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;
50 
51  /*!
52  * A transform on how to flip axis and rotate the IMU values into device
53  * space.
54  */
55  struct xrt_matrix_3x3 transform;
56 };
57 
58 /*!
59  * A simple init function that just takes the two ticks_to_float values, all
60  * other values are set to identity.
61  */
62 void
64  float ticks_to_float_accel,
65  float ticks_to_float_gyro);
66 
67 /*!
68  * Sets the transformation to flip X and Y axis. This changes the handedness
69  * of the coordinates.
70  */
71 void
73 
74 /*!
75  * Pre-filters the values, taking them from ticks into float values.
76  *
77  * See description of @ref m_imu_pre_filter_part for formula used. Also rotates
78  * values with the imu_to_head pose.
79  */
80 void
82  const struct xrt_vec3_i32 *accel,
83  const struct xrt_vec3_i32 *gyro,
84  struct xrt_vec3 *out_accel,
85  struct xrt_vec3 *out_gyro);
86 
87 
88 #ifdef __cplusplus
89 }
90 #endif
A 3 element vector with single floats.
Definition: xrt_defines.h:133
This is a common IMU pre-filter which takes raw &#39;ticks&#39; from an IMU measurement and converts it into ...
Definition: m_imu_pre.h:46
struct xrt_vec3 bias
Bias for the imu part.
Definition: m_imu_pre.h:33
A tightly packed 3x3 matrix of floats.
Definition: xrt_defines.h:268
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:63
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 just takes the two ticks_to_float values, all other values are set to ide...
Definition: m_imu_pre.c:15
A 3 element vector with 32 bit integers.
Definition: xrt_defines.h:145
Common defines and enums for XRT.
float ticks_to_float
Going from IMU &#39;ticks&#39; to a floating value.
Definition: m_imu_pre.h:38
uint16_t gyro[3]
Definition: vive_protocol.h:210
struct xrt_vec3 gain
Gain for the imu part.
Definition: m_imu_pre.h:36
This is a common IMU pre-filter which takes raw &#39;ticks&#39; from a 3 axis IMU measurement and converts it...
Definition: m_imu_pre.h:30
float _pad
Definition: m_imu_pre.h:34
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:49