From 6c730ccfec51d1b2403ee722f09913e712dba215 Mon Sep 17 00:00:00 2001 From: Henry Wurzburg Date: Thu, 9 Apr 2020 08:54:33 -0500 Subject: [PATCH] Plane: start tailsitter forward transition from current pitch angle --- ArduPlane/quadplane.cpp | 6 +++++- ArduPlane/quadplane.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ArduPlane/quadplane.cpp b/ArduPlane/quadplane.cpp index 26acbe7a7a..03d1756c48 100644 --- a/ArduPlane/quadplane.cpp +++ b/ArduPlane/quadplane.cpp @@ -1702,7 +1702,10 @@ void QuadPlane::update_transition(void) // in half the transition time float transition_rate = tailsitter.transition_angle / float(transition_time_ms/2); uint32_t dt = now - transition_start_ms; - plane.nav_pitch_cd = constrain_float((-transition_rate * dt)*100, -8500, 0); + float pitch_cd; + pitch_cd = constrain_float((-transition_rate * dt)*100, -8500, 0); + // if already pitched forward at start of transition, wait until curve catches up + plane.nav_pitch_cd = (pitch_cd > transition_initial_pitch)? transition_initial_pitch : pitch_cd; plane.nav_roll_cd = 0; check_attitude_relax(); attitude_control->input_euler_angle_roll_pitch_euler_rate_yaw(plane.nav_roll_cd, @@ -1816,6 +1819,7 @@ void QuadPlane::update(void) */ transition_state = TRANSITION_ANGLE_WAIT_FW; transition_start_ms = now; + transition_initial_pitch= constrain_float(ahrs_view->pitch_sensor,-8500,0); } else { /* setup for airspeed wait for later diff --git a/ArduPlane/quadplane.h b/ArduPlane/quadplane.h index c283da4b5a..63baaba0ad 100644 --- a/ArduPlane/quadplane.h +++ b/ArduPlane/quadplane.h @@ -347,6 +347,7 @@ private: // timer start for transition uint32_t transition_start_ms; + float transition_initial_pitch; uint32_t transition_low_airspeed_ms; Location last_auto_target;