Package swervelib.imu
Class NavXSwerve
java.lang.Object
swervelib.imu.SwerveIMU
swervelib.imu.NavXSwerve
- All Implemented Interfaces:
AutoCloseable
Communicates with the NavX(
AHRS) as the IMU.-
Constructor Summary
ConstructorsConstructorDescriptionNavXSwerve(com.studica.frc.AHRS.NavXComType port) Constructor for the NavX(AHRS) swerve. -
Method Summary
Modifier and TypeMethodDescriptionvoidClear sticky faults on IMU.voidclose()voidReset offset to current gyro reading.getAccel()Fetch the acceleration [x, y, z] from the IMU in meters per second squared.getIMU()Get the instantiated NavX(AHRS) IMU object.Fetch theRotation3dfrom the IMU without any zeroing.Fetch theRotation3dfrom the IMU.Fetch the rotation rate from the IMU asMutAngularVelocityvoidsetInverted(boolean invertIMU) Set the gyro to invert its default directionvoidsetOffset(Rotation3d offset) Set the gyro offset.
-
Constructor Details
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein classSwerveIMU
-
factoryDefault
public void factoryDefault()Reset offset to current gyro reading. Does not call NavX(AHRS.reset()) because it has been reported to be too slow.- Specified by:
factoryDefaultin classSwerveIMU
-
clearStickyFaults
public void clearStickyFaults()Clear sticky faults on IMU.- Specified by:
clearStickyFaultsin classSwerveIMU
-
setOffset
Set the gyro offset.- Specified by:
setOffsetin classSwerveIMU- Parameters:
offset- gyro offset as aRotation3d.
-
setInverted
public void setInverted(boolean invertIMU) Set the gyro to invert its default direction- Specified by:
setInvertedin classSwerveIMU- Parameters:
invertIMU- invert gyro direction
-
getRawRotation3d
Fetch theRotation3dfrom the IMU without any zeroing. Robot relative.- Specified by:
getRawRotation3din classSwerveIMU- Returns:
Rotation3dfrom the IMU.
-
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.- Specified by:
getAccelin classSwerveIMU- Returns:
Translation3dof the acceleration as anOptional.
-
getYawAngularVelocity
Description copied from class:SwerveIMUFetch the rotation rate from the IMU asMutAngularVelocity- Specified by:
getYawAngularVelocityin classSwerveIMU- Returns:
MutAngularVelocityof the rotation rate.
-
getIMU
Get the instantiated NavX(AHRS) IMU object.
-