WPILibC++ 2024.1.1-beta-4
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
}
 
enum  IMUAxis { kX , kY , kZ }
 

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 &&)=default
 
ADIS16448_IMUoperator= (ADIS16448_IMU &&)=default
 
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
 
units::degree_t GetYComplementaryAngle () const
 
units::degree_t GetXFilteredAccelAngle () const
 
units::degree_t GetYFilteredAccelAngle () const
 
units::tesla_t GetMagneticFieldX () const
 
units::tesla_t GetMagneticFieldY () const
 
units::tesla_t GetMagneticFieldZ () const
 
units::pounds_per_square_inch_t GetBarometricPressure () const
 
units::celsius_t GetTemperature () const
 
IMUAxis GetYawAxis () const
 
int SetYawAxis (IMUAxis yaw_axis)
 
bool IsConnected () const
 
int ConfigDecRate (uint16_t DecimationRate)
 
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

Enumerator
_32ms 
_64ms 
_128ms 
_256ms 
_512ms 
_1s 
_2s 
_4s 
_8s 
_16s 
_32s 
_64s 

◆ IMUAxis

Enumerator
kX 
kY 
kZ 

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 &&  )
default

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)

◆ 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

◆ 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

◆ GetMagneticFieldY()

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

◆ GetMagneticFieldZ()

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

◆ 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

◆ GetXComplementaryAngle()

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

◆ GetXFilteredAccelAngle()

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

◆ GetYawAxis()

IMUAxis frc::ADIS16448_IMU::GetYawAxis ( ) const

◆ GetYComplementaryAngle()

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

◆ GetYFilteredAccelAngle()

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

◆ 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

◆ operator=()

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

◆ 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: