Zephyr Scientific Library (zscilib)
mahony.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 Marti Riba Pons
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
23 #ifndef ZEPHYR_INCLUDE_ZSL_FUSION_MAHONY_H_
24 #define ZEPHYR_INCLUDE_ZSL_FUSION_MAHONY_H_
25 
26 #include <zsl/zsl.h>
27 #include <zsl/vectors.h>
28 #include <zsl/matrices.h>
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /* Source: https://ahrs.readthedocs.io/en/latest/filters/mahony.html */
36 
45 
50 
55 
60  struct zsl_vec intfb;
61 };
62 
72 int zsl_fus_mahn_init(uint32_t freq, void *cfg);
73 
87 int zsl_fus_mahn_feed(struct zsl_vec *a, struct zsl_vec *m,
88  struct zsl_vec *g, zsl_real_t *incl, struct zsl_quat *q,
89  void *cfg);
90 
98 void zsl_fus_mahn_error(int error);
99 
100 #ifdef __cplusplus
101 }
102 #endif
103 
104 #endif /* ZEPHYR_INCLUDE_ZSL_FUSION_MAHONY_H_ */
105  /* End of algorithms group */
zsl_fus_mahn_cfg::intfb
struct zsl_vec intfb
Integral feedback vector, which is updated every iteration. Its initial value must be (0,...
Definition: mahony.h:60
zsl_fus_mahn_cfg::kp
zsl_real_t kp
Proportional filter gain constant. Must be greater than 0.
Definition: mahony.h:44
zsl_quat
Represents a quaternion, a 4D structure capable of representing 3D rigid body orientations.
Definition: quaternions.h:89
zsl_fus_mahn_cfg::integral_limit
zsl_real_t integral_limit
Integral limit for the integrator to avoid windup. Must be greater than 0.
Definition: mahony.h:54
zsl_fus_mahn_init
int zsl_fus_mahn_init(uint32_t freq, void *cfg)
Sets the sample frequency (in Hz) for the algorithm.
zsl_fus_mahn_error
void zsl_fus_mahn_error(int error)
Default error handler for the Mahony sensor fusion driver.
quaternions.h
API header file for quaternions in zscilib.
vectors.h
API header file for vectors in zscilib.
zsl_fus_mahn_cfg
Config settings for the Mahony sensor fusion algorithm.
Definition: mahony.h:40
matrices.h
API header file for matrices in zscilib.
zsl.h
API header file for zscilib.
zsl_vec
Represents a vector.
Definition: vectors.h:40
zsl_real_t
double zsl_real_t
Definition: zsl.h:51
zsl_fus_mahn_cfg::ki
zsl_real_t ki
Integral filter gain constant. Must be greater than 0.
Definition: mahony.h:49
zsl_fus_mahn_feed
int zsl_fus_mahn_feed(struct zsl_vec *a, struct zsl_vec *m, struct zsl_vec *g, zsl_real_t *incl, struct zsl_quat *q, void *cfg)
Mahony sensor fusion algorithm implementation.