Check if neos are at setpoint

Is there any way to check if the neo’s built in encoders have reached the setpoint? I didn’t find anything in the REVlib java docs. Has anyone had success with this in the past?

I never found anything in the JavaDoc for getting the setpoint/reference back out of the PID Controller, or any direct “On Target” value. We simply stored the set point separately every-time we updated it on the controllers, and wrote our own check.

would this work for positional PID as well?

Depends on how exactly you plan to copy it. Clearly you’d need to change to GetPosition() from the Encoder instead of getVelocity() and take into account all the stuff for setting unit conversion factor, ect. But the math itself should transfer over fine, assuming everything will be in the same units.

yes. I’m using meters and the conversion factor for the neo integrated encoder is a little more straight forward than for other encoders. Thanks a lot!

When looking at position it is also a good idea to make sure velocity is near 0. If you have an auto routine of driving followed by shooting, you don’t want to start shooting the moment the robot enters the target threshold as it will still have some momentum and might even be overshooting. Make sure it is on target and has come to a stop.

5 Likes

This is a very good point! If you’re truly at your setpoint (or very near) your velocity should be about zero.

Should I just use the above code to check if the velocity is 0 before ending the routine?

Yes, the principle is the same.

implemented. Will test in about an hour and a half! Thanks so much!