Team5830 / 2023-Charged-Up

MIT License
0 stars 0 forks source link

Add NavX to drivetrain subsystem #1

Closed asteele11 closed 1 year ago

asteele11 commented 1 year 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/