Package edu.wpi.first.wpilibj
Class ADIS16448_IMU
java.lang.Object
edu.wpi.first.wpilibj.ADIS16448_IMU
- All Implemented Interfaces:
Sendable,AutoCloseable
This class is for the ADIS16448 IMU that connects to the RoboRIO MXP port.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumADIS16448 calibration times.static enumIMU axes. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new ADIS16448_IMU object.ADIS16448_IMU(ADIS16448_IMU.IMUAxis yaw_axis, SPI.Port port, ADIS16448_IMU.CalibrationTime cal_time) Creates a new ADIS16448_IMU object. -
Method Summary
Modifier and TypeMethodDescriptionvoidCalibrate the gyro.voidclose()Delete (free) the spi port used for the IMU.final intconfigCalTime(ADIS16448_IMU.CalibrationTime new_cal_time) Configures calibration time.intconfigDecRate(int decimationRate) Configures the decimation rate of the IMU.doubleReturns the acceleration in the X axis in meters per second squared.doubleReturns the acceleration in the Y axis in meters per second squared.doubleReturns the acceleration in the Z axis in meters per second squared.doublegetAngle()Returns the yaw axis angle in degrees (CCW positive).doubleReturns the barometric pressure in PSI.doubleReturns the accumulated gyro angle in the X axis in degrees.doubleReturns the accumulated gyro angle in the Y axis in degrees.doubleReturns the accumulated gyro angle in the Z axis in degrees.doubleReturns the gyro angular rate in the X axis in degrees per second.doubleReturns the gyro angular rate in the Y axis in degrees per second.doubleReturns the gyro angular rate in the Z axis in degrees per second.doubleReturns the magnetic field strength in the X axis in Tesla.doubleReturns the magnetic field strength in the Y axis in Tesla.doubleReturns the magnetic field strength in the Z axis in Tesla.intgetPort()Get the SPI port number.doublegetRate()Returns the yaw axis angular rate in degrees per second (CCW positive).doubleReturns the temperature in degrees Celsius.doubleReturns the complementary angle around the X axis computed from accelerometer and gyro rate measurements.doubleReturns the X-axis filtered acceleration angle in degrees.Returns which axis, kX, kY, or kZ, is set to the yaw axis.doubleReturns the complementary angle around the Y axis computed from accelerometer and gyro rate measurements.doubleReturns the Y-axis filtered acceleration angle in degrees.voidinitSendable(SendableBuilder builder) Initializes thisSendableobject.booleanChecks the connection status of the IMU.voidreset()Reset the gyro.intsetYawAxis(ADIS16448_IMU.IMUAxis yaw_axis) Sets the yaw axis.
-
Constructor Details
-
ADIS16448_IMU
public ADIS16448_IMU()Creates a new ADIS16448_IMU object. -
ADIS16448_IMU
public ADIS16448_IMU(ADIS16448_IMU.IMUAxis yaw_axis, SPI.Port port, ADIS16448_IMU.CalibrationTime cal_time) Creates a new ADIS16448_IMU object.- Parameters:
yaw_axis- The axis that measures the yawport- The SPI Port the gyro is plugged intocal_time- Calibration time
-
-
Method Details
-
isConnected
Checks the connection status of the IMU.- Returns:
- True if the IMU is connected, false otherwise.
-
configDecRate
Configures the decimation rate of the IMU.- Parameters:
decimationRate- The new decimation value.- Returns:
- 0 if success, 1 if no change, 2 if error.
-
configCalTime
Configures calibration time.- Parameters:
new_cal_time- New calibration time- Returns:
- 1 if the new calibration time is the same as the current one else 0
-
calibrate
Calibrate the gyro. It's important to make sure that the robot is not moving while the calibration is in progress, this is typically done when the robot is first turned on while it's sitting at rest before the match starts. -
setYawAxis
Sets the yaw axis.- Parameters:
yaw_axis- The new yaw axis to use- Returns:
- 1 if the new yaw axis is the same as the current one else 0.
-
reset
Reset the gyro.Resets the gyro accumulations to a heading of zero. This can be used if there is significant drift in the gyro and it needs to be recalibrated after running.
-
close
Delete (free) the spi port used for the IMU.- Specified by:
closein interfaceAutoCloseable
-
getAngle
Returns the yaw axis angle in degrees (CCW positive).- Returns:
- Yaw axis angle in degrees (CCW positive).
-
getRate
Returns the yaw axis angular rate in degrees per second (CCW positive).- Returns:
- Yaw axis angular rate in degrees per second (CCW positive).
-
getYawAxis
Returns which axis, kX, kY, or kZ, is set to the yaw axis.- Returns:
- IMUAxis Yaw Axis
-
getGyroAngleX
Returns the accumulated gyro angle in the X axis in degrees.- Returns:
- The accumulated gyro angle in the X axis in degrees.
-
getGyroAngleY
Returns the accumulated gyro angle in the Y axis in degrees.- Returns:
- The accumulated gyro angle in the Y axis in degrees.
-
getGyroAngleZ
Returns the accumulated gyro angle in the Z axis in degrees.- Returns:
- The accumulated gyro angle in the Z axis in degrees.
-
getGyroRateX
Returns the gyro angular rate in the X axis in degrees per second.- Returns:
- The gyro angular rate in the X axis in degrees per second.
-
getGyroRateY
Returns the gyro angular rate in the Y axis in degrees per second.- Returns:
- The gyro angular rate in the Y axis in degrees per second.
-
getGyroRateZ
Returns the gyro angular rate in the Z axis in degrees per second.- Returns:
- The gyro angular rate in the Z axis in degrees per second.
-
getAccelX
Returns the acceleration in the X axis in meters per second squared.- Returns:
- The acceleration in the X axis in meters per second squared.
-
getAccelY
Returns the acceleration in the Y axis in meters per second squared.- Returns:
- The acceleration in the Y axis in meters per second squared.
-
getAccelZ
Returns the acceleration in the Z axis in meters per second squared.- Returns:
- The acceleration in the Z axis in meters per second squared.
-
getMagneticFieldX
Returns the magnetic field strength in the X axis in Tesla.- Returns:
- The magnetic field strength in the X axis in Tesla.
-
getMagneticFieldY
Returns the magnetic field strength in the Y axis in Tesla.- Returns:
- The magnetic field strength in the Y axis in Tesla.
-
getMagneticFieldZ
Returns the magnetic field strength in the Z axis in Tesla.- Returns:
- The magnetic field strength in the Z axis in Tesla.
-
getXComplementaryAngle
Returns the complementary angle around the X axis computed from accelerometer and gyro rate measurements.- Returns:
- The X-axis complementary angle in degrees.
-
getYComplementaryAngle
Returns the complementary angle around the Y axis computed from accelerometer and gyro rate measurements.- Returns:
- The Y-axis complementary angle in degrees.
-
getXFilteredAccelAngle
Returns the X-axis filtered acceleration angle in degrees.- Returns:
- The X-axis filtered acceleration angle in degrees.
-
getYFilteredAccelAngle
Returns the Y-axis filtered acceleration angle in degrees.- Returns:
- The Y-axis filtered acceleration angle in degrees.
-
getBarometricPressure
Returns the barometric pressure in PSI.- Returns:
- The barometric pressure in PSI.
-
getTemperature
Returns the temperature in degrees Celsius.- Returns:
- The temperature in degrees Celsius.
-
getPort
Get the SPI port number.- Returns:
- The SPI port number.
-
initSendable
Description copied from interface:SendableInitializes thisSendableobject.- Specified by:
initSendablein interfaceSendable- Parameters:
builder- sendable builder
-