View Single Post
  #13   Spotlight this post!  
Unread 18-05-2014, 00:52
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
Re: What's your favorite programming/control system magic this year?

Quote:
Originally Posted by Joey1939 View Post
1986 had really simple yet effective targeting system setup. A ultrasonic sensor set low to the ground told them how far away they were from the wall. When the robot was in shooting range, LEDs on the back of the robot lit up to inform the drivers.
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. The input/output ranged aren't exactly set in stone... if the input is greater than expected, the output will also be outside of the expected range (meaning that the above piece of code can be used when too close or too far away from the wall, even though the output should fall between 0 and 1. It just re-maps values from one range to another. We pretty much programmed the entire robot on the fly during competition this year, so the only time we had to test out changes during matches. We ended up running into the wall on more than one occasion due to this...

Last edited by ekapalka : 18-05-2014 at 01:22.