WPILibC++ 2024.1.1-beta-4
|
Use DMA SPI to read rate and acceleration data from the ADIS16470 IMU and return the robot's heading relative to a starting position and instant measurements. More...
#include <frc/ADIS16470_IMU.h>
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 | |
ADIS16470_IMU () | |
Default constructor. More... | |
ADIS16470_IMU (IMUAxis yaw_axis, SPI::Port port, CalibrationTime cal_time) | |
Customizable constructor. More... | |
~ADIS16470_IMU () override | |
Destructor. More... | |
ADIS16470_IMU (ADIS16470_IMU &&)=default | |
ADIS16470_IMU & | operator= (ADIS16470_IMU &&)=default |
int | ConfigDecRate (uint16_t reg) |
void | Calibrate () |
Switches the active SPI port to standard SPI mode, writes the command to activate the new null configuration, and re-enables auto SPI. More... | |
int | ConfigCalTime (CalibrationTime new_cal_time) |
Switches the active SPI port to standard SPI mode, writes a new value to the NULL_CNFG register in the IMU, and re-enables auto SPI. More... | |
void | Reset () |
Resets (zeros) the xgyro, ygyro, and zgyro angle integrations. 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::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 |
IMUAxis | GetYawAxis () const |
int | SetYawAxis (IMUAxis yaw_axis) |
bool | IsConnected () const |
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< ADIS16470_IMU > | |
SendableHelper (const SendableHelper &rhs)=default | |
SendableHelper (SendableHelper &&rhs) | |
SendableHelper & | operator= (const SendableHelper &rhs)=default |
SendableHelper & | operator= (SendableHelper &&rhs) |
Public Attributes | |
IMUAxis | m_yaw_axis |
Additional Inherited Members | |
Protected Member Functions inherited from wpi::SendableHelper< ADIS16470_IMU > | |
SendableHelper ()=default | |
~SendableHelper () | |
Use DMA SPI to read rate and acceleration data from the ADIS16470 IMU and return the robot's heading relative to a starting position and instant measurements.
The ADIS16470 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 ADIS16470 IMU connected via the primary SPI port available on the RoboRIO.
|
strong |
frc::ADIS16470_IMU::ADIS16470_IMU | ( | ) |
Default constructor.
Uses CS0 on the 10-pin SPI port, the yaw axis is set to the IMU Z axis, and calibration time is defaulted to 4 seconds.
|
explicit |
Customizable constructor.
Allows the SPI port and CS to be customized, the yaw axis used for GetAngle() is adjustable, and initial calibration time can be modified.
yaw_axis | Selects the "default" axis to use for GetAngle() and GetRate() |
port | The SPI port and CS where the IMU is connected. |
cal_time | The calibration time that should be used on start-up. |
|
override |
Destructor.
Kills the acquisition loop and closes the SPI peripheral.
|
default |
void frc::ADIS16470_IMU::Calibrate | ( | ) |
int frc::ADIS16470_IMU::ConfigCalTime | ( | CalibrationTime | new_cal_time | ) |
int frc::ADIS16470_IMU::ConfigDecRate | ( | uint16_t | reg | ) |
units::meters_per_second_squared_t frc::ADIS16470_IMU::GetAccelX | ( | ) | const |
Returns the acceleration in the X axis.
units::meters_per_second_squared_t frc::ADIS16470_IMU::GetAccelY | ( | ) | const |
Returns the acceleration in the Y axis.
units::meters_per_second_squared_t frc::ADIS16470_IMU::GetAccelZ | ( | ) | const |
Returns the acceleration in the Z axis.
units::degree_t frc::ADIS16470_IMU::GetAngle | ( | ) | const |
Returns the yaw axis angle in degrees (CCW positive).
units::degrees_per_second_t frc::ADIS16470_IMU::GetRate | ( | ) | const |
Returns the yaw axis angular rate in degrees per second (CCW positive).
units::degree_t frc::ADIS16470_IMU::GetXComplementaryAngle | ( | ) | const |
units::degree_t frc::ADIS16470_IMU::GetXFilteredAccelAngle | ( | ) | const |
IMUAxis frc::ADIS16470_IMU::GetYawAxis | ( | ) | const |
units::degree_t frc::ADIS16470_IMU::GetYComplementaryAngle | ( | ) | const |
units::degree_t frc::ADIS16470_IMU::GetYFilteredAccelAngle | ( | ) | const |
|
overridevirtual |
bool frc::ADIS16470_IMU::IsConnected | ( | ) | const |
|
default |
void frc::ADIS16470_IMU::Reset | ( | ) |
Resets (zeros) the xgyro, ygyro, and zgyro angle integrations.
Resets the gyro accumulations to a heading of zero. This can be used if the "zero" orientation of the sensor needs to be changed in runtime.
int frc::ADIS16470_IMU::SetYawAxis | ( | IMUAxis | yaw_axis | ) |
IMUAxis frc::ADIS16470_IMU::m_yaw_axis |