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:
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/