JHS-Viking-Robotics / FRC-2022

Code for the 2022 FRC season, now written in Java
Other
2 stars 2 forks source link

Refactor drivetrain to use WPILib #13

Closed derickson2402 closed 3 years ago

derickson2402 commented 3 years ago

Drivetrain is currently built using the CTRE Phoenix library, which is how all motors were handled previously.

However, for a differential drivetrain there is no CTRE Phoenix classes to make differential calculations or trajectory following work, so it would have to be implemented by hand.

To fix this, the WPILib should be used to handle the motors instead. This would provide the following benefits:

The WPILib brings the following drawbacks compared to Phoenix, but these seem acceptable given the benefits:

derickson2402 commented 3 years ago

This issue was forgotten about, and has actually been closed.

WPILib encoder classes are only for DIO encoders, so all CTRE hardware must be handled by CTRE Phoenix library. However, the WPILib has built in Kinematics and Odometry helper classes, which offer the desired functionality for mapping controllers to motor outputs.

The code now uses both libraries, and also implements the Shuffleboard dashboard (see #6). In the future, a gyro can also be integrated easily using WPILib.

Closed with 73e017d