WPILibC++ 2024.3.2
|
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>
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_IMU & | operator= (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) | |
SendableHelper & | operator= (const SendableHelper &rhs)=default |
SendableHelper & | operator= (SendableHelper &&rhs) |
Additional Inherited Members | |
Protected Member Functions inherited from wpi::SendableHelper< ADIS16448_IMU > | |
SendableHelper ()=default | |
~SendableHelper () | |
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.
|
strong |
ADIS16448 calibration times.
frc::ADIS16448_IMU::ADIS16448_IMU | ( | ) |
IMU constructor on onboard MXP CS0, Z-up orientation, and complementary AHRS computation.
|
explicit |
IMU constructor on the specified MXP port and orientation.
yaw_axis | The axis where gravity is present. Valid options are kX, kY, and kZ |
port | The SPI port where the IMU is connected. |
cal_time | The calibration time that should be used on start-up. |
|
override |
frc::ADIS16448_IMU::ADIS16448_IMU | ( | ADIS16448_IMU && | ) |
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.
int frc::ADIS16448_IMU::ConfigCalTime | ( | CalibrationTime | new_cal_time | ) |
Configures the calibration time used for the next calibrate.
new_cal_time | The calibration time that should be used |
int frc::ADIS16448_IMU::ConfigDecRate | ( | uint16_t | decimationRate | ) |
Configures the decimation rate of the IMU.
decimationRate | The new decimation value. |
units::meters_per_second_squared_t frc::ADIS16448_IMU::GetAccelX | ( | ) | const |
Returns the acceleration in the X axis.
units::meters_per_second_squared_t frc::ADIS16448_IMU::GetAccelY | ( | ) | const |
Returns the acceleration in the Y axis.
units::meters_per_second_squared_t frc::ADIS16448_IMU::GetAccelZ | ( | ) | const |
Returns the acceleration in the Z axis.
units::degree_t frc::ADIS16448_IMU::GetAngle | ( | ) | const |
Returns the yaw axis angle in degrees (CCW positive).
units::pounds_per_square_inch_t frc::ADIS16448_IMU::GetBarometricPressure | ( | ) | const |
Returns the barometric pressure.
units::degree_t frc::ADIS16448_IMU::GetGyroAngleX | ( | ) | const |
Returns the accumulated gyro angle in the X axis.
units::degree_t frc::ADIS16448_IMU::GetGyroAngleY | ( | ) | const |
Returns the accumulated gyro angle in the Y axis.
units::degree_t frc::ADIS16448_IMU::GetGyroAngleZ | ( | ) | const |
Returns the accumulated gyro angle in the Z axis.
units::degrees_per_second_t frc::ADIS16448_IMU::GetGyroRateX | ( | ) | const |
Returns the angular rate in the X axis.
units::degrees_per_second_t frc::ADIS16448_IMU::GetGyroRateY | ( | ) | const |
Returns the angular rate in the Y axis.
units::degrees_per_second_t frc::ADIS16448_IMU::GetGyroRateZ | ( | ) | const |
Returns the angular rate in the Z axis.
units::tesla_t frc::ADIS16448_IMU::GetMagneticFieldX | ( | ) | const |
Returns the magnetic field strength in the X axis.
units::tesla_t frc::ADIS16448_IMU::GetMagneticFieldY | ( | ) | const |
Returns the magnetic field strength in the Y axis.
units::tesla_t frc::ADIS16448_IMU::GetMagneticFieldZ | ( | ) | const |
Returns the magnetic field strength in the Z axis.
units::degrees_per_second_t frc::ADIS16448_IMU::GetRate | ( | ) | const |
Returns the yaw axis angular rate in degrees per second (CCW positive).
units::celsius_t frc::ADIS16448_IMU::GetTemperature | ( | ) | const |
Returns the temperature.
units::degree_t frc::ADIS16448_IMU::GetXComplementaryAngle | ( | ) | const |
Returns the complementary angle around the X axis computed from accelerometer and gyro rate measurements.
units::degree_t frc::ADIS16448_IMU::GetXFilteredAccelAngle | ( | ) | const |
Returns the X-axis filtered acceleration angle.
IMUAxis frc::ADIS16448_IMU::GetYawAxis | ( | ) | const |
units::degree_t frc::ADIS16448_IMU::GetYComplementaryAngle | ( | ) | const |
Returns the complementary angle around the Y axis computed from accelerometer and gyro rate measurements.
units::degree_t frc::ADIS16448_IMU::GetYFilteredAccelAngle | ( | ) | const |
Returns the Y-axis filtered acceleration angle.
|
overridevirtual |
bool frc::ADIS16448_IMU::IsConnected | ( | ) | const |
Checks the connection status of the IMU.
ADIS16448_IMU & frc::ADIS16448_IMU::operator= | ( | ADIS16448_IMU && | ) |
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.
int frc::ADIS16448_IMU::SetYawAxis | ( | IMUAxis | yaw_axis | ) |