Zephyr Scientific Library (zscilib)
Files | Data Structures | Functions
Attitude and Heading Reference System

Functions and structs for dealing with 'Attitude' and AHRS. More...

Files

file  ahrs.h
 API header file for attitude and AHRS in zscilib.
 

Data Structures

struct  zsl_attitude
 Represents the orientation of a rigid body with respect to the world frame in terms of roll, pitch and yaw (heading), expressed in degrees. More...
 

Functions

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, allowing for vector functions to be used on the zsl_attitude values. More...
 
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_euler. More...
 
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_attitude. More...
 
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) to attitude. More...
 
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. More...
 
int zsl_att_accel_angle (struct zsl_vec *a1, struct zsl_vec *a2, zsl_real_t *b)
 Calculates the angle between two accelerometers. More...
 

Detailed Description

Functions and structs for dealing with 'Attitude' and AHRS.

Structs like zsl_attitude are inteded to be used as 'last-mile' represetnations, to convert Euler angles (in radians) to something more human-friendly like degrees. Most calculations should make use of Euler angles, and the richer API around them, with conversion to degrees as the final step.

Function Documentation

◆ 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.

Parameters
a1First acceleration triplet in m/s^2.
a2First acceleration triplet in m/s^2.
bAngle between the accelerometers, in radians.
Returns
0 if everything executed correctly, otherwise a negative error code if the accelerometer data is not tridimensional.

◆ 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.

Parameters
accelAcceleration triplet in m/s^2.
aPointer the the output zsl_attitude struct.
Returns
0 if everything executed correctly, otherwise a negative error code.

◆ 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) to attitude.

Parameters
accelAcceleration triplet in m/s^2.
magMagnetometer triplet in micro-Tesla.
aPointer the the output zsl_attitude struct.
Returns
0 if everything executed correctly, otherwise a negative error code.

◆ 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_attitude.

Parameters
ePointer to the zsl_euler struct to use.
aPointer to the zsl_attitued struct to use.
Returns
0 if everything executed correctly, otherwise a negative error code.

◆ 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_euler.

Parameters
aPointer to the zsl_attitued struct to use.
ePointer to the zsl_euler struct to use.
Returns
0 if everything executed correctly, otherwise a negative error code.

◆ 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, allowing for vector functions to be used on the zsl_attitude values.

Parameters
aPointer to the zsl_attitude struct to use.
vPointer to the zsl_vec struct to use.
Returns
0 if everything executed correctly, otherwise a negative error code.