Plane: split out the tailsitter transition complete code

use both roll and pitch to trigger completion of transition. This
copes with situations where the plane has managed to get itself rolled
over far enough that it can't recover into hover
This commit is contained in:
Andrew Tridgell 2017-02-12 20:58:00 +11:00
parent d5a3f844f1
commit e8b11924f8
3 changed files with 21 additions and 1 deletions

View File

@ -1043,7 +1043,7 @@ void QuadPlane::update_transition(void)
if (is_tailsitter()) {
if (transition_state == TRANSITION_ANGLE_WAIT &&
(ahrs_view->pitch_sensor < -tailsitter.transition_angle*100 || plane.fly_inverted())) {
tailsitter_transition_complete()) {
GCS_MAVLINK::send_statustext_all(MAV_SEVERITY_INFO, "Transition done");
transition_state = TRANSITION_DONE;
}

View File

@ -83,6 +83,9 @@ public:
// create outputs for tailsitters
void tailsitter_output(void);
// check if we have completed transition
bool tailsitter_transition_complete(void);
struct PACKED log_QControl_Tuning {
LOG_PACKET_HEADER;

View File

@ -44,3 +44,20 @@ void QuadPlane::tailsitter_output(void)
}
}
/*
return true when we have completed enough of a transition to switch to fixed wing control
*/
bool QuadPlane::tailsitter_transition_complete(void)
{
if (plane.fly_inverted()) {
// transition immediately
return true;
}
if (ahrs_view->pitch_sensor < -tailsitter.transition_angle*100 ||
ahrs_view->roll_sensor < -tailsitter.transition_angle*100) {
return true;
}
// still waiting
return false;
}