WPILibC++ 2024.3.2
frc::ADIS16448_IMU Class Reference

Use DMA SPI to read rate, acceleration, and magnetometer data from the ADIS16448 IMU and return the robots heading relative to a starting position, AHRS, and instant measurements. More...

#include <frc/ADIS16448_IMU.h>

Inheritance diagram for frc::ADIS16448_IMU:
wpi::Sendable wpi::SendableHelper< ADIS16448_IMU >

Public Types

enum class  CalibrationTime {
  _32ms = 0 , _64ms = 1 , _128ms = 2 , _256ms = 3 ,
  _512ms = 4 , _1s = 5 , _2s = 6 , _4s = 7 ,
  _8s = 8 , _16s = 9 , _32s = 10 , _64s = 11
}
 ADIS16448 calibration times. More...
 
enum  IMUAxis { kX , kY , kZ }
 IMU axes. More...
 

Public Member Functions

 ADIS16448_IMU ()
 IMU constructor on onboard MXP CS0, Z-up orientation, and complementary AHRS computation. More...
 
 ADIS16448_IMU (IMUAxis yaw_axis, SPI::Port port, CalibrationTime cal_time)
 IMU constructor on the specified MXP port and orientation. More...
 
 ~ADIS16448_IMU () override
 
 ADIS16448_IMU (ADIS16448_IMU &&)
 
ADIS16448_IMUoperator= (ADIS16448_IMU &&)
 
void Calibrate ()
 Initialize the IMU. More...
 
int ConfigCalTime (CalibrationTime new_cal_time)
 Configures the calibration time used for the next calibrate. More...
 
void Reset ()
 Reset the gyro. More...
 
units::degree_t GetAngle () const
 Returns the yaw axis angle in degrees (CCW positive). More...
 
units::degrees_per_second_t GetRate () const
 Returns the yaw axis angular rate in degrees per second (CCW positive). More...
 
units::degree_t GetGyroAngleX () const
 Returns the accumulated gyro angle in the X axis. More...
 
units::degree_t GetGyroAngleY () const
 Returns the accumulated gyro angle in the Y axis. More...
 
units::degree_t GetGyroAngleZ () const
 Returns the accumulated gyro angle in the Z axis. More...
 
units::degrees_per_second_t GetGyroRateX () const
 Returns the angular rate in the X axis. More...
 
units::degrees_per_second_t GetGyroRateY () const
 Returns the angular rate in the Y axis. More...
 
units::degrees_per_second_t GetGyroRateZ () const
 Returns the angular rate in the Z axis. More...
 
units::meters_per_second_squared_t GetAccelX () const
 Returns the acceleration in the X axis. More...
 
units::meters_per_second_squared_t GetAccelY () const
 Returns the acceleration in the Y axis. More...
 
units::meters_per_second_squared_t GetAccelZ () const
 Returns the acceleration in the Z axis. More...
 
units::degree_t GetXComplementaryAngle () const
 Returns the complementary angle around the X axis computed from accelerometer and gyro rate measurements. More...
 
units::degree_t GetYComplementaryAngle () const
 Returns the complementary angle around the Y axis computed from accelerometer and gyro rate measurements. More...
 
units::degree_t GetXFilteredAccelAngle () const
 Returns the X-axis filtered acceleration angle. More...
 
units::degree_t GetYFilteredAccelAngle () const
 Returns the Y-axis filtered acceleration angle. More...
 
units::tesla_t GetMagneticFieldX () const
 Returns the magnetic field strength in the X axis. More...
 
units::tesla_t GetMagneticFieldY () const
 Returns the magnetic field strength in the Y axis. More...
 
units::tesla_t GetMagneticFieldZ () const
 Returns the magnetic field strength in the Z axis. More...
 
units::pounds_per_square_inch_t GetBarometricPressure () const
 Returns the barometric pressure. More...
 
units::celsius_t GetTemperature () const
 Returns the temperature. More...
 
IMUAxis GetYawAxis () const
 
int SetYawAxis (IMUAxis yaw_axis)
 
bool IsConnected () const
 Checks the connection status of the IMU. More...
 
int ConfigDecRate (uint16_t decimationRate)
 Configures the decimation rate of the IMU. More...
 
int GetPort () const
 Get the SPI port number. More...
 
void InitSendable (wpi::SendableBuilder &builder) override
 Initializes this Sendable object. More...
 
- Public Member Functions inherited from wpi::Sendable
virtual ~Sendable ()=default
 
virtual void InitSendable (SendableBuilder &builder)=0
 Initializes this Sendable object. More...
 
- Public Member Functions inherited from wpi::SendableHelper< ADIS16448_IMU >
 SendableHelper (const SendableHelper &rhs)=default
 
 SendableHelper (SendableHelper &&rhs)
 
SendableHelperoperator= (const SendableHelper &rhs)=default
 
SendableHelperoperator= (SendableHelper &&rhs)
 

Additional Inherited Members

- Protected Member Functions inherited from wpi::SendableHelper< ADIS16448_IMU >
 SendableHelper ()=default
 
 ~SendableHelper ()
 

Detailed Description

Use DMA SPI to read rate, acceleration, and magnetometer data from the ADIS16448 IMU and return the robots heading relative to a starting position, AHRS, and instant measurements.

The ADIS16448 gyro angle outputs track the robot's heading based on the starting position. As the robot rotates the new heading is computed by integrating the rate of rotation returned by the IMU. When the class is instantiated, a short calibration routine is performed where the IMU samples the gyros while at rest to determine the initial offset. This is subtracted from each sample to determine the heading.

This class is for the ADIS16448 IMU connected via the SPI port available on the RoboRIO MXP port.

Member Enumeration Documentation

◆ CalibrationTime

ADIS16448 calibration times.

Enumerator
_32ms 

32 ms calibration time.

_64ms 

64 ms calibration time.

_128ms 

128 ms calibration time.

_256ms 

256 ms calibration time.

_512ms 

512 ms calibration time.

_1s 

1 s calibration time.

_2s 

2 s calibration time.

_4s 

4 s calibration time.

_8s 

8 s calibration time.

_16s 

16 s calibration time.

_32s 

32 s calibration time.

_64s 

64 s calibration time.

◆ IMUAxis

IMU axes.

Enumerator
kX 

The IMU's X axis.

kY 

The IMU's Y axis.

kZ 

The IMU's Z axis.

Constructor & Destructor Documentation

◆ ADIS16448_IMU() [1/3]

frc::ADIS16448_IMU::ADIS16448_IMU ( )

IMU constructor on onboard MXP CS0, Z-up orientation, and complementary AHRS computation.

◆ ADIS16448_IMU() [2/3]

frc::ADIS16448_IMU::ADIS16448_IMU ( IMUAxis  yaw_axis,
SPI::Port  port,
CalibrationTime  cal_time 
)
explicit

IMU constructor on the specified MXP port and orientation.

Parameters
yaw_axisThe axis where gravity is present. Valid options are kX, kY, and kZ
portThe SPI port where the IMU is connected.
cal_timeThe calibration time that should be used on start-up.

◆ ~ADIS16448_IMU()

frc::ADIS16448_IMU::~ADIS16448_IMU ( )
override

◆ ADIS16448_IMU() [3/3]

frc::ADIS16448_IMU::ADIS16448_IMU ( ADIS16448_IMU &&  )

Member Function Documentation

◆ Calibrate()

void frc::ADIS16448_IMU::Calibrate ( )

Initialize the IMU.

Perform gyro offset calibration by collecting data for a number of seconds and computing the center value. The center value is subtracted from subsequent measurements.

It's important to make sure that the robot is not moving while the centering calculations are in progress, this is typically done when the robot is first turned on while it's sitting at rest before the match starts.

The calibration routine can be triggered by the user during runtime.

◆ ConfigCalTime()

int frc::ADIS16448_IMU::ConfigCalTime ( CalibrationTime  new_cal_time)

Configures the calibration time used for the next calibrate.

Parameters
new_cal_timeThe calibration time that should be used

◆ ConfigDecRate()

int frc::ADIS16448_IMU::ConfigDecRate ( uint16_t  decimationRate)

Configures the decimation rate of the IMU.

Parameters
decimationRateThe new decimation value.
Returns
0 if success, 1 if no change, 2 if error.

◆ GetAccelX()

units::meters_per_second_squared_t frc::ADIS16448_IMU::GetAccelX ( ) const

Returns the acceleration in the X axis.

◆ GetAccelY()

units::meters_per_second_squared_t frc::ADIS16448_IMU::GetAccelY ( ) const

Returns the acceleration in the Y axis.

◆ GetAccelZ()

units::meters_per_second_squared_t frc::ADIS16448_IMU::GetAccelZ ( ) const

Returns the acceleration in the Z axis.

◆ GetAngle()

units::degree_t frc::ADIS16448_IMU::GetAngle ( ) const

Returns the yaw axis angle in degrees (CCW positive).

◆ GetBarometricPressure()

units::pounds_per_square_inch_t frc::ADIS16448_IMU::GetBarometricPressure ( ) const

Returns the barometric pressure.

◆ GetGyroAngleX()

units::degree_t frc::ADIS16448_IMU::GetGyroAngleX ( ) const

Returns the accumulated gyro angle in the X axis.

◆ GetGyroAngleY()

units::degree_t frc::ADIS16448_IMU::GetGyroAngleY ( ) const

Returns the accumulated gyro angle in the Y axis.

◆ GetGyroAngleZ()

units::degree_t frc::ADIS16448_IMU::GetGyroAngleZ ( ) const

Returns the accumulated gyro angle in the Z axis.

◆ GetGyroRateX()

units::degrees_per_second_t frc::ADIS16448_IMU::GetGyroRateX ( ) const

Returns the angular rate in the X axis.

◆ GetGyroRateY()

units::degrees_per_second_t frc::ADIS16448_IMU::GetGyroRateY ( ) const

Returns the angular rate in the Y axis.

◆ GetGyroRateZ()

units::degrees_per_second_t frc::ADIS16448_IMU::GetGyroRateZ ( ) const

Returns the angular rate in the Z axis.

◆ GetMagneticFieldX()

units::tesla_t frc::ADIS16448_IMU::GetMagneticFieldX ( ) const

Returns the magnetic field strength in the X axis.

◆ GetMagneticFieldY()

units::tesla_t frc::ADIS16448_IMU::GetMagneticFieldY ( ) const

Returns the magnetic field strength in the Y axis.

◆ GetMagneticFieldZ()

units::tesla_t frc::ADIS16448_IMU::GetMagneticFieldZ ( ) const

Returns the magnetic field strength in the Z axis.

◆ GetPort()

int frc::ADIS16448_IMU::GetPort ( ) const

Get the SPI port number.

Returns
The SPI port number.

◆ GetRate()

units::degrees_per_second_t frc::ADIS16448_IMU::GetRate ( ) const

Returns the yaw axis angular rate in degrees per second (CCW positive).

◆ GetTemperature()

units::celsius_t frc::ADIS16448_IMU::GetTemperature ( ) const

Returns the temperature.

◆ GetXComplementaryAngle()

units::degree_t frc::ADIS16448_IMU::GetXComplementaryAngle ( ) const

Returns the complementary angle around the X axis computed from accelerometer and gyro rate measurements.

◆ GetXFilteredAccelAngle()

units::degree_t frc::ADIS16448_IMU::GetXFilteredAccelAngle ( ) const

Returns the X-axis filtered acceleration angle.

◆ GetYawAxis()

IMUAxis frc::ADIS16448_IMU::GetYawAxis ( ) const

◆ GetYComplementaryAngle()

units::degree_t frc::ADIS16448_IMU::GetYComplementaryAngle ( ) const

Returns the complementary angle around the Y axis computed from accelerometer and gyro rate measurements.

◆ GetYFilteredAccelAngle()

units::degree_t frc::ADIS16448_IMU::GetYFilteredAccelAngle ( ) const

Returns the Y-axis filtered acceleration angle.

◆ InitSendable()

void frc::ADIS16448_IMU::InitSendable ( wpi::SendableBuilder builder)
overridevirtual

Initializes this Sendable object.

Parameters
buildersendable builder

Implements wpi::Sendable.

◆ IsConnected()

bool frc::ADIS16448_IMU::IsConnected ( ) const

Checks the connection status of the IMU.

Returns
True if the IMU is connected, false otherwise.

◆ operator=()

ADIS16448_IMU & frc::ADIS16448_IMU::operator= ( ADIS16448_IMU &&  )

◆ Reset()

void frc::ADIS16448_IMU::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.

◆ SetYawAxis()

int frc::ADIS16448_IMU::SetYawAxis ( IMUAxis  yaw_axis)

The documentation for this class was generated from the following file: