Is there a command for resetting CANencoder values to zero? If so, what is it?
The encoder values reset automatically after powering on, but we would like to be able to reset them at other times as well.
Is there a command for resetting CANencoder values to zero? If so, what is it?
The encoder values reset automatically after powering on, but we would like to be able to reset them at other times as well.
I don’t see anything in the API to do this. If you need this capability, the cleanest way is to wrap the CANencoder in another class which implements the reset by saving the current value of getPosition() from the CANEncoder in an instance variable and subtracting it from all subsequent calls to your class’ getPosition().
If you’re talking about the SRX encoder that plugs into a Talon check out this post.
Help with setting a mag encoder position to zero
If that is not the encoder you are talking about then can I ask what a CANencoder is?
Looks like REV will be adding this to the API soon:
In the mean time, could you set it yourself by getting the count before your particular method runs like so (psuedocode)?
oldEncoderValue = getEncoderValue
While True:
currentEncoderValue = getEncoderValue
If (currentEncoderValue >= oldEncoderValue)
do stuff
Else:
Do different stuff