2019-01-15 13:46:13 -04:00
|
|
|
#include "mode.h"
|
|
|
|
#include "Plane.h"
|
|
|
|
|
2021-09-10 03:28:21 -03:00
|
|
|
#if HAL_QUADPLANE_ENABLED
|
|
|
|
|
2019-01-15 13:46:13 -04:00
|
|
|
bool ModeQHover::_enter()
|
2021-08-14 15:54:08 -03:00
|
|
|
{
|
|
|
|
// set vertical speed and acceleration limits
|
2024-01-18 22:40:25 -04:00
|
|
|
pos_control->set_max_speed_accel_z(-quadplane.get_pilot_velocity_z_max_dn(), quadplane.pilot_speed_z_max_up*100, quadplane.pilot_accel_z*100);
|
|
|
|
pos_control->set_correction_speed_accel_z(-quadplane.get_pilot_velocity_z_max_dn(), quadplane.pilot_speed_z_max_up*100, quadplane.pilot_accel_z*100);
|
2022-12-17 14:27:48 -04:00
|
|
|
quadplane.set_climb_rate_cms(0);
|
2021-08-14 15:54:08 -03:00
|
|
|
|
|
|
|
quadplane.init_throttle_wait();
|
2021-09-04 16:20:45 -03:00
|
|
|
return true;
|
2021-08-14 15:54:08 -03:00
|
|
|
}
|
|
|
|
|
2019-01-15 13:46:13 -04:00
|
|
|
void ModeQHover::update()
|
|
|
|
{
|
|
|
|
plane.mode_qstabilize.update();
|
|
|
|
}
|
|
|
|
|
2021-08-14 15:54:08 -03:00
|
|
|
/*
|
|
|
|
control QHOVER mode
|
|
|
|
*/
|
|
|
|
void ModeQHover::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:54:08 -03:00
|
|
|
if (quadplane.throttle_wait) {
|
|
|
|
quadplane.set_desired_spool_state(AP_Motors::DesiredSpoolState::GROUND_IDLE);
|
|
|
|
attitude_control->set_throttle_out(0, true, 0);
|
|
|
|
quadplane.relax_attitude_control();
|
|
|
|
pos_control->relax_z_controller(0);
|
|
|
|
} else {
|
2023-09-26 05:56:28 -03:00
|
|
|
plane.quadplane.assign_tilt_to_fwd_thr();
|
2021-08-14 15:54:08 -03:00
|
|
|
quadplane.hold_hover(quadplane.get_pilot_desired_climb_rate_cms());
|
|
|
|
}
|
2023-05-01 22:05:00 -03:00
|
|
|
|
|
|
|
// Stabilize with fixed wing surfaces
|
|
|
|
plane.stabilize_roll();
|
|
|
|
plane.stabilize_pitch();
|
2021-08-14 15:54:08 -03:00
|
|
|
}
|
2021-09-10 03:28:21 -03:00
|
|
|
|
|
|
|
#endif
|