Quote:
Originally Posted by PriyankP
Sorry to bring up this relatively old topic but I was wondering how are you using encoders to go to a certain distance? Do you just have PID and Setpoint encoders to some number? Or are you using something else too?
Any other teams out there willing to share how they use their encoders in autonomous? 
|
I have two encoders hooked up to jaguars running CAN one for the left side and the other for the right side. The autonomous does P (No need for ID) so that it slows down as it gets closer until it hits the wall going pretty slowly. This runs reliably as long as it's lined up and the left and right sides act the same. i.e. You jam both joysticks forward and it actually drives straight-ish.
Here's the relevant code.
Code:
leftDist = bot.dt.getLeftDist() - leftStart;
rightDist = bot.dt.getRightDist() - rightStart;
double left = gain * ((distance - leftDist) / distance);
double right = gain * ((distance - rightDist) / distance);
bot.dt.drive(left, right, bot.gyro);
distance is the distance you wish to travel in feet.
gain is the initial value that gets toned down as you drive (Currently using 0.7)
Hopefully the rest of the code is clear enough that it makes sense. If you have anymore questions feel free to ask. Also, you can PM me if you want to see our full autonomous code.