Quote:
Originally Posted by ekapalka
This is quite similar to what we did this year  Except we used ours as an active aim-assist to put ourselves the correct distance from whatever was in front of us when a button was held. We literally got it working ten minutes after the last match :/ Our autonomous and teleop aim-assist could be reduced down to just a few lines of code using the map() function we replicated from the Arduino language. For both the range was smoothed using a moving average to avoid jittering.
Code:
ForwardSpeed = map(rangefinder_distance - target_distance, 0, 200, 0, 1);
The map() function takes an input (in our case from a rangefinder), the minimum expected value of that input, the maximum expected value of that input, the minimum value to output, and the maximum value to output.
|
I read part way through that and I was like awesome, someone has decided to use
map,
filter and
fold. That's still pretty cool though. We started writing something like that but didn't finish because it didn't fit how we played the game.