Skip to content

Commit 01d8c3d

Browse files
nidhishrajsfuhrer
authored andcommitted
vtol_att_control: occasional tailsitter forward transition failure issue solved
Tailsitter VTOLs very occasionally gets stuck with zero roll and pitch angle in multicopter mode after a forward transition command is issued. This very rare behavior is triggered by the following events: 1> a forward transition is triggered either in auto or manual mode. 2> in the vtol_att_control main loop, if multicopter and fixed wing attitude setpoints are not updated, transition state is not updated 3> the commander changes the vehicle status to transition mode. 4> multicopter pos controller initiated Transition flight task. This results in zero roll and pitch setpoint due to zero acceleration setpoint 5> now vtol_att_control executes and updates the transition state. Specifically, _q_trans_start and _q_trans_sp are set with zero roll and pitch sp 6> tilt is evaluated to be NaN, despite _q_trans_sp being normalized. This happens for 25% of all yaw angles when using float datatype. This can be verified using the matrix library 7> once tilt is evaluated to be NaN, _q_trans_sp is never updated again and is stuck in this state for ever. This has been fixed by constraining the cos(tilt) within +1 to -1 range Further, _q_trans_start and _q_trans_sp are immedietly initialized after a transition event is triggered.
1 parent b30f391 commit 01d8c3d

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/modules/vtol_att_control/tailsitter.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,11 @@ void Tailsitter::update_transition_state()
225225
_q_trans_sp.normalize();
226226

227227
// tilt angle (zero if vehicle nose points up (hover))
228-
const float tilt = acosf(_q_trans_sp(0) * _q_trans_sp(0) - _q_trans_sp(1) * _q_trans_sp(1) - _q_trans_sp(2) *
229-
_q_trans_sp(2) + _q_trans_sp(3) * _q_trans_sp(3));
228+
float cos_tilt = _q_trans_sp(0) * _q_trans_sp(0) - _q_trans_sp(1) * _q_trans_sp(1) - _q_trans_sp(2) *
229+
_q_trans_sp(2) + _q_trans_sp(3) * _q_trans_sp(3);
230+
cos_tilt = cos_tilt > 1.0f ? 1.0f : cos_tilt;
231+
cos_tilt = cos_tilt < -1.0f ? -1.0f : cos_tilt;
232+
const float tilt = acosf(cos_tilt);
230233

231234
if (_vtol_schedule.flight_mode == vtol_mode::TRANSITION_FRONT_P1) {
232235

src/modules/vtol_att_control/vtol_att_control_main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ VtolAttitudeControl::Run()
424424

425425
_fw_virtual_att_sp_sub.update(&_fw_virtual_att_sp);
426426

427-
if (mc_att_sp_updated || fw_att_sp_updated) {
427+
if (!_vtol_type->was_in_trans_mode() || mc_att_sp_updated || fw_att_sp_updated) {
428428
_vtol_type->update_transition_state();
429429
_v_att_sp_pub.publish(_v_att_sp);
430430
}

src/modules/vtol_att_control/vtol_type.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ class VtolType
190190

191191
mode get_mode() {return _vtol_mode;}
192192

193+
bool was_in_trans_mode() {return _flag_was_in_trans_mode;}
194+
193195
virtual void parameters_update() = 0;
194196

195197
protected:

0 commit comments

Comments
 (0)