View Single Post
  #3   Spotlight this post!  
Unread 04-02-2016, 22:29
Dan Waxman Dan Waxman is offline
Registered User
FRC #0263 (Aftershock)
Team Role: Programmer
 
Join Date: Feb 2016
Rookie Year: 2016
Location: Long Island
Posts: 34
Dan Waxman is an unknown quantity at this point
Re: Problems with Encoders

If you would like to just start at a certain angle, you're going to have a few issues.

Your first issue is that if you just stop your motors at a certain angle, you will get a ridiculous amount of overshoot. In order to fix this, I would use a PID system. You have the option of using the PIDSubsystem that WPILib has built in (a quick tutorial for which can be found here), or you can write your own. I wrote my own due to a little issue I found with the built in PID subsystem, but by all means you can use the built in sub system. If you would like a better explanation of what a PID Controller is/how it works, here's a fantastic video explaining it.

Another issue you'll find is that if you don't implement a PID system, encoders don't usually report back in angles anyways. We have two encoders on my team, one where a full rotation is 1500 from encoder.getRaw(), another type where a full rotation is 1000. To convert from degrees to encoder ticks, you would multiply by (ticks per full rotation / 360). To convert to degrees, you would multiply by (360 / ticks per full rotation). You would have to figure out what your encoders rotation is empirically.

If you have any questions, feel free to message me. Sorry if anything is fuzzy, very tired right now.
Reply With Quote