mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-25 16:51:16 +08:00
refactor(vtol_att_control): share the transition state machine (#29808)
* refactor(vtol_att_control): move the transition state machine into VtolType Standard, tiltrotor and tailsitter each kept a private vtol_mode enum and a 100-line update_vtol_state() that walked the same four-state graph (hover, transition to FW, transition to MC, FW) and then mapped it onto the common mode enum. The only type-specific parts were the completion predicates and a handful of entry side effects, so fixes to the graph (like the 2016 "restart the front transition instead of jumping to FW from a back transition" change inc6e4926d4e) reached one type and not the others. VtolType::update_vtol_state() now runs the graph on _common_vtol_mode directly, and the types override only: - isBackTransitionCompleted(): speed/time (standard, with on-ground), tilt and speed/time (tiltrotor), pitch or time (tailsitter). The shared speed/time check is isBackTransitionSpeedOrTimeExitConditionMet(). - canSwitchToFixedWingDuringBackTransition(): true for tiltrotor and tailsitter to keep their current instant switch, false (restart the front transition) for standard. - onTransitionStart(): tailsitter resets its start-attitude latch, tiltrotor resets its phase-2 flag. - onFrontTransitionCompleted() / onFrontTransitionAborted() / onFixedWingSystemFailure(): standard pusher throttle and transition pitch latch, tailsitter thrust-bridging timestamp. The tiltrotor's TRANSITION_FRONT_P2 becomes a private sub-phase of TRANSITION_TO_FW, entered from update_transition_state() when the common front-transition check passes and left when the tilt reaches VT_TILT_FW. Deliberate small deviations from the previous per-type code: - _trans_finished_ts is set on every switch into FW mode, including the tiltrotor's phase-2 completion and the tiltrotor's instant switch from a back transition (previously only at the tiltrotor's P1->P2 handoff). - the standard VTOL set its MC weights every loop in hover and FW mode; they are now set in update_mc_state()/update_fw_state(), i.e. on the next attitude-setpoint update. - the standard VTOL zeroed its pusher throttle on every loop while fixed_wing_system_failure was set; it now does so once on the switch to hover and update_mc_state() takes over as in any hover flight. Rebased onto the tailsitter and tiltrotor back transition fixes. The canSwitchToFixedWingDuringBackTransition() bullet above describes the code before them. The hook now returns false for the tailsitter, which restarts the front transition like the standard VTOL, and the VT_TILT_TRANS check for the tiltrotor. Also rebased onto the change that stops treating a commanded quad-chute as a fixed-wing failure. The state machine now reads is_quadchute_active() instead of fixed_wing_system_failure, and onFixedWingSystemFailure() is now onQuadchute(), called on every update while a quad-chute holds the vehicle in hover. Each type keeps the condition its own update_vtol_state() had: the tailsitter sets its thrust-bridging timestamp only on the switch to hover, and the standard VTOL zeroes its pusher on the switch and, while the quad-chute is a detected one, on every update. The onFixedWingSystemFailure() name in the bullets and the last deviation above describe the code before that change. Signed-off-by: Balduin <balduin@auterion.com> Assisted-by: Claude:claude-fable-5-2 Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu> * refactor(vtol_att_control): drop the redundant tailsitter hook override Since the rebase onto the back transition fixes the tailsitter's canSwitchToFixedWingDuringBackTransition() returns the base class default, so drop the override. The tailsitter restarts the front transition through the shared state machine like the standard VTOL. Give the tiltrotor check the reason it had in its update_vtol_state() and remove the blank lines left where the per-type enums were. No behaviour change. Assisted-by: Claude:claude-fable-5-2 Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu> * style(tiltrotor): remove stale comment This comment was added in02fda7a0f5(2015) describing a `rear_motor_state` enum. The enum has then been moved to a general `motor_state` in744f806214(2018) which has then been completely removed ince337a3d80(2022). * refactor(vtol_att_control): rename the shared front transition check For the tiltrotor the shared VtolType::isFrontTransitionCompleted() only meant that phase 2 of the front transition can start, while Tiltrotor::isFrontTransitionCompleted() means the rotors have reached VT_TILT_FW and the vehicle can switch to fixed-wing. Two functions with the same name answered different questions. Rename the shared one to isFrontTransitionSpeedOrTimeReached() and make isFrontTransitionCompleted() pure virtual. The tiltrotor keeps its override and starts phase 2 from the renamed check. Standard and tailsitter return the renamed check, which is what they used before. No functional change. Suggested by Balduin in review. Assisted-by: Claude:claude-fable-5-2 Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu> * refactor(vtol_att_control): rename the shared back transition check Match the name of isFrontTransitionSpeedOrTimeReached. I also find it clearer to not label it 'ExitConditionMet' because for the tiltrotor the exit condition is literally not already met, because of the added * refactor(vtol_att_control): default isFrontTransitionCompleted to the shared check This way we only have to override it if it is different from the current default (completed = speed or time reached), i.e. only for tailsitter. * refactor(vtol_att_control): drop isFrontTransitionCompletedBase Types now override isFrontTransitionCompleted() directly, mirroring the back transition: a non-virtual speed/time helper plus one virtual completion check. The on-ground bypass is spelled out where needed. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Balduin <balduin@auterion.com> * refactor(vtol_att_control): test the fixed-wing request positively in the state machine Slightly more readable than the other version IMO Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Balduin <balduin@auterion.com> --------- Signed-off-by: Balduin <balduin@auterion.com> Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu> Co-authored-by: Balduin <balduin@auterion.com>
This commit is contained in:
1 parent
288b114841
commit
081695e0fb
8 files changed
+246
-393
No files matched your search
@@ -67,115 +67,34 @@ Standard::parameters_update()
|
||||
}
|
||||
}
|
||||
|
||||
void Standard::update_vtol_state()
|
||||
bool Standard::isBackTransitionCompleted()
|
||||
{
|
||||
/* After flipping the switch the vehicle will start the pusher (or tractor) motor, picking up
|
||||
* forward speed. After the vehicle has picked up enough speed the rotors shutdown.
|
||||
* For the back transition the pusher motor is immediately stopped and rotors reactivated.
|
||||
*/
|
||||
return can_transition_on_ground() || isBackTransitionSpeedOrTimeReached();
|
||||
}
|
||||
|
||||
void Standard::checkTypeSpecificQuadchute()
|
||||
{
|
||||
// without pusher a front transition would fail too, so this quad-chute stays until reboot
|
||||
if (_pusher_failed) {
|
||||
_attc->quadchute(QuadchuteReason::PusherFailure);
|
||||
}
|
||||
}
|
||||
|
||||
float mc_weight = _mc_roll_weight;
|
||||
void Standard::onFrontTransitionCompleted()
|
||||
{
|
||||
// don't set pusher throttle here as it's being ramped up elsewhere
|
||||
_front_transition_pitch = Eulerf(Quatf(_v_att_sp->q_d)).theta();
|
||||
}
|
||||
|
||||
if (_attc->is_quadchute_active()) {
|
||||
// Failsafe event, engage mc motors immediately
|
||||
if (_vtol_mode != vtol_mode::MC_MODE || _attc->is_fixed_wing_system_failure()) {
|
||||
_pusher_throttle = 0.0f; // a commanded quad-chute keeps pusher assist once in multicopter mode
|
||||
}
|
||||
void Standard::onFrontTransitionAborted()
|
||||
{
|
||||
_pusher_throttle = 0.0f;
|
||||
}
|
||||
|
||||
_vtol_mode = vtol_mode::MC_MODE;
|
||||
|
||||
} else if (!_attc->is_fixed_wing_requested()) {
|
||||
|
||||
// the transition to fw mode switch is off
|
||||
if (_vtol_mode == vtol_mode::MC_MODE) {
|
||||
// in mc mode
|
||||
_vtol_mode = vtol_mode::MC_MODE;
|
||||
mc_weight = 1.0f;
|
||||
|
||||
} else if (_vtol_mode == vtol_mode::FW_MODE) {
|
||||
// Regular backtransition
|
||||
resetTransitionStates();
|
||||
_vtol_mode = vtol_mode::TRANSITION_TO_MC;
|
||||
|
||||
} else if (_vtol_mode == vtol_mode::TRANSITION_TO_FW) {
|
||||
// failsafe back to mc mode
|
||||
_vtol_mode = vtol_mode::MC_MODE;
|
||||
mc_weight = 1.0f;
|
||||
_pusher_throttle = 0.0f;
|
||||
|
||||
} else if (_vtol_mode == vtol_mode::TRANSITION_TO_MC) {
|
||||
// speed exit condition: use ground if valid, otherwise airspeed
|
||||
bool exit_backtransition_speed_condition = false;
|
||||
|
||||
if (_local_pos->v_xy_valid) {
|
||||
const Dcmf R_to_body(Quatf(_v_att->q).inversed());
|
||||
const Vector3f vel = R_to_body * Vector3f(_local_pos->vx, _local_pos->vy, _local_pos->vz);
|
||||
exit_backtransition_speed_condition = vel(0) < _param_mpc_xy_cruise.get();
|
||||
|
||||
} else if (PX4_ISFINITE(_attc->get_calibrated_airspeed())) {
|
||||
exit_backtransition_speed_condition = _attc->get_calibrated_airspeed() < _param_mpc_xy_cruise.get();
|
||||
}
|
||||
|
||||
const bool exit_backtransition_time_condition = _time_since_trans_start > _param_vt_b_trans_dur.get();
|
||||
|
||||
if (can_transition_on_ground() || exit_backtransition_speed_condition || exit_backtransition_time_condition) {
|
||||
_vtol_mode = vtol_mode::MC_MODE;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// the transition to fw mode switch is on
|
||||
if (_vtol_mode == vtol_mode::MC_MODE || _vtol_mode == vtol_mode::TRANSITION_TO_MC) {
|
||||
// start transition to fw mode
|
||||
/* NOTE: The failsafe transition to fixed-wing was removed because it can result in an
|
||||
* unsafe flying state. */
|
||||
resetTransitionStates();
|
||||
_vtol_mode = vtol_mode::TRANSITION_TO_FW;
|
||||
|
||||
} else if (_vtol_mode == vtol_mode::FW_MODE) {
|
||||
// in fw mode
|
||||
_vtol_mode = vtol_mode::FW_MODE;
|
||||
mc_weight = 0.0f;
|
||||
|
||||
} else if (_vtol_mode == vtol_mode::TRANSITION_TO_FW) {
|
||||
|
||||
if (isFrontTransitionCompleted()) {
|
||||
_vtol_mode = vtol_mode::FW_MODE;
|
||||
|
||||
// don't set pusher throttle here as it's being ramped up elsewhere
|
||||
_trans_finished_ts = hrt_absolute_time();
|
||||
_front_transition_pitch = Eulerf(Quatf(_v_att_sp->q_d)).theta();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_mc_roll_weight = mc_weight;
|
||||
_mc_pitch_weight = mc_weight;
|
||||
_mc_yaw_weight = mc_weight;
|
||||
_mc_throttle_weight = mc_weight;
|
||||
|
||||
// map specific control phases to simple control modes
|
||||
switch (_vtol_mode) {
|
||||
case vtol_mode::MC_MODE:
|
||||
_common_vtol_mode = mode::ROTARY_WING;
|
||||
break;
|
||||
|
||||
case vtol_mode::FW_MODE:
|
||||
_common_vtol_mode = mode::FIXED_WING;
|
||||
break;
|
||||
|
||||
case vtol_mode::TRANSITION_TO_FW:
|
||||
_common_vtol_mode = mode::TRANSITION_TO_FW;
|
||||
break;
|
||||
|
||||
case vtol_mode::TRANSITION_TO_MC:
|
||||
_common_vtol_mode = mode::TRANSITION_TO_MC;
|
||||
break;
|
||||
void Standard::onQuadchute()
|
||||
{
|
||||
if (_common_vtol_mode != mode::ROTARY_WING || _attc->is_fixed_wing_system_failure()) {
|
||||
_pusher_throttle = 0.0f; // a commanded quad-chute keeps pusher assist once in multicopter mode
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,7 +134,7 @@ void Standard::update_transition_state()
|
||||
float pitch_body = attitude_setpoint_euler.theta();
|
||||
float yaw_body = attitude_setpoint_euler.psi();
|
||||
|
||||
if (_vtol_mode == vtol_mode::TRANSITION_TO_FW) {
|
||||
if (_common_vtol_mode == mode::TRANSITION_TO_FW) {
|
||||
|
||||
if (_v_control_mode->flag_control_climb_rate_enabled) {
|
||||
roll_body = Eulerf(Quatf(_fw_virtual_att_sp->q_d)).phi();
|
||||
@@ -261,7 +180,7 @@ void Standard::update_transition_state()
|
||||
q_sp.copyTo(_v_att_sp->q_d);
|
||||
mc_weight = math::constrain(mc_weight, 0.0f, 1.0f);
|
||||
|
||||
} else if (_vtol_mode == vtol_mode::TRANSITION_TO_MC) {
|
||||
} else if (_common_vtol_mode == mode::TRANSITION_TO_MC) {
|
||||
|
||||
// continually increase mc attitude control as we transition back to mc mode
|
||||
if (_param_vt_b_trans_ramp.get() > FLT_EPSILON) {
|
||||
@@ -324,6 +243,8 @@ bool Standard::isPusherFailureDetected()
|
||||
void Standard::update_fw_state()
|
||||
{
|
||||
VtolType::update_fw_state();
|
||||
|
||||
_mc_throttle_weight = 0.0f;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -356,8 +277,8 @@ void Standard::fill_actuator_outputs()
|
||||
_thrust_setpoint_1->xyz[1] = 0.f;
|
||||
_thrust_setpoint_1->xyz[2] = 0.f;
|
||||
|
||||
switch (_vtol_mode) {
|
||||
case vtol_mode::MC_MODE:
|
||||
switch (_common_vtol_mode) {
|
||||
case mode::ROTARY_WING:
|
||||
|
||||
// MC actuators:
|
||||
_torque_setpoint_0->xyz[0] = _vehicle_torque_setpoint_virtual_mc->xyz[0];
|
||||
@@ -377,10 +298,10 @@ void Standard::fill_actuator_outputs()
|
||||
|
||||
break;
|
||||
|
||||
case vtol_mode::TRANSITION_TO_FW:
|
||||
case mode::TRANSITION_TO_FW:
|
||||
|
||||
// FALLTHROUGH
|
||||
case vtol_mode::TRANSITION_TO_MC:
|
||||
case mode::TRANSITION_TO_MC:
|
||||
// MC actuators:
|
||||
_torque_setpoint_0->xyz[0] = _vehicle_torque_setpoint_virtual_mc->xyz[0] * _mc_roll_weight;
|
||||
_torque_setpoint_0->xyz[1] = _vehicle_torque_setpoint_virtual_mc->xyz[1] * _mc_pitch_weight;
|
||||
@@ -395,7 +316,7 @@ void Standard::fill_actuator_outputs()
|
||||
|
||||
break;
|
||||
|
||||
case vtol_mode::FW_MODE:
|
||||
case mode::FIXED_WING:
|
||||
|
||||
// FW actuators
|
||||
_torque_setpoint_1->xyz[0] = _vehicle_torque_setpoint_virtual_fw->xyz[0];
|
||||
|
||||
@@ -57,7 +57,6 @@ public:
|
||||
Standard(VtolAttitudeControl *_att_controller);
|
||||
~Standard() override = default;
|
||||
|
||||
void update_vtol_state() override;
|
||||
void update_transition_state() override;
|
||||
void update_fw_state() override;
|
||||
void update_mc_state() override;
|
||||
@@ -67,16 +66,6 @@ public:
|
||||
void blendPitchAfterFrontTransition(float scale) override;
|
||||
|
||||
private:
|
||||
|
||||
enum class vtol_mode {
|
||||
MC_MODE = 0,
|
||||
TRANSITION_TO_FW,
|
||||
TRANSITION_TO_MC,
|
||||
FW_MODE
|
||||
};
|
||||
|
||||
vtol_mode _vtol_mode{vtol_mode::MC_MODE}; /**< vtol flight mode, defined by enum vtol_mode */
|
||||
|
||||
float _pusher_throttle{0.0f};
|
||||
float _airspeed_trans_blend_margin{0.0f};
|
||||
hrt_abstime _last_time_pusher_transition_update{0};
|
||||
@@ -87,6 +76,12 @@ private:
|
||||
|
||||
void parameters_update() override;
|
||||
|
||||
bool isBackTransitionCompleted() override;
|
||||
void onFrontTransitionCompleted() override;
|
||||
void onFrontTransitionAborted() override;
|
||||
void onQuadchute() override;
|
||||
void checkTypeSpecificQuadchute() override;
|
||||
|
||||
bool isPusherFailureDetectionEnabled() const { return _param_vt_ef_time.get() > FLT_EPSILON; }
|
||||
|
||||
/** Pusher assist above VT_EF_THROT, but the forward velocity stays below its setpoint */
|
||||
|
||||
@@ -98,101 +98,20 @@ bool Tailsitter::isRollExceeded()
|
||||
return false;
|
||||
}
|
||||
|
||||
void Tailsitter::update_vtol_state()
|
||||
bool Tailsitter::isBackTransitionCompleted()
|
||||
{
|
||||
/* simple logic using a two way switch to perform transitions.
|
||||
* after flipping the switch the vehicle will start tilting in MC control mode, picking up
|
||||
* forward speed. After the vehicle has picked up enough and sufficient pitch angle the uav will go into FW mode.
|
||||
* For the backtransition the pitch is controlled in MC mode again and switches to full MC control reaching the sufficient pitch angle.
|
||||
*/
|
||||
const float pitch = Eulerf(Quatf(_v_att->q)).theta();
|
||||
|
||||
// check if we have reached pitch angle to switch to MC mode
|
||||
return pitch >= PITCH_THRESHOLD_AUTO_TRANSITION_TO_MC || _time_since_trans_start > _param_vt_b_trans_dur.get();
|
||||
}
|
||||
|
||||
if (_attc->is_quadchute_active()) {
|
||||
// Failsafe event, switch to MC mode immediately
|
||||
if (_vtol_mode != vtol_mode::MC_MODE) {
|
||||
_transition_start_timestamp = hrt_absolute_time();
|
||||
}
|
||||
|
||||
_vtol_mode = vtol_mode::MC_MODE;
|
||||
|
||||
} else if (!_attc->is_fixed_wing_requested()) {
|
||||
|
||||
switch (_vtol_mode) { // user switchig to MC mode
|
||||
case vtol_mode::MC_MODE:
|
||||
break;
|
||||
|
||||
case vtol_mode::FW_MODE:
|
||||
resetTransitionStates();
|
||||
_vtol_mode = vtol_mode::TRANSITION_BACK;
|
||||
break;
|
||||
|
||||
case vtol_mode::TRANSITION_FRONT_P1:
|
||||
// failsafe into multicopter mode
|
||||
_vtol_mode = vtol_mode::MC_MODE;
|
||||
break;
|
||||
|
||||
case vtol_mode::TRANSITION_BACK:
|
||||
const float pitch = Eulerf(Quatf(_v_att->q)).theta();
|
||||
|
||||
// check if we have reached pitch angle to switch to MC mode
|
||||
if (pitch >= PITCH_THRESHOLD_AUTO_TRANSITION_TO_MC || _time_since_trans_start > _param_vt_b_trans_dur.get()) {
|
||||
_vtol_mode = vtol_mode::MC_MODE;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
} else { // user switchig to FW mode
|
||||
|
||||
switch (_vtol_mode) {
|
||||
case vtol_mode::MC_MODE:
|
||||
// initialise a front transition
|
||||
_vtol_mode = vtol_mode::TRANSITION_FRONT_P1;
|
||||
resetTransitionStates();
|
||||
break;
|
||||
|
||||
case vtol_mode::FW_MODE:
|
||||
break;
|
||||
|
||||
case vtol_mode::TRANSITION_FRONT_P1: {
|
||||
|
||||
if (isFrontTransitionCompleted()) {
|
||||
_vtol_mode = vtol_mode::FW_MODE;
|
||||
_trans_finished_ts = hrt_absolute_time();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case vtol_mode::TRANSITION_BACK:
|
||||
// fixed-wing requested again during the back transition. Restart the front transition
|
||||
// instead of handing a partly pitched-up attitude at low airspeed to the fixed-wing controller
|
||||
resetTransitionStates();
|
||||
_flag_was_in_trans_mode = false; // recompute the transition start attitude and rotation axis
|
||||
_vtol_mode = vtol_mode::TRANSITION_FRONT_P1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// map tailsitter specific control phases to simple control modes
|
||||
switch (_vtol_mode) {
|
||||
case vtol_mode::MC_MODE:
|
||||
_common_vtol_mode = mode::ROTARY_WING;
|
||||
_flag_was_in_trans_mode = false;
|
||||
break;
|
||||
|
||||
case vtol_mode::FW_MODE:
|
||||
_common_vtol_mode = mode::FIXED_WING;
|
||||
_flag_was_in_trans_mode = false;
|
||||
break;
|
||||
|
||||
case vtol_mode::TRANSITION_FRONT_P1:
|
||||
_common_vtol_mode = mode::TRANSITION_TO_FW;
|
||||
break;
|
||||
|
||||
case vtol_mode::TRANSITION_BACK:
|
||||
_common_vtol_mode = mode::TRANSITION_TO_MC;
|
||||
break;
|
||||
void Tailsitter::onQuadchute()
|
||||
{
|
||||
if (_common_vtol_mode != mode::ROTARY_WING) {
|
||||
// for the short period after the switch where there is no thrust published yet from the MC controller,
|
||||
// keep publishing the last FW thrust (see fill_actuator_outputs)
|
||||
_transition_start_timestamp = hrt_absolute_time();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,7 +129,7 @@ void Tailsitter::update_transition_state()
|
||||
if (!_flag_was_in_trans_mode) {
|
||||
_flag_was_in_trans_mode = true;
|
||||
|
||||
if (_vtol_mode == vtol_mode::TRANSITION_BACK) {
|
||||
if (_common_vtol_mode == mode::TRANSITION_TO_MC) {
|
||||
// calculate rotation axis for transition.
|
||||
_q_trans_start = Quatf(_v_att->q);
|
||||
Vector3f z = -_q_trans_start.dcm_z();
|
||||
@@ -234,7 +153,7 @@ void Tailsitter::update_transition_state()
|
||||
// multirotor frame
|
||||
_q_trans_start = _q_trans_start * Quatf(Eulerf(0, -M_PI_2_F, 0));
|
||||
|
||||
} else if (_vtol_mode == vtol_mode::TRANSITION_FRONT_P1) {
|
||||
} else if (_common_vtol_mode == mode::TRANSITION_TO_FW) {
|
||||
// initial attitude setpoint for the transition should be with wings level
|
||||
const Eulerf setpoint_euler(Quatf(_mc_virtual_att_sp->q_d));
|
||||
_q_trans_start = Eulerf(0.f, setpoint_euler.theta(), setpoint_euler.psi());
|
||||
@@ -253,7 +172,7 @@ void Tailsitter::update_transition_state()
|
||||
_q_trans_sp(2) * _q_trans_sp(2) + _q_trans_sp(3) * _q_trans_sp(3), -1.f, 1.f);
|
||||
const float tilt = acosf(cos_tilt);
|
||||
|
||||
if (_vtol_mode == vtol_mode::TRANSITION_FRONT_P1) {
|
||||
if (_common_vtol_mode == mode::TRANSITION_TO_FW) {
|
||||
|
||||
// calculate pitching rate - and constrain to at least 0.1s transition time
|
||||
const float trans_pitch_rate = M_PI_2_F / math::max(_param_vt_f_trans_dur.get(), 0.1f);
|
||||
@@ -263,7 +182,7 @@ void Tailsitter::update_transition_state()
|
||||
_time_since_trans_start * trans_pitch_rate)) * _q_trans_start;
|
||||
}
|
||||
|
||||
} else if (_vtol_mode == vtol_mode::TRANSITION_BACK) {
|
||||
} else if (_common_vtol_mode == mode::TRANSITION_TO_MC) {
|
||||
|
||||
// calculate pitching rate - and constrain to at least 0.1s transition time
|
||||
const float trans_pitch_rate = M_PI_2_F / math::max(_param_vt_b_trans_dur.get(), 0.1f);
|
||||
@@ -276,7 +195,7 @@ void Tailsitter::update_transition_state()
|
||||
|
||||
_v_att_sp->thrust_body[2] = _mc_virtual_att_sp->thrust_body[2];
|
||||
|
||||
if (_vtol_mode == vtol_mode::TRANSITION_BACK) {
|
||||
if (_common_vtol_mode == mode::TRANSITION_TO_MC) {
|
||||
const float progress = math::constrain(_time_since_trans_start / B_TRANS_THRUST_BLENDING_DURATION, 0.f, 1.f);
|
||||
blendThrottleBeginningBackTransition(progress);
|
||||
}
|
||||
@@ -329,7 +248,7 @@ void Tailsitter::fill_actuator_outputs()
|
||||
_thrust_setpoint_1->xyz[2] = 0.f;
|
||||
|
||||
// Motors
|
||||
if (_vtol_mode == vtol_mode::FW_MODE) {
|
||||
if (_common_vtol_mode == mode::FIXED_WING) {
|
||||
|
||||
_thrust_setpoint_0->xyz[2] = -_vehicle_thrust_setpoint_virtual_fw->xyz[0];
|
||||
|
||||
@@ -360,7 +279,7 @@ void Tailsitter::fill_actuator_outputs()
|
||||
|
||||
// for the short period after starting the backtransition where there is no thrust published yet from the MC controller,
|
||||
// keep publishing the last FW thrust to keep the motors running
|
||||
if (_vtol_mode != vtol_mode::TRANSITION_FRONT_P1 && hrt_elapsed_time(&_transition_start_timestamp) < 50_ms) {
|
||||
if (_common_vtol_mode != mode::TRANSITION_TO_FW && hrt_elapsed_time(&_transition_start_timestamp) < 50_ms) {
|
||||
_thrust_setpoint_0->xyz[2] = -_last_thr_in_fw_mode;
|
||||
}
|
||||
|
||||
@@ -370,7 +289,7 @@ void Tailsitter::fill_actuator_outputs()
|
||||
}
|
||||
|
||||
// Control surfaces
|
||||
if (!_param_vt_elev_mc_lock.get() || _vtol_mode != vtol_mode::MC_MODE) {
|
||||
if (!_param_vt_elev_mc_lock.get() || _common_vtol_mode != mode::ROTARY_WING) {
|
||||
_torque_setpoint_1->xyz[0] = _vehicle_torque_setpoint_virtual_fw->xyz[0];
|
||||
_torque_setpoint_1->xyz[1] = _vehicle_torque_setpoint_virtual_fw->xyz[1];
|
||||
_torque_setpoint_1->xyz[2] = _vehicle_torque_setpoint_virtual_fw->xyz[2];
|
||||
@@ -378,7 +297,7 @@ void Tailsitter::fill_actuator_outputs()
|
||||
}
|
||||
|
||||
|
||||
bool Tailsitter::isFrontTransitionCompletedBase()
|
||||
bool Tailsitter::isFrontTransitionCompleted()
|
||||
{
|
||||
const bool airspeed_triggers_transition = PX4_ISFINITE(_attc->get_calibrated_airspeed());
|
||||
|
||||
@@ -394,7 +313,7 @@ bool Tailsitter::isFrontTransitionCompletedBase()
|
||||
}
|
||||
}
|
||||
|
||||
return transition_to_fw;
|
||||
return transition_to_fw || can_transition_on_ground();
|
||||
}
|
||||
|
||||
void Tailsitter::blendThrottleAfterFrontTransition(float scale)
|
||||
|
||||
@@ -64,7 +64,6 @@ public:
|
||||
Tailsitter(VtolAttitudeControl *_att_controller);
|
||||
~Tailsitter() override = default;
|
||||
|
||||
void update_vtol_state() override;
|
||||
void update_transition_state() override;
|
||||
void update_fw_state() override;
|
||||
void fill_actuator_outputs() override;
|
||||
@@ -73,15 +72,6 @@ public:
|
||||
void blendThrottleBeginningBackTransition(float scale);
|
||||
|
||||
private:
|
||||
enum class vtol_mode {
|
||||
MC_MODE = 0, /**< vtol is in multicopter mode */
|
||||
TRANSITION_FRONT_P1, /**< vtol is in front transition part 1 mode */
|
||||
TRANSITION_BACK, /**< vtol is in back transition mode */
|
||||
FW_MODE /**< vtol is in fixed wing mode */
|
||||
};
|
||||
|
||||
vtol_mode _vtol_mode{vtol_mode::MC_MODE}; /**< vtol flight mode, defined by enum vtol_mode */
|
||||
|
||||
bool _flag_was_in_trans_mode = false; // true if mode has just switched to transition
|
||||
|
||||
matrix::Quatf _q_trans_start;
|
||||
@@ -92,7 +82,10 @@ private:
|
||||
|
||||
void parameters_update() override;
|
||||
|
||||
bool isFrontTransitionCompletedBase() override;
|
||||
bool isFrontTransitionCompleted() override;
|
||||
bool isBackTransitionCompleted() override;
|
||||
void onTransitionStart() override { _flag_was_in_trans_mode = false; }
|
||||
void onQuadchute() override;
|
||||
bool isPitchExceeded() override;
|
||||
bool isRollExceeded() override;
|
||||
|
||||
|
||||
@@ -59,132 +59,17 @@ Tiltrotor::parameters_update()
|
||||
VtolType::updateParams();
|
||||
}
|
||||
|
||||
void Tiltrotor::update_vtol_state()
|
||||
bool Tiltrotor::isFrontTransitionCompleted()
|
||||
{
|
||||
/* simple logic using a two way switch to perform transitions.
|
||||
* after flipping the switch the vehicle will start tilting rotors, picking up
|
||||
* forward speed. After the vehicle has picked up enough speed the rotors are tilted
|
||||
* forward completely. For the backtransition the motors simply rotate back.
|
||||
*/
|
||||
// if the rotors have been tilted completely we switch to fw mode
|
||||
return _front_transition_phase_2 && _tilt_control >= _param_vt_tilt_fw.get();
|
||||
}
|
||||
|
||||
if (_attc->is_quadchute_active()) {
|
||||
// Failsafe event, switch to MC mode immediately
|
||||
_vtol_mode = vtol_mode::MC_MODE;
|
||||
bool Tiltrotor::isBackTransitionCompleted()
|
||||
{
|
||||
const bool exit_backtransition_tilt_condition = _tilt_control <= (_param_vt_tilt_mc.get() + 0.01f);
|
||||
|
||||
} else if (!_attc->is_fixed_wing_requested()) {
|
||||
|
||||
// plane is in multicopter mode
|
||||
switch (_vtol_mode) {
|
||||
case vtol_mode::MC_MODE:
|
||||
break;
|
||||
|
||||
case vtol_mode::FW_MODE:
|
||||
resetTransitionStates();
|
||||
_vtol_mode = vtol_mode::TRANSITION_BACK;
|
||||
break;
|
||||
|
||||
case vtol_mode::TRANSITION_FRONT_P1:
|
||||
// failsafe into multicopter mode
|
||||
_vtol_mode = vtol_mode::MC_MODE;
|
||||
break;
|
||||
|
||||
case vtol_mode::TRANSITION_FRONT_P2:
|
||||
// failsafe into multicopter mode
|
||||
_vtol_mode = vtol_mode::MC_MODE;
|
||||
break;
|
||||
|
||||
case vtol_mode::TRANSITION_BACK:
|
||||
const bool exit_backtransition_tilt_condition = _tilt_control <= (_param_vt_tilt_mc.get() + 0.01f);
|
||||
|
||||
// speed exit condition: use ground if valid, otherwise airspeed
|
||||
bool exit_backtransition_speed_condition = false;
|
||||
|
||||
if (_local_pos->v_xy_valid) {
|
||||
const Dcmf R_to_body(Quatf(_v_att->q).inversed());
|
||||
const Vector3f vel = R_to_body * Vector3f(_local_pos->vx, _local_pos->vy, _local_pos->vz);
|
||||
exit_backtransition_speed_condition = vel(0) < _param_mpc_xy_cruise.get() ;
|
||||
|
||||
} else if (PX4_ISFINITE(_attc->get_calibrated_airspeed())) {
|
||||
exit_backtransition_speed_condition = _attc->get_calibrated_airspeed() < _param_mpc_xy_cruise.get() ;
|
||||
}
|
||||
|
||||
const bool exit_backtransition_time_condition = _time_since_trans_start > _param_vt_b_trans_dur.get() ;
|
||||
|
||||
if (exit_backtransition_tilt_condition && (exit_backtransition_speed_condition || exit_backtransition_time_condition)) {
|
||||
_vtol_mode = vtol_mode::MC_MODE;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
switch (_vtol_mode) {
|
||||
case vtol_mode::MC_MODE:
|
||||
// initialise a front transition
|
||||
resetTransitionStates();
|
||||
_vtol_mode = vtol_mode::TRANSITION_FRONT_P1;
|
||||
break;
|
||||
|
||||
case vtol_mode::FW_MODE:
|
||||
break;
|
||||
|
||||
case vtol_mode::TRANSITION_FRONT_P1: {
|
||||
if (isFrontTransitionCompleted()) {
|
||||
_vtol_mode = vtol_mode::TRANSITION_FRONT_P2;
|
||||
_trans_finished_ts = hrt_absolute_time();
|
||||
resetTransitionStates();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case vtol_mode::TRANSITION_FRONT_P2:
|
||||
|
||||
// if the rotors have been tilted completely we switch to fw mode
|
||||
if (_tilt_control >= _param_vt_tilt_fw.get()) {
|
||||
_vtol_mode = vtol_mode::FW_MODE;
|
||||
_tilt_control = _param_vt_tilt_fw.get();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case vtol_mode::TRANSITION_BACK:
|
||||
|
||||
// while the rotors are still tilted forward enough for the wing, finish as before
|
||||
if (_tilt_control >= _param_vt_tilt_trans.get()) {
|
||||
_vtol_mode = vtol_mode::FW_MODE;
|
||||
|
||||
} else {
|
||||
// the rotors are already coming back. Restart the front transition from the current tilt
|
||||
// instead of handing the fixed-wing controller a vehicle with the rotors near vertical
|
||||
resetTransitionStates();
|
||||
_vtol_mode = vtol_mode::TRANSITION_FRONT_P1;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// map tiltrotor specific control phases to simple control modes
|
||||
switch (_vtol_mode) {
|
||||
case vtol_mode::MC_MODE:
|
||||
_common_vtol_mode = mode::ROTARY_WING;
|
||||
break;
|
||||
|
||||
case vtol_mode::FW_MODE:
|
||||
_common_vtol_mode = mode::FIXED_WING;
|
||||
break;
|
||||
|
||||
case vtol_mode::TRANSITION_FRONT_P1:
|
||||
case vtol_mode::TRANSITION_FRONT_P2:
|
||||
_common_vtol_mode = mode::TRANSITION_TO_FW;
|
||||
break;
|
||||
|
||||
case vtol_mode::TRANSITION_BACK:
|
||||
_common_vtol_mode = mode::TRANSITION_TO_MC;
|
||||
break;
|
||||
}
|
||||
return exit_backtransition_tilt_condition && isBackTransitionSpeedOrTimeReached();
|
||||
}
|
||||
|
||||
void Tiltrotor::update_mc_state()
|
||||
@@ -244,7 +129,16 @@ void Tiltrotor::update_transition_state()
|
||||
roll_body = Eulerf(Quatf(_fw_virtual_att_sp->q_d)).phi();
|
||||
}
|
||||
|
||||
if (_vtol_mode == vtol_mode::TRANSITION_FRONT_P1) {
|
||||
if (_common_vtol_mode == mode::TRANSITION_TO_FW && !_front_transition_phase_2
|
||||
&& ((isFrontTransitionSpeedOrTimeReached() && _tilt_control >= _param_vt_tilt_trans.get())
|
||||
|| can_transition_on_ground())) {
|
||||
// first part done: the plane is ready to go into fixed wing mode, tilt the rotors forward completely
|
||||
_front_transition_phase_2 = true;
|
||||
_trans_finished_ts = hrt_absolute_time();
|
||||
resetTransitionStates();
|
||||
}
|
||||
|
||||
if (_common_vtol_mode == mode::TRANSITION_TO_FW && !_front_transition_phase_2) {
|
||||
// for the first part of the transition all rotors are enabled
|
||||
|
||||
// tilt rotors forward up to certain angle
|
||||
@@ -286,7 +180,7 @@ void Tiltrotor::update_transition_state()
|
||||
// add minimum throttle for front transition
|
||||
_thrust_transition = math::max(_thrust_transition, FRONTTRANS_THR_MIN);
|
||||
|
||||
} else if (_vtol_mode == vtol_mode::TRANSITION_FRONT_P2) {
|
||||
} else if (_common_vtol_mode == mode::TRANSITION_TO_FW) {
|
||||
// the plane is ready to go into fixed wing mode, tilt the rotors forward completely
|
||||
_tilt_control = math::constrain(_param_vt_tilt_trans.get() +
|
||||
fabsf(_param_vt_tilt_fw.get() - _param_vt_tilt_trans.get()) * _time_since_trans_start /
|
||||
@@ -302,7 +196,7 @@ void Tiltrotor::update_transition_state()
|
||||
// if this is not then then there is race condition where the fw rate controller still publishes a zero sample throttle after transition
|
||||
_v_att_sp->thrust_body[0] = _thrust_transition;
|
||||
|
||||
} else if (_vtol_mode == vtol_mode::TRANSITION_BACK) {
|
||||
} else if (_common_vtol_mode == mode::TRANSITION_TO_MC) {
|
||||
|
||||
// tilt rotors back once motors are idle
|
||||
if (_time_since_trans_start > BACKTRANS_THROTTLE_DOWNRAMP_DUR_S) {
|
||||
@@ -401,7 +295,7 @@ void Tiltrotor::fill_actuator_outputs()
|
||||
// by the allocator directly.
|
||||
float collective_thrust_normalized_setpoint = 0.f;
|
||||
|
||||
if (_vtol_mode == vtol_mode::FW_MODE) {
|
||||
if (_common_vtol_mode == mode::FIXED_WING) {
|
||||
|
||||
collective_thrust_normalized_setpoint = _vehicle_thrust_setpoint_virtual_fw->xyz[0];
|
||||
_thrust_setpoint_0->xyz[2] = -collective_thrust_normalized_setpoint;
|
||||
@@ -417,7 +311,7 @@ void Tiltrotor::fill_actuator_outputs()
|
||||
}
|
||||
|
||||
// Fixed wing output
|
||||
if (!_param_vt_elev_mc_lock.get() || _vtol_mode != vtol_mode::MC_MODE) {
|
||||
if (!_param_vt_elev_mc_lock.get() || _common_vtol_mode != mode::ROTARY_WING) {
|
||||
_torque_setpoint_1->xyz[0] = _vehicle_torque_setpoint_virtual_fw->xyz[0];
|
||||
_torque_setpoint_1->xyz[1] = _vehicle_torque_setpoint_virtual_fw->xyz[1];
|
||||
_torque_setpoint_1->xyz[2] = _vehicle_torque_setpoint_virtual_fw->xyz[2];
|
||||
@@ -452,8 +346,3 @@ float Tiltrotor::moveLinear(float start, float stop, float progress)
|
||||
{
|
||||
return start + progress * (stop - start);
|
||||
}
|
||||
|
||||
bool Tiltrotor::isFrontTransitionCompletedBase()
|
||||
{
|
||||
return VtolType::isFrontTransitionCompletedBase() && _tilt_control >= _param_vt_tilt_trans.get();
|
||||
}
|
||||
@@ -55,7 +55,6 @@ public:
|
||||
Tiltrotor(VtolAttitudeControl *_att_controller);
|
||||
~Tiltrotor() override = default;
|
||||
|
||||
void update_vtol_state() override;
|
||||
void update_transition_state() override;
|
||||
void fill_actuator_outputs() override;
|
||||
void update_mc_state() override;
|
||||
@@ -64,32 +63,25 @@ public:
|
||||
void blendThrottleAfterFrontTransition(float scale) override;
|
||||
|
||||
private:
|
||||
enum class vtol_mode {
|
||||
MC_MODE = 0, /**< vtol is in multicopter mode */
|
||||
TRANSITION_FRONT_P1, /**< vtol is in front transition part 1 mode */
|
||||
TRANSITION_FRONT_P2, /**< vtol is in front transition part 2 mode */
|
||||
TRANSITION_BACK, /**< vtol is in back transition mode */
|
||||
FW_MODE /**< vtol is in fixed wing mode */
|
||||
};
|
||||
|
||||
/**
|
||||
* Specific to tiltrotor with vertical aligned rear engine/s.
|
||||
* These engines need to be shut down in fw mode. During the back-transition
|
||||
* they need to idle otherwise they need too much time to spin up for mc mode.
|
||||
*/
|
||||
|
||||
vtol_mode _vtol_mode{vtol_mode::MC_MODE}; /**< vtol flight mode, defined by enum vtol_mode */
|
||||
|
||||
uORB::Publication<tiltrotor_extra_controls_s> _tiltrotor_extra_controls_pub{ORB_ID(tiltrotor_extra_controls)};
|
||||
|
||||
float _tilt_control{0.0f}; /**< actuator value for the tilt servo */
|
||||
|
||||
bool _front_transition_phase_2{false}; /**< rotors at VT_TILT_TRANS and tilting forward completely */
|
||||
|
||||
void parameters_update() override;
|
||||
float timeUntilMotorsAreUp();
|
||||
float moveLinear(float start, float stop, float progress);
|
||||
|
||||
void blendThrottleDuringBacktransition(const float scale, const float target_throttle);
|
||||
bool isFrontTransitionCompletedBase() override;
|
||||
bool isFrontTransitionCompleted() override;
|
||||
bool isBackTransitionCompleted() override;
|
||||
// switch to fixed-wing at once only while the rotors are still tilted forward enough for the wing. Once they are
|
||||
// coming back, restart the front transition from the current tilt instead of handing the fixed-wing controller
|
||||
// a vehicle with the rotors near vertical
|
||||
bool canSwitchToFixedWingDuringBackTransition() override { return _tilt_control >= _param_vt_tilt_trans.get(); }
|
||||
void onTransitionStart() override { _front_transition_phase_2 = false; }
|
||||
|
||||
|
||||
DEFINE_PARAMETERS_CUSTOM_PARENT(VtolType,
|
||||
|
||||
@@ -152,6 +152,103 @@ void VtolType::update_fw_state()
|
||||
check_quadchute_condition();
|
||||
}
|
||||
|
||||
void VtolType::update_vtol_state()
|
||||
{
|
||||
checkTypeSpecificQuadchute();
|
||||
|
||||
if (_attc->is_quadchute_active()) {
|
||||
// Failsafe event, engage mc motors immediately
|
||||
onQuadchute();
|
||||
_common_vtol_mode = mode::ROTARY_WING;
|
||||
|
||||
} else if (_attc->is_fixed_wing_requested()) {
|
||||
|
||||
switch (_common_vtol_mode) {
|
||||
case mode::ROTARY_WING:
|
||||
// start a front transition
|
||||
resetTransitionStates();
|
||||
onTransitionStart();
|
||||
_common_vtol_mode = mode::TRANSITION_TO_FW;
|
||||
break;
|
||||
|
||||
case mode::FIXED_WING:
|
||||
break;
|
||||
|
||||
case mode::TRANSITION_TO_FW:
|
||||
if (isFrontTransitionCompleted()) {
|
||||
_common_vtol_mode = mode::FIXED_WING;
|
||||
_trans_finished_ts = hrt_absolute_time();
|
||||
onFrontTransitionCompleted();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case mode::TRANSITION_TO_MC:
|
||||
|
||||
// fixed-wing requested again while the back transition is still running
|
||||
if (canSwitchToFixedWingDuringBackTransition()) {
|
||||
_common_vtol_mode = mode::FIXED_WING;
|
||||
_trans_finished_ts = hrt_absolute_time();
|
||||
|
||||
} else {
|
||||
// restart the front transition instead of switching to fixed-wing from a partially
|
||||
// completed back transition, which can result in an unsafe flying state
|
||||
resetTransitionStates();
|
||||
onTransitionStart();
|
||||
_common_vtol_mode = mode::TRANSITION_TO_FW;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
switch (_common_vtol_mode) {
|
||||
case mode::ROTARY_WING:
|
||||
break;
|
||||
|
||||
case mode::FIXED_WING:
|
||||
// regular back transition
|
||||
resetTransitionStates();
|
||||
onTransitionStart();
|
||||
_common_vtol_mode = mode::TRANSITION_TO_MC;
|
||||
break;
|
||||
|
||||
case mode::TRANSITION_TO_FW:
|
||||
// abort into hover
|
||||
onFrontTransitionAborted();
|
||||
_common_vtol_mode = mode::ROTARY_WING;
|
||||
break;
|
||||
|
||||
case mode::TRANSITION_TO_MC:
|
||||
if (isBackTransitionCompleted()) {
|
||||
_common_vtol_mode = mode::ROTARY_WING;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool VtolType::isBackTransitionSpeedOrTimeReached() const
|
||||
{
|
||||
// speed exit condition: use ground if valid, otherwise airspeed
|
||||
bool exit_backtransition_speed_condition = false;
|
||||
|
||||
if (_local_pos->v_xy_valid) {
|
||||
const Dcmf R_to_body(Quatf(_v_att->q).inversed());
|
||||
const Vector3f vel = R_to_body * Vector3f(_local_pos->vx, _local_pos->vy, _local_pos->vz);
|
||||
exit_backtransition_speed_condition = vel(0) < _param_mpc_xy_cruise.get();
|
||||
|
||||
} else if (PX4_ISFINITE(_attc->get_calibrated_airspeed())) {
|
||||
exit_backtransition_speed_condition = _attc->get_calibrated_airspeed() < _param_mpc_xy_cruise.get();
|
||||
}
|
||||
|
||||
const bool exit_backtransition_time_condition = _time_since_trans_start > _param_vt_b_trans_dur.get();
|
||||
|
||||
return exit_backtransition_speed_condition || exit_backtransition_time_condition;
|
||||
}
|
||||
|
||||
void VtolType::update_transition_state()
|
||||
{
|
||||
hrt_abstime t_now = hrt_absolute_time();
|
||||
@@ -167,14 +264,7 @@ void VtolType::update_transition_state()
|
||||
_last_thr_in_mc = _vehicle_thrust_setpoint_virtual_mc->xyz[2];
|
||||
}
|
||||
|
||||
bool VtolType::isFrontTransitionCompleted()
|
||||
{
|
||||
bool ret = isFrontTransitionCompletedBase();
|
||||
|
||||
return ret || can_transition_on_ground();
|
||||
}
|
||||
|
||||
bool VtolType::isFrontTransitionCompletedBase()
|
||||
bool VtolType::isFrontTransitionSpeedOrTimeReached() const
|
||||
{
|
||||
// continue the transition to fw mode while monitoring airspeed for a final switch to fw mode
|
||||
const bool airspeed_triggers_transition = PX4_ISFINITE(_attc->get_calibrated_airspeed());
|
||||
|
||||
@@ -113,9 +113,10 @@ public:
|
||||
bool init();
|
||||
|
||||
/**
|
||||
* Update vtol state.
|
||||
* Update vtol state. Runs the mode state machine common to all VTOL types,
|
||||
* type-specific behaviour is injected through the virtual hooks below.
|
||||
*/
|
||||
virtual void update_vtol_state() = 0;
|
||||
void update_vtol_state();
|
||||
|
||||
/**
|
||||
* Update transition state.
|
||||
@@ -322,8 +323,61 @@ protected:
|
||||
|
||||
bool _quadchute_command_treated{false};
|
||||
|
||||
bool isFrontTransitionCompleted();
|
||||
virtual bool isFrontTransitionCompletedBase();
|
||||
/**
|
||||
* @return true if the front transition is complete and the vehicle can switch to fixed-wing mode
|
||||
*/
|
||||
virtual bool isFrontTransitionCompleted() { return isFrontTransitionSpeedOrTimeReached() || can_transition_on_ground(); }
|
||||
|
||||
/**
|
||||
* @return true if the transition airspeed is reached after the minimum front transition time, or, without
|
||||
* airspeed, the open-loop front transition time has elapsed
|
||||
*/
|
||||
bool isFrontTransitionSpeedOrTimeReached() const;
|
||||
|
||||
/**
|
||||
* @return true if the back transition is complete and the vehicle can switch to hover mode
|
||||
*/
|
||||
virtual bool isBackTransitionCompleted() = 0;
|
||||
|
||||
/**
|
||||
* @return true if the vehicle is below the back transition exit speed (MPC_XY_CRUISE) or the back transition
|
||||
* has lasted longer than VT_B_TRANS_DUR
|
||||
*/
|
||||
bool isBackTransitionSpeedOrTimeReached() const;
|
||||
|
||||
/**
|
||||
* Called when fixed-wing is requested while a back transition is in progress.
|
||||
*
|
||||
* @return true to switch to fixed-wing mode immediately, false to restart the front transition
|
||||
*/
|
||||
virtual bool canSwitchToFixedWingDuringBackTransition() { return false; }
|
||||
|
||||
/**
|
||||
* Called when a front or back transition starts, after the transition timer states have been reset.
|
||||
*/
|
||||
virtual void onTransitionStart() {}
|
||||
|
||||
/**
|
||||
* Called on the switch from front transition to fixed-wing mode.
|
||||
*/
|
||||
virtual void onFrontTransitionCompleted() {}
|
||||
|
||||
/**
|
||||
* Called when a front transition is aborted into hover because fixed-wing is no longer requested.
|
||||
*/
|
||||
virtual void onFrontTransitionAborted() {}
|
||||
|
||||
/**
|
||||
* Called on every update while a quad-chute keeps the vehicle in hover, before the mode is set to hover.
|
||||
* The mode is not hover yet only on the update that switches.
|
||||
*/
|
||||
virtual void onQuadchute() {}
|
||||
|
||||
/**
|
||||
* Called at the start of every update, in every mode, before the quad-chute state is read.
|
||||
* A type requests a quad-chute here for a failure that only it can detect.
|
||||
*/
|
||||
virtual void checkTypeSpecificQuadchute() {}
|
||||
|
||||
float _local_position_z_start_of_transition{0.f}; // altitude at start of transition
|
||||
|
||||
|
||||
Reference in new issue
Block a user