Monado OpenXR Runtime
xrt::auxiliary::tracking::SimpleIMUFusion Class Reference

A simple IMU fusion class. More...

#include <tracking/t_imu_fusion.hpp>

Public Member Functions

EIGEN_MAKE_ALIGNED_OPERATOR_NEW SimpleIMUFusion (double gravity_rate=0.9)
 
bool valid () const noexcept
 
Eigen::Quaterniond getQuat () const
 Get the current state orientation. More...
 
Eigen::Vector3d getRotationVec () const
 Get the current state orientation as a rotation vector. More...
 
Eigen::Matrix3d getRotationMatrix () const
 Get the current state orientation as a rotation matrix. More...
 
Eigen::Quaterniond getPredictedQuat (timepoint_ns timestamp) const
 Get the predicted orientation at some point in the future. More...
 
Eigen::Vector3d const & getAngVel () const
 Get the angular velocity in body space. More...
 
bool handleGyro (Eigen::Vector3d const &gyro, timepoint_ns timestamp)
 Process a gyroscope report. More...
 
bool handleAccel (Eigen::Vector3d const &accel, timepoint_ns timestamp)
 Process an accelerometer report. More...
 
Eigen::Vector3d getCorrectedWorldAccel (Eigen::Vector3d const &accel) const
 Use this to obtain the residual, world-space acceleration in m/s/s not associated with gravity, after incorporating a measurement. More...
 
void postCorrect ()
 Normalize internal state. More...
 

Detailed Description

A simple IMU fusion class.

Constructor & Destructor Documentation

◆ SimpleIMUFusion()

EIGEN_MAKE_ALIGNED_OPERATOR_NEW xrt::auxiliary::tracking::SimpleIMUFusion::SimpleIMUFusion ( double  gravity_rate = 0.9)
inlineexplicit
Parameters
gravity_rateValue in [0, 1] indicating how much the accelerometer should affect the orientation each second.

Member Function Documentation

◆ getAngVel()

Eigen::Vector3d const& xrt::auxiliary::tracking::SimpleIMUFusion::getAngVel ( ) const
inline

Get the angular velocity in body space.

◆ getCorrectedWorldAccel()

Eigen::Vector3d xrt::auxiliary::tracking::SimpleIMUFusion::getCorrectedWorldAccel ( Eigen::Vector3d const &  accel) const
inline

Use this to obtain the residual, world-space acceleration in m/s/s not associated with gravity, after incorporating a measurement.

Parameters
accelBody-relative acceleration measurement in m/s/s.

References MATH_GRAVITY_M_S2.

◆ getPredictedQuat()

Eigen::Quaterniond xrt::auxiliary::tracking::SimpleIMUFusion::getPredictedQuat ( timepoint_ns  timestamp) const
inline

Get the predicted orientation at some point in the future.

Here, we do not clamp the delta-t, so only ask for reasonable points in the future. (The gyro handler math does clamp delta-t for the purposes of integration in case of long times without signals, etc, which is OK since the accelerometer serves as a correction.)

◆ getQuat()

Eigen::Quaterniond xrt::auxiliary::tracking::SimpleIMUFusion::getQuat ( ) const
inline

Get the current state orientation.

◆ getRotationMatrix()

Eigen::Matrix3d xrt::auxiliary::tracking::SimpleIMUFusion::getRotationMatrix ( ) const
inline

Get the current state orientation as a rotation matrix.

◆ getRotationVec()

Eigen::Vector3d xrt::auxiliary::tracking::SimpleIMUFusion::getRotationVec ( ) const
inline

Get the current state orientation as a rotation vector.

◆ handleAccel()

bool xrt::auxiliary::tracking::SimpleIMUFusion::handleAccel ( Eigen::Vector3d const &  accel,
timepoint_ns  timestamp 
)
inline

Process an accelerometer report.

Parameters
accelBody-relative acceleration measurement in m/s/s.
timestampNanosecond timestamp of this measurement.
Returns
true if the report was used to update the state.

◆ handleGyro()

bool xrt::auxiliary::tracking::SimpleIMUFusion::handleGyro ( Eigen::Vector3d const &  gyro,
timepoint_ns  timestamp 
)
inline

Process a gyroscope report.

Note
At startup, no gyro reports will be considered until at least one accelerometer report has been processed, to provide us with an initial estimate of the direction of gravity.
Parameters
gyroAngular rate in radians per second, in body space.
timestampNanosecond timestamp of this measurement.
Returns
true if the report was used to update the state.

◆ postCorrect()

void xrt::auxiliary::tracking::SimpleIMUFusion::postCorrect ( )
inline

Normalize internal state.

Call periodically, like after you finish handling both the accel and gyro from one packet.

◆ valid()

bool xrt::auxiliary::tracking::SimpleIMUFusion::valid ( ) const
inlinenoexcept
Returns
true if the filter has started up

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