Open jzhang010 opened 4 years ago
Changing the encoder suppliers shouldn’t affect the robot driving. The behavior of the data logger almost sounds like the logger wasn’t connected to the robot for the test with a modified template. Your encoder code snippet looks fine, although it’s hard to rule out added errant code without seeing your entire Robot.java.
Our team doesn't want to use talons SRX this year to conserve space with the new Falcon 500 motors, so we opted for CANCoders instead for greater precision over the built in falcon 500 encoders. I tried changing the code in Robot.java to read from the CANCoders for the characterization data logger since the it defaults to reading from encoders being plugged into a Talon SRX. However, the robot ended up not moving at all when I tried running the Quasistatic forward process in Autonomous mode and the data logger didn't stop the Quasistatic forward process when I disabled the Autonomous mode. The robot did move when we tested the default code, without making any changes to the default encoder code.
Here's the code we wrote to use values from the CANCoder instead:
leftEncoder = new CANCoder (13);
rightEncoder = new CANCoder (12);
leftEncoderPosition = () -> leftEncoder.getPosition()*encoderConstant;
leftEncoderRate = () -> leftEncoder.getVelocity()*encoderConstant*10;
rightEncoderPosition = () -> rightEncoder.getPosition()*encoderConstant;
rightEncoderRate = () -> rightEncoder.getVelocity()*encoderConstant*10;