MetaWear C++ API  0.20.0
C++ implementation of the MetaWear protocol
sensor_fusion.h
Go to the documentation of this file.
1 
8 #pragma once
9 
10 #include "sensor_common.h"
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 const uint8_t MBL_MW_SENSOR_FUSION_CALIBRATION_ACCURACY_UNRELIABLE = 0,
17  MBL_MW_SENSOR_FUSION_CALIBRATION_ACCURACY_LOW = 1,
18  MBL_MW_SENSOR_FUSION_CALIBRATION_ACCURACY_MEDIUM = 2,
19  MBL_MW_SENSOR_FUSION_CALIBRATION_ACCURACY_HIGH = 3;
20 
24 typedef enum {
25  MBL_MW_SENSOR_FUSION_MODE_SLEEP = 0,
26  MBL_MW_SENSOR_FUSION_MODE_NDOF,
27  MBL_MW_SENSOR_FUSION_MODE_IMU_PLUS,
28  MBL_MW_SENSOR_FUSION_MODE_COMPASS,
29  MBL_MW_SENSOR_FUSION_MODE_M4G
31 
35 typedef enum {
36  MBL_MW_SENSOR_FUSION_ACC_RANGE_2G = 0,
37  MBL_MW_SENSOR_FUSION_ACC_RANGE_4G,
38  MBL_MW_SENSOR_FUSION_ACC_RANGE_8G,
39  MBL_MW_SENSOR_FUSION_ACC_RANGE_16G
41 
45 typedef enum {
46  MBL_MW_SENSOR_FUSION_GYRO_RANGE_2000DPS = 0,
47  MBL_MW_SENSOR_FUSION_GYRO_RANGE_1000DPS,
48  MBL_MW_SENSOR_FUSION_GYRO_RANGE_500DPS,
49  MBL_MW_SENSOR_FUSION_GYRO_RANGE_250DPS
51 
55 typedef enum {
56  MBL_MW_SENSOR_FUSION_DATA_CORRECTED_ACC = 0,
57  MBL_MW_SENSOR_FUSION_DATA_CORRECTED_GYRO,
58  MBL_MW_SENSOR_FUSION_DATA_CORRECTED_MAG,
59  MBL_MW_SENSOR_FUSION_DATA_QUATERNION,
60  MBL_MW_SENSOR_FUSION_DATA_EULER_ANGLE,
61  MBL_MW_SENSOR_FUSION_DATA_GRAVITY_VECTOR,
62  MBL_MW_SENSOR_FUSION_DATA_LINEAR_ACC
64 
68 typedef struct {
69  uint8_t acc[10];
70  uint8_t gyro[10];
71  uint8_t mag[10];
73 
80 typedef void(*MblMwFnBoardPtrCalibDataPtr)(void *context, MblMwMetaWearBoard* board, const MblMwCalibrationData* data);
81 
179 
180 #ifdef __cplusplus
181 }
182 #endif
struct MblMwDataSignal MblMwDataSignal
A event fired from the MetaWear board that also contains data.
Definition: datasignal_fwd.h:15
#define METAWEAR_API
Indicates the function should be exported to the symbol table
Definition: dllmarker.h:27
struct MblMwMetaWearBoard MblMwMetaWearBoard
Software representation of a physical MetaWear board.
Definition: metawearboard_fwd.h:17
void(* MblMwFnBoardPtrInt)(void *context, MblMwMetaWearBoard *board, int32_t value)
Definition for callback functions that accept an MblMwMetaWearBoard pointer and an int32.
Definition: metawearboard_fwd.h:26
METAWEAR_API void mbl_mw_sensor_fusion_write_config(MblMwMetaWearBoard *board)
Write the module configuration to the board Applies the MODE and RANGE values set in set_*().
METAWEAR_API void mbl_mw_sensor_fusion_set_mode(MblMwMetaWearBoard *board, MblMwSensorFusionMode mode)
Set the operation mode See MblMwSensorFusionMode for allowed values.
METAWEAR_API void mbl_mw_sensor_fusion_write_calibration_data(const MblMwMetaWearBoard *board, const MblMwCalibrationData *data)
Write IMU calibration data.
METAWEAR_API void mbl_mw_sensor_fusion_stop(const MblMwMetaWearBoard *board)
Stop sensor fusion The board will stop gathering data from the gyroscope, accelerometer,...
MblMwSensorFusionGyroRange
Supported rotation ranges.
Definition: sensor_fusion.h:45
METAWEAR_API void mbl_mw_sensor_fusion_clear_enabled_mask(MblMwMetaWearBoard *board)
Clear all data enable bits Turns off the Kalman filter (sensor fusion)
METAWEAR_API void mbl_mw_sensor_fusion_reset_orientation(MblMwMetaWearBoard *board)
Reset the default orientation of the board.
METAWEAR_API void mbl_mw_sensor_fusion_enable_data(MblMwMetaWearBoard *board, MblMwSensorFusionData data)
Set a data enable bit Turns on the Kalman filter (sensor fusion)
METAWEAR_API void mbl_mw_sensor_fusion_set_gyro_range(MblMwMetaWearBoard *board, MblMwSensorFusionGyroRange range)
Set the gyroscope data range Sets the range of the gyro in DPS, see MblMwSensorFusionGyroRange for al...
MblMwSensorFusionData
Data computed by the algorithm.
Definition: sensor_fusion.h:55
MblMwSensorFusionAccRange
Supported acceleration ranges.
Definition: sensor_fusion.h:35
METAWEAR_API void mbl_mw_sensor_fusion_start(const MblMwMetaWearBoard *board)
Start sensor fusion The board will start gathering data from the gyroscope, accelerometer,...
METAWEAR_API void mbl_mw_sensor_fusion_read_calibration_data(MblMwMetaWearBoard *board, void *context, MblMwFnBoardPtrCalibDataPtr completed)
Retrieve IMU calibration data; free the memory allocated for the MblMwCalibrationData pointer with mb...
METAWEAR_API MblMwDataSignal * mbl_mw_sensor_fusion_get_data_signal(const MblMwMetaWearBoard *board, MblMwSensorFusionData data)
Get the data signal object representing data from the sensor fusion algorithm The sensor fusion algo ...
MblMwSensorFusionMode
Fusion modes supported by the algorithm.
Definition: sensor_fusion.h:24
METAWEAR_API MblMwDataSignal * mbl_mw_sensor_fusion_calibration_state_data_signal(const MblMwMetaWearBoard *board)
Get the data signal object representing thecalibration state.
METAWEAR_API void mbl_mw_sensor_fusion_read_config(const MblMwMetaWearBoard *board, void *context, MblMwFnBoardPtrInt completed)
Pulls the current sensor fusion configuration from the board.
METAWEAR_API void mbl_mw_sensor_fusion_set_acc_range(MblMwMetaWearBoard *board, MblMwSensorFusionAccRange range)
Set the accelerometer data range Sets the range of the acc in Gs, see MblMwSensorFusionAccRange for a...
void(* MblMwFnBoardPtrCalibDataPtr)(void *context, MblMwMetaWearBoard *board, const MblMwCalibrationData *data)
Definition for callback functions that accept an MblMwMetaWearBoard and MblMwCalibrationData pointer.
Definition: sensor_fusion.h:80
Container class holding the IMU calibration data.
Definition: sensor_fusion.h:68