Package swervelib.imu
Class NavXSwerve
java.lang.Object
swervelib.imu.SwerveIMU
swervelib.imu.NavXSwerve
Communicates with the NavX as the IMU.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionNavXSwerve(edu.wpi.first.wpilibj.SerialPort.Port port) Constructor for the NavX swerve. -
Method Summary
Modifier and TypeMethodDescriptionvoidClear sticky faults on IMU.voidReset IMU to factory default.Optional<edu.wpi.first.math.geometry.Translation3d>getAccel()Fetch the acceleration [x, y, z] from the IMU in meters per second squared.getIMU()Get the instantiated IMU object.edu.wpi.first.math.geometry.Rotation3dFetch theRotation3dfrom the IMU.voidgetYawPitchRoll(double[] yprArray) Fetch the yaw/pitch/roll from the IMU.voidsetYaw(double yaw) Set the yaw in degrees.
-
Field Details
-
gyro
private com.kauailabs.navx.frc.AHRS gyroNavX IMU. -
yawOffset
private double yawOffsetOffset for the NavX yaw reading.
-
-
Constructor Details
-
NavXSwerve
public NavXSwerve(edu.wpi.first.wpilibj.SerialPort.Port port) Constructor for the NavX swerve.- Parameters:
port- Serial Port to connect to.
-
-
Method Details
-
factoryDefault
public void factoryDefault()Reset IMU to factory default.- Specified by:
factoryDefaultin classSwerveIMU
-
clearStickyFaults
public void clearStickyFaults()Clear sticky faults on IMU.- Specified by:
clearStickyFaultsin classSwerveIMU
-
setYaw
public void setYaw(double yaw) Set the yaw in degrees. -
getYawPitchRoll
public void getYawPitchRoll(double[] yprArray) Fetch the yaw/pitch/roll from the IMU.- Specified by:
getYawPitchRollin classSwerveIMU- Parameters:
yprArray- Array which will be filled with {yaw, pitch, roll} in degrees.
-
getRotation3d
public edu.wpi.first.math.geometry.Rotation3d getRotation3d()Fetch theRotation3dfrom the IMU. Robot relative.- Specified by:
getRotation3din classSwerveIMU- Returns:
Rotation3dfrom the IMU.
-
getAccel
Fetch the acceleration [x, y, z] from the IMU in meters per second squared. If acceleration isn't supported returns empty. -
getIMU
Get the instantiated IMU object.
-