I’ve noticed that CAN talons have two methods that seem to set encoder positions: setPosition() and setEncPosition(). Does anyone know what the difference is? Neither are working for us and I was wondering if each is to be used in certain situations. Thanks!
setPosition (to the best of my knowledge) sets the setpoint of the PID where setEncPosition configures the sensor to be at that value
This is the source of my confusion, section 13.3 of the talon srx software manual says that setPosition() sets the sensor position so setPosition(0) would zero the encoder. Does setPosition() only set the encoder value when the talon isn’t in PID mode and it sets the setpoint when it is in PID mode, while setEncPosition() sets the sensor position no matter the talon’s control mode?
Where did you get “setEncPosition()” from?
Yes, one of the things about it that confuses me is that the software manual says that setPosition(0) will zero a quadrature encoder (which we’re using), but when we call that method the value returned from getEncPosition() doesn’t change and the manual doesn’t even mention setEncPosition(), but it exists, although it also doesn’t change the value of getEncPosition().
We found setEncPosition() by looking at the suggestions from content assist in eclipse after typing setPos. We tried both setEncPosition(0) and setPosition(0), but neither seemed to work.
You must select the sensor type before calling setPosition(). setpos and getpos are for the “selected” sensor.
Also be aware that calling setPosition doesn’t instantly clear the return of the next getPosition(), leave at least 20ms or so for the Talon Feedback Status Frame to update the RIO. Then call getPosition(). It does however clear the position in the firmware of the Talon within 100us or so.
setEncPosition/getEncPosition are low level functions for quadrature encoder. They do not update as fast but provide low-level api for getting sensor values from all sensor types at once. See section 16.9 for more info. Similarly there are GetAnalo* functions for analog sensors, and GetPulseWid* funcs for pulse width sensors.
Ah, thank you for the clarification.
My bad, I had that confused with the setSetpoint function.
for future reference, this is a great resource https://www.ctr-electronics.com/Talon%20SRX%20Software%20Reference%20Manual.pdf
of what document?
The document that I posted, I assume (though my last assumption in this thread was wrong so who knows. 16.9 in that document refers to “why are there multiple methods of gathering encoder data” so i believe it to be correct).
Please post a screenshot showing “setEncPosition” anywhere in that document.