Questions with encoders

Hi guys!

I hope you can help me out with this one…

My team is planning to use the E4T OEM Miniature Optical Encoders to run our autonomous with precision, but the only problem is that nobody knows how to use them?

Could you guys please provide us with the info on how to declare them, how to configure them and finally how to use the to tell the robot to stop until a certain distance is reached?

Thanks!

https://wpilib.screenstepslive.com/s/currentCS/m/java/l/599717-encoders-measuring-rotation-of-a-wheel-or-other-shaft this is a good place to start.

Then I’d make a new command, that drives straight, and in the commands isFinished method, check to see if youve driven the desired distance.

"Driving straight " can require closed loop controllers and a gyro sensor depending on how accurate you’re trying to be, but if you don’t really care what your orientation is at the end of the distance driven (say you just want to cross a line in auto), driving straight can be as simple as setting two fixed % Voltage commands to either side of your drivetrain’s motor controllers. Distance driven and heading will vary slightly run by run, but sometimes thats good enough…