2019-01-15 13:46:13 -04:00
|
|
|
#include "mode.h"
|
|
|
|
#include "Plane.h"
|
|
|
|
|
|
|
|
bool ModeAcro::_enter()
|
|
|
|
{
|
2023-02-12 09:45:25 -04:00
|
|
|
acro_state.locked_roll = false;
|
|
|
|
acro_state.locked_pitch = false;
|
|
|
|
IGNORE_RETURN(ahrs.get_quaternion(acro_state.q));
|
2019-01-15 13:46:13 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ModeAcro::update()
|
|
|
|
{
|
|
|
|
// handle locked/unlocked control
|
2023-02-12 09:45:25 -04:00
|
|
|
if (acro_state.locked_roll) {
|
|
|
|
plane.nav_roll_cd = acro_state.locked_roll_err;
|
2019-01-15 13:46:13 -04:00
|
|
|
} else {
|
2023-02-12 09:33:27 -04:00
|
|
|
plane.nav_roll_cd = ahrs.roll_sensor;
|
2019-01-15 13:46:13 -04:00
|
|
|
}
|
2023-02-12 09:45:25 -04:00
|
|
|
if (acro_state.locked_pitch) {
|
|
|
|
plane.nav_pitch_cd = acro_state.locked_pitch_cd;
|
2019-01-15 13:46:13 -04:00
|
|
|
} else {
|
2023-02-12 09:33:27 -04:00
|
|
|
plane.nav_pitch_cd = ahrs.pitch_sensor;
|
2019-01-15 13:46:13 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|