Mod Library
Sun Devil Rocketry's hardware agnostic utility library
Loading...
Searching...
No Matches
mahony.h
Go to the documentation of this file.
1
29
30/* Define to prevent recursive inclusion -------------------------------------*/
31#ifndef MAHONY_H
32#define MAHONY_H
33
34#ifdef __cplusplus
35extern "C"
36{
37#endif
38
39/* Standard Includes ---------------------------------------------------------*/
40#include <stdbool.h>
41
42/* Project Includes ----------------------------------------------------------*/
43#include "math_sdr.h"
44
45/* Typedefs ------------------------------------------------------------------*/
46
50typedef enum
51 {
52 MAHONY_OK = 0,
53 MAHONY_NULL_POINTER,
54 MAHONY_INVALID_QUATERNION,
55 MAHONY_NONFINITE_GAIN,
56 MAHONY_NEGATIVE_GAIN,
57 MAHONY_INVALID_GYRO,
58 MAHONY_INVALID_DELTA_TIME
60
64typedef struct _MAHONY_FILTER
65 {
68
71
72 float proportional_gain;
73 float integral_gain;
74
76
77/* Function Prototypes -------------------------------------------------------*/
78
80 (
81 MAHONY_FILTER *filter,
82 QUAT initial_attitude,
83 float proportional_gain,
84 float integral_gain
85 );
86
87
89 (
90 MAHONY_FILTER *filter,
91 VECTOR_3F gyro_body_rad_s,
92 float delta_time_s
93 );
94
96 (
97 MAHONY_FILTER *filter,
98 VECTOR_3F gyro_body_rad_s,
99 VECTOR_3F accel_body,
100 float delta_time_s,
101 bool use_accel
102 );
103
104#ifdef __cplusplus
105}
106#endif
107
108#endif /* MAHONY_H */
109
110/*******************************************************************************
111 * END OF FILE
112 ******************************************************************************/
MAHONY_STATUS mahony_update_gyro(MAHONY_FILTER *filter, VECTOR_3F gyro_body_rad_s, float delta_time_s)
Propagates attitude using body-frame gyroscope measurements.
Definition mahony.c:127
MAHONY_STATUS mahony_update_imu(MAHONY_FILTER *filter, VECTOR_3F gyro_body_rad_s, VECTOR_3F accel_body, float delta_time_s, bool use_accel)
Updates attitude using gyroscope propagation and accelerometer proportional feedback.
Definition mahony.c:202
MAHONY_STATUS mahony_init(MAHONY_FILTER *filter, QUAT initial_attitude, float proportional_gain, float integral_gain)
Initializes a Mahony attitude filter.
Definition mahony.c:72
MAHONY_STATUS
Mahony attitude filter status codes.
Definition mahony.h:51
struct _MAHONY_FILTER MAHONY_FILTER
State and gains for a Mahony attitude filter.
: Contains math and utility functions for SDR code.
struct _VECTOR_3F VECTOR_3F
Three-dimensional floating-point vector.
State and gains for a Mahony attitude filter.
Definition mahony.h:65
VECTOR_3F integral_error
Definition mahony.h:70
QUAT attitude
Definition mahony.h:67