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
16extern "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 second^2
23 * floats.
24 *
25 * One of these is used per gyro, accelerometer and magnometer.
26 *
27 * The formula used is: `v = ((V * ticks_to_float) - bias) * gain`. For
28 * @ref ticks_to_float the same value used for all channels, where as for
29 * @ref gain and @ref bias the value is per channel.
30 */
32{
33 //! Bias for the imu part.
34 struct xrt_vec3 bias;
35 float _pad;
36 //! Gain for the imu part.
37 struct xrt_vec3 gain;
38 //! Going from IMU 'ticks' to a floating value.
40};
41
42/*!
43 * This is a common IMU pre-filter which takes raw 'ticks' from an IMU
44 * measurement and converts it into floats representing radians per second and
45 * meters per second^2 floats.
46 */
48{
49 struct m_imu_pre_filter_part accel;
50 struct m_imu_pre_filter_part gyro;
51
52 /*!
53 * A transform on how to flip axis and rotate the IMU values into device
54 * space.
55 */
57};
58
59/*!
60 * A simple init function that takes the two ticks_to_float values, all
61 * other values are set to identity.
62 */
63void
64m_imu_pre_filter_init(struct m_imu_pre_filter *imu, float ticks_to_float_accel, float ticks_to_float_gyro);
65
66/*!
67 * Sets the transformation to flip X and Y axis. This changes the handedness
68 * of the coordinates.
69 */
70void
72
73/*!
74 * Pre-filters the values, taking them from ticks into float values.
75 *
76 * See description of @ref m_imu_pre_filter_part for formula used. Also rotates
77 * values with the imu_to_head pose.
78 */
79void
81 const struct xrt_vec3_i32 *accel,
82 const struct xrt_vec3_i32 *gyro,
83 struct xrt_vec3 *out_accel,
84 struct xrt_vec3 *out_gyro);
85
86
87#ifdef __cplusplus
88}
89#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:32
struct xrt_vec3 gain
Gain for the imu part.
Definition: m_imu_pre.h:37
float ticks_to_float
Going from IMU 'ticks' to a floating value.
Definition: m_imu_pre.h:39
struct xrt_vec3 bias
Bias for the imu part.
Definition: m_imu_pre.h:34
This is a common IMU pre-filter which takes raw 'ticks' from an IMU measurement and converts it into ...
Definition: m_imu_pre.h:48
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:56
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.