Package edu.wpi.first.wpilibj
Class ADIS16448_IMU
- java.lang.Object
-
- edu.wpi.first.wpilibj.ADIS16448_IMU
-
- All Implemented Interfaces:
NTSendable
,Sendable
,AutoCloseable
public class ADIS16448_IMU extends Object implements AutoCloseable, NTSendable
This class is for the ADIS16448 IMU that connects to the RoboRIO MXP port.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ADIS16448_IMU.CalibrationTime
static class
ADIS16448_IMU.IMUAxis
-
Constructor Summary
Constructors Constructor Description ADIS16448_IMU()
ADIS16448_IMU(ADIS16448_IMU.IMUAxis yaw_axis, SPI.Port port, ADIS16448_IMU.CalibrationTime cal_time)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
calibrate()
Calibrate the gyro.void
close()
Delete (free) the spi port used for the IMU.int
configCalTime(ADIS16448_IMU.CalibrationTime new_cal_time)
Configures calibration timeint
configDecRate(int m_decRate)
double
getAccelX()
double
getAccelY()
double
getAccelZ()
double
getAngle()
double
getBarometricPressure()
double
getGyroAngleX()
double
getGyroAngleY()
double
getGyroAngleZ()
double
getGyroRateX()
double
getGyroRateY()
double
getGyroRateZ()
double
getMagneticFieldX()
double
getMagneticFieldY()
double
getMagneticFieldZ()
int
getPort()
Get the SPI port number.double
getRate()
double
getTemperature()
double
getXComplementaryAngle()
double
getXFilteredAccelAngle()
ADIS16448_IMU.IMUAxis
getYawAxis()
double
getYComplementaryAngle()
double
getYFilteredAccelAngle()
void
initSendable(NTSendableBuilder builder)
Initializes thisSendable
object.void
reset()
int
setYawAxis(ADIS16448_IMU.IMUAxis yaw_axis)
Sets the yaw axisstatic int
toUShort(int... buf)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface edu.wpi.first.networktables.NTSendable
initSendable
-
-
-
-
Constructor Detail
-
ADIS16448_IMU
public ADIS16448_IMU()
-
ADIS16448_IMU
public ADIS16448_IMU(ADIS16448_IMU.IMUAxis yaw_axis, SPI.Port port, ADIS16448_IMU.CalibrationTime cal_time)
- Parameters:
yaw_axis
- The axis that measures the yawport
- The SPI Port the gyro is plugged intocal_time
- Calibration time
-
-
Method Detail
-
toUShort
public static int toUShort(int... buf)
-
configDecRate
public int configDecRate(int m_decRate)
-
configCalTime
public int configCalTime(ADIS16448_IMU.CalibrationTime new_cal_time)
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
public void 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
public int setYawAxis(ADIS16448_IMU.IMUAxis yaw_axis)
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
public void reset()
-
close
public void close()
Delete (free) the spi port used for the IMU.- Specified by:
close
in interfaceAutoCloseable
-
getAngle
public double getAngle()
- Returns:
- Yaw axis angle in degrees (CCW positive)
-
getRate
public double getRate()
- Returns:
- Yaw axis angular rate in degrees per second (CCW positive)
-
getYawAxis
public ADIS16448_IMU.IMUAxis getYawAxis()
- Returns:
- Yaw Axis
-
getGyroAngleX
public double getGyroAngleX()
- Returns:
- accumulated gyro angle in the X axis in degrees
-
getGyroAngleY
public double getGyroAngleY()
- Returns:
- accumulated gyro angle in the Y axis in degrees
-
getGyroAngleZ
public double getGyroAngleZ()
- Returns:
- accumulated gyro angle in the Z axis in degrees
-
getGyroRateX
public double getGyroRateX()
- Returns:
- gyro angular rate in the X axis in degrees per second
-
getGyroRateY
public double getGyroRateY()
- Returns:
- gyro angular rate in the Y axis in degrees per second
-
getGyroRateZ
public double getGyroRateZ()
- Returns:
- gyro angular rate in the Z axis in degrees per second
-
getAccelX
public double getAccelX()
- Returns:
- urrent acceleration in the X axis in meters per second squared
-
getAccelY
public double getAccelY()
- Returns:
- current acceleration in the Y axis in meters per second squared
-
getAccelZ
public double getAccelZ()
- Returns:
- current acceleration in the Z axis in meters per second squared
-
getMagneticFieldX
public double getMagneticFieldX()
- Returns:
- Magnetic field strength in the X axis in Tesla
-
getMagneticFieldY
public double getMagneticFieldY()
- Returns:
- Magnetic field strength in the Y axis in Tesla
-
getMagneticFieldZ
public double getMagneticFieldZ()
- Returns:
- Magnetic field strength in the Z axis in Tesla
-
getXComplementaryAngle
public double getXComplementaryAngle()
- Returns:
- X axis complementary angle in degrees
-
getYComplementaryAngle
public double getYComplementaryAngle()
- Returns:
- Y axis complementary angle in degrees
-
getXFilteredAccelAngle
public double getXFilteredAccelAngle()
- Returns:
- X axis filtered acceleration angle in degrees
-
getYFilteredAccelAngle
public double getYFilteredAccelAngle()
- Returns:
- Y axis filtered acceleration angle in degrees
-
getBarometricPressure
public double getBarometricPressure()
- Returns:
- Barometric Pressure in PSI
-
getTemperature
public double getTemperature()
- Returns:
- Temperature in degrees Celsius
-
getPort
public int getPort()
Get the SPI port number.- Returns:
- The SPI port number.
-
initSendable
public void initSendable(NTSendableBuilder builder)
Description copied from interface:NTSendable
Initializes thisSendable
object.- Specified by:
initSendable
in interfaceNTSendable
- Parameters:
builder
- sendable builder
-
-