2019-01-15 13:46:13 -04:00
|
|
|
#include "mode.h"
|
|
|
|
#include "Plane.h"
|
|
|
|
|
2021-09-10 03:28:21 -03:00
|
|
|
#include "qautotune.h"
|
|
|
|
|
|
|
|
#if QAUTOTUNE_ENABLED
|
|
|
|
|
2019-01-15 13:46:13 -04:00
|
|
|
bool ModeQAutotune::_enter()
|
|
|
|
{
|
2021-09-04 16:20:33 -03:00
|
|
|
#if QAUTOTUNE_ENABLED
|
|
|
|
return quadplane.qautotune.init();
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
2019-01-15 13:46:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ModeQAutotune::update()
|
|
|
|
{
|
|
|
|
plane.mode_qstabilize.update();
|
|
|
|
}
|
|
|
|
|
2021-08-14 15:53:03 -03:00
|
|
|
void ModeQAutotune::run()
|
|
|
|
{
|
2023-05-01 22:05:00 -03:00
|
|
|
const uint32_t now = AP_HAL::millis();
|
|
|
|
if (quadplane.tailsitter.in_vtol_transition(now)) {
|
|
|
|
// Tailsitters in FW pull up phase of VTOL transition run FW controllers
|
|
|
|
Mode::run();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-08-14 15:53:03 -03:00
|
|
|
#if QAUTOTUNE_ENABLED
|
|
|
|
quadplane.qautotune.run();
|
|
|
|
#endif
|
2023-05-01 22:05:00 -03:00
|
|
|
|
|
|
|
// Stabilize with fixed wing surfaces
|
|
|
|
plane.stabilize_roll();
|
|
|
|
plane.stabilize_pitch();
|
2021-08-14 15:53:03 -03:00
|
|
|
}
|
|
|
|
|
2019-04-30 01:43:10 -03:00
|
|
|
void ModeQAutotune::_exit()
|
|
|
|
{
|
|
|
|
#if QAUTOTUNE_ENABLED
|
|
|
|
plane.quadplane.qautotune.stop();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-09-10 03:28:21 -03:00
|
|
|
#endif
|