Monado OpenXR Runtime
m_imu_pre.h
Go to the documentation of this file.
1 // Copyright 2020, Collabora, Ltd.
2 // SPDX-License-Identifier: BSL-1.0
3 /*!
4  * @file
5  * @brief IMU pre filter struct.
6  * @author Jakob Bornecrantz <jakob@collabora.com>
7  * @ingroup aux_math
8  */
9 
10 #pragma once
11 
12 #include "xrt/xrt_defines.h"
13 
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 
20 /*!
21  * This is a common IMU pre-filter which takes raw 'ticks' from a 3 axis IMU
22  * measurement and converts it into degrees per secs and meters per floats.
23  *
24  * One of these is used per gyro, accelerometer and magnometer.
25  *
26  * The formula used is: `v = ((V * ticks_to_float) - bias) * gain`. For
27  * @ref ticks_to_float the same value used for all channels, where as for
28  * @ref gain and @ref bias the value is per channel.
29  */
31 {
32  //! Bias for the imu part.
33  struct xrt_vec3 bias;
34  float _pad;
35  //! Gain for the imu part.
36  struct xrt_vec3 gain;
37  //! Going from IMU 'ticks' to a floating value.
39 };
40 
41 /*!
42  * This is a common IMU pre-filter which takes raw 'ticks' from an IMU
43  * measurement and converts it into floats representing radians per second and
44  * meters per second^2 floats.
45  */
47 {
48  struct m_imu_pre_filter_part accel;
49  struct m_imu_pre_filter_part gyro;
50 
51  /*!
52  * A transform on how to flip axis and rotate the IMU values into device
53  * space.
54  */
56 };
57 
58 /*!
59  * A simple init function that takes the two ticks_to_float values, all
60  * other values are set to identity.
61  */
62 void
63 m_imu_pre_filter_init(struct m_imu_pre_filter *imu, float ticks_to_float_accel, float ticks_to_float_gyro);
64 
65 /*!
66  * Sets the transformation to flip X and Y axis. This changes the handedness
67  * of the coordinates.
68  */
69 void
71 
72 /*!
73  * Pre-filters the values, taking them from ticks into float values.
74  *
75  * See description of @ref m_imu_pre_filter_part for formula used. Also rotates
76  * values with the imu_to_head pose.
77  */
78 void
80  const struct xrt_vec3_i32 *accel,
81  const struct xrt_vec3_i32 *gyro,
82  struct xrt_vec3 *out_accel,
83  struct xrt_vec3 *out_gyro);
84 
85 
86 #ifdef __cplusplus
87 }
88 #endif
void m_imu_pre_filter_data(struct m_imu_pre_filter *imu, const struct xrt_vec3_i32 *accel, const struct xrt_vec3_i32 *gyro, struct xrt_vec3 *out_accel, struct xrt_vec3 *out_gyro)
Pre-filters the values, taking them from ticks into float values.
Definition: m_imu_pre.c:61
void m_imu_pre_filter_set_switch_x_and_y(struct m_imu_pre_filter *imu)
Sets the transformation to flip X and Y axis.
Definition: m_imu_pre.c:47
void m_imu_pre_filter_init(struct m_imu_pre_filter *imu, float ticks_to_float_accel, float ticks_to_float_gyro)
A simple init function that takes the two ticks_to_float values, all other values are set to identity...
Definition: m_imu_pre.c:15
This is a common IMU pre-filter which takes raw 'ticks' from a 3 axis IMU measurement and converts it...
Definition: m_imu_pre.h:31
struct xrt_vec3 gain
Gain for the imu part.
Definition: m_imu_pre.h:36
float ticks_to_float
Going from IMU 'ticks' to a floating value.
Definition: m_imu_pre.h:38
struct xrt_vec3 bias
Bias for the imu part.
Definition: m_imu_pre.h:33
This is a common IMU pre-filter which takes raw 'ticks' from an IMU measurement and converts it into ...
Definition: m_imu_pre.h:47
struct xrt_matrix_3x3 transform
A transform on how to flip axis and rotate the IMU values into device space.
Definition: m_imu_pre.h:55
A tightly packed 3x3 matrix of floats.
Definition: xrt_defines.h:533
A 3 element vector with 32 bit integers.
Definition: xrt_defines.h:336
A 3 element vector with single floats.
Definition: xrt_defines.h:271
Common defines and enums for XRT.