Team5830 / 2022-Rapid-React

Team 5830's robot code for FIRST Rapid React (2022)
MIT License
0 stars 0 forks source link

Add the NavX Gyro to the DriveTrain subsystem #3

Closed asteele11 closed 2 years ago

asteele11 commented 2 years ago

Description of how to add a Gryo

The link below provides an example but uses a different type of hardware. Instead of using the ADXRS450_Gyro, we use the Gryo on the NavX board over a USB connection. If the driver is installed on your computer it can be loaded with:

import com.kauailabs.navx.frc.AHRS;

https://github.com/wpilibsuite/allwpilib/blob/main/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gyrodrivecommands/subsystems/DriveSubsystem.java

An addition to the above example code it would be good to add a "try catch" statement around the instantiation of the NavX: like:

try { ahrs = new AHRS(SerialPort.Port.kUSB1); ahrs.enableLogging(true); } catch (RuntimeException ex ) { DriverStation.reportError("Error instantiating navX MXP: " + ex.getMessage(), true); }

Additional Information about the NavX

https://www.andymark.com/products/navx-mxp-robotics-navigation-sensor

Example code with NavX: https://pdocs.kauailabs.com/navx-mxp/examples/