58 | | Add the following function to the Robot class: |
59 | | {{{ |
60 | | double raw2inches(int raw_count, int counts_per_rotation, double wheel_diameter) { |
61 | | return (raw_count / counts_per_rotation) * (3.141492 * wheel_diameter); |
62 | | } |
63 | | }}} |
64 | | Add the following to the robotPeriodic() method: |
65 | | // Encoders connected to CAN controller return raw counts |
66 | | double l_raw = leftMotor.getSelectedSensorPosition(); |
67 | | double r_raw = rightMotor.getSelectedSensorPosition(); |
68 | | // display distances on smart dashboard |
69 | | SmartDashboard.putNumber("Left", raw2inches(l_raw, 360*2, 7.5)); |
70 | | SmartDashboard.putNumber("Right", raw2inches(r_raw, 360*2, 7.5)); |
71 | | }}} |
| 58 | * Add the following function to the Robot class: |
| 59 | {{{ |
| 60 | double raw2inches(int raw_count, int counts_per_rotation, double wheel_diameter) { |
| 61 | return (raw_count / counts_per_rotation) * (3.141492 * wheel_diameter); |
| 62 | } |
| 63 | }}} |
| 64 | * Add the following to the robotPeriodic() method: |
| 65 | {{{ |
| 66 | // Encoders connected to CAN controller return raw counts |
| 67 | double l_raw = leftMotor.getSelectedSensorPosition(); |
| 68 | double r_raw = rightMotor.getSelectedSensorPosition(); |
| 69 | // display distances on smart dashboard |
| 70 | SmartDashboard.putNumber("Left", raw2inches(l_raw, 360*2, 7.5)); |
| 71 | SmartDashboard.putNumber("Right", raw2inches(r_raw, 360*2, 7.5)); |
| 72 | }}} |