Avionics
Core avionics package for CURE flight computers
Loading...
Searching...
No Matches
OrientationEstimator.h
Go to the documentation of this file.
1
#ifndef ORIENTATION_ESTIMATOR_H
2
#define ORIENTATION_ESTIMATOR_H
3
4
#include "
data_handling/DataPoint.h
"
5
#include "
state_estimation/StateEstimationTypes.h
"
6
#include "
state_estimation/States.h
"
7
16
class
OrientationEstimator
{
17
public
:
18
OrientationEstimator
(
float
gainPad = 0.05f,
float
gainFlight = 0.005f)
19
: q0(1.0f), q1(0.0f), q2(0.0f), q3(0.0f),
20
betaPad(gainPad), betaFlight(gainFlight),
21
roll(0.0f), pitch(0.0f), yaw(0.0f), hasLaunched(false), lastUpdateTime(0) {}
22
33
void
update
(
AccelerationTriplet
accel,
GyroTriplet
gyro,
MagTriplet
mag, uint32_t currentTime);
34
35
Quaternion
getQuaternion
()
const
{
36
Quaternion
q = {q0, q1, q2, q3};
37
return
q;
38
}
39
void
launchDetected
() { hasLaunched =
true
;}
40
float
getRoll
()
const
{
return
roll; }
41
float
getPitch
()
const
{
return
pitch; }
42
float
getYaw
()
const
{
return
yaw; }
43
44
private
:
45
float
q0, q1, q2, q3;
// quaternion
46
float
betaPad;
47
float
betaFlight;
48
float
beta;
// determines how much the algorithm relies on the accelerometer vs the gyroscope. Higher beta means more reliance on accel.
49
float
roll, pitch, yaw;
// Euler angles in degrees
50
bool
hasLaunched;
51
uint32_t lastUpdateTime;
// timestamp of the last update in milliseconds
52
62
void
updateFullAHRS(
AccelerationTriplet
accel,
GyroTriplet
gyro,
MagTriplet
mag, uint32_t currentTime);
63
72
void
updateIMU(
AccelerationTriplet
accel,
GyroTriplet
gyro, uint32_t currentTime);
73
74
/*
75
* @brief Compute Euler angles (roll, pitch, yaw) from the current quaternion estimate.
76
* This is called every update to keep the Euler angles in sync with the quaternion.
77
* The Euler angles are in degrees and follow the aerospace convention (roll around x-axis, pitch around y-axis, yaw around z-axis).
78
*/
79
void
getEuler();
80
};
81
82
83
#endif
DataPoint.h
StateEstimationTypes.h
States.h
OrientationEstimator::getQuaternion
Quaternion getQuaternion() const
Definition
OrientationEstimator.h:35
OrientationEstimator::update
void update(AccelerationTriplet accel, GyroTriplet gyro, MagTriplet mag, uint32_t currentTime)
Update the orientation estimator with new sensor data. This method should be called whenever new acce...
Definition
OrientationEstimator.cpp:15
OrientationEstimator::OrientationEstimator
OrientationEstimator(float gainPad=0.05f, float gainFlight=0.005f)
Definition
OrientationEstimator.h:18
OrientationEstimator::getRoll
float getRoll() const
Definition
OrientationEstimator.h:40
OrientationEstimator::getPitch
float getPitch() const
Definition
OrientationEstimator.h:41
OrientationEstimator::launchDetected
void launchDetected()
Definition
OrientationEstimator.h:39
OrientationEstimator::getYaw
float getYaw() const
Definition
OrientationEstimator.h:42
AccelerationTriplet
Definition
StateEstimationTypes.h:6
GyroTriplet
Definition
StateEstimationTypes.h:12
MagTriplet
Definition
StateEstimationTypes.h:18
Quaternion
Definition
StateEstimationTypes.h:24
include
state_estimation
OrientationEstimator.h
Generated by
1.16.1