Zephyr Scientific Library (zscilib)
ahrs.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 Kevin Townsend
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
28 #ifndef ZEPHYR_INCLUDE_ZSL_AHRS_H_
29 #define ZEPHYR_INCLUDE_ZSL_AHRS_H_
30 
31 #include <zsl/zsl.h>
32 #include <zsl/vectors.h>
33 #include <zsl/orientation/euler.h>
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
48 struct zsl_attitude {
49  union {
50  struct {
61  };
64  };
65  union {
66  struct {
68  uint8_t roll_invalid : 1;
70  uint8_t pitch_invalid : 1;
72  uint8_t yaw_invalid : 1;
73  } status;
75  uint8_t status_bits;
76  };
77 };
78 
89 int zsl_att_to_vec(struct zsl_attitude *a, struct zsl_vec *v);
90 
100 int zsl_att_to_euler(struct zsl_attitude *a, struct zsl_euler *e);
101 
111 int zsl_att_from_euler(struct zsl_euler *e, struct zsl_attitude *a);
112 
123 int zsl_att_from_accelmag(struct zsl_vec *accel, struct zsl_vec *mag,
124  struct zsl_attitude *a);
125 
135 int zsl_att_from_accel(struct zsl_vec *accel, struct zsl_attitude *a);
136 
147 int zsl_att_accel_angle(struct zsl_vec *a1, struct zsl_vec *a2, zsl_real_t *b);
148 
149 #ifdef __cplusplus
150 }
151 #endif
152 
153 #endif /* ZEPHYR_INCLUDE_ZSL_AHRS_H_ */
154  /* End of ahrs group */
zsl_attitude::roll
zsl_real_t roll
Longitudinal axis in degrees. A positive rolling motion lifts the left wing and lowers the right wing...
Definition: ahrs.h:54
zsl_attitude::pitch
zsl_real_t pitch
Transverse axis in degrees. A positive pitching motion raises the nose of the aircraft and lowers the...
Definition: ahrs.h:57
zsl_attitude::idx
zsl_real_t idx[3]
Array-based access.
Definition: ahrs.h:63
zsl_attitude::status_bits
uint8_t status_bits
Invalid field indicators.
Definition: ahrs.h:75
zsl_attitude::yaw
zsl_real_t yaw
Vertical axis in degrees. A positive yawing motion moves the nose of the aircraft to the right....
Definition: ahrs.h:60
zsl_att_from_accelmag
int zsl_att_from_accelmag(struct zsl_vec *accel, struct zsl_vec *mag, struct zsl_attitude *a)
Converts a three-axis accelerometer (in m/s^2) and a three-axis magnetometer sample (in micro-Tesla) ...
zsl_attitude
Represents the orientation of a rigid body with respect to the world frame in terms of roll,...
Definition: ahrs.h:48
zsl_att_to_vec
int zsl_att_to_vec(struct zsl_attitude *a, struct zsl_vec *v)
Takes the values in the supplied zsl_attitude, and assigns the same memory address to a zsl_vec,...
zsl_attitude::roll_invalid
uint8_t roll_invalid
If non-zero, indicates that roll is invalid.
Definition: ahrs.h:68
zsl_euler
An ordered triplet of real numbers describing the orientation of a rigid body in three-dimensional (E...
Definition: euler.h:43
zsl_attitude::status
struct zsl_attitude::@19::@23 status
zsl_att_from_euler
int zsl_att_from_euler(struct zsl_euler *e, struct zsl_attitude *a)
Converts the input zsl_euler, expessed in radians, to it's equivalent in degrees in the output zsl_at...
vectors.h
API header file for vectors in zscilib.
zsl_attitude::yaw_invalid
uint8_t yaw_invalid
If non-zero, indicates that yaw is invalid.
Definition: ahrs.h:72
zsl.h
API header file for zscilib.
zsl_att_from_accel
int zsl_att_from_accel(struct zsl_vec *accel, struct zsl_attitude *a)
Converts a three-axis accelerometer sample (in m/s^2) to roll and pitch.
zsl_att_accel_angle
int zsl_att_accel_angle(struct zsl_vec *a1, struct zsl_vec *a2, zsl_real_t *b)
Calculates the angle between two accelerometers.
zsl_vec
Represents a vector.
Definition: vectors.h:40
zsl_real_t
double zsl_real_t
Definition: zsl.h:51
zsl_att_to_euler
int zsl_att_to_euler(struct zsl_attitude *a, struct zsl_euler *e)
Converts the input zsl_attitude, expessed in degrees, to it's equivalent in radians in the output zsl...
zsl_attitude::pitch_invalid
uint8_t pitch_invalid
If non-zero, indicates that pitch is invalid.
Definition: ahrs.h:70
euler.h
API header file for euler angles in zscilib.