wpilibsuite / frc-characterization

Tools to help FRC teams measure the physical parameters of their robot
Apache License 2.0
51 stars 41 forks source link

Using CANCoders #100

Open jzhang010 opened 4 years ago

jzhang010 commented 4 years ago

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;

pietroglyph commented 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.