Hello, is there a function that can be used from the C++ wpilib to reset encoders that are connected to Jaguars. I’m doing a position drive with CAN and unless I reboot the cRIO the position values never reset.
If you’re using the Jaguar in kPosition mode, the EnableControl method has an encoderInitialPosition parameter that will set and initial position for the encoder.
Otherwise, I’m going to need to dig into the Jaguar code tomorrow to see when and how the encoder position gets reset and all that.
Thanks though I actually wanted to know how to reset the actual encoder and it just still dosen’t seem to be a way.
Okay, so I’m looking to see if there’s a way you can reset the Jaguar’s encoder counts so that getPosition() will read 0.0 or some number you send it instead of reading whatever number the encoder has counted up to while it’s running. That what I’m calling “resetting the encoder”. Are you trying to do something different or something?
Just checked the TI Jaguar firmware source code. The encoder position is set to 0.0 when the Jaguar powers on, and it can be set to an arbitrary number when you enable position control mode by calling ChangeControlMode(kPosition) then calling EnableControl(double initialPosition). It’s the call to EnableControl while you’re in kPosition mode that resets the encoder position. I believe you can call EnableControl again while in kPosition mode to reset the encoder without disabling the position control.
Oh thankyou for stating that, I forgot about that part. I’ll try it and yeah I’m just trying to reset the encoder. It’s to build a library that will contain commands that will make the robot do certain movements. Then with the library I can stack together blocks of movements to make a whole auton driving code.
Oh hey thanks and It works!