@ -2199,6 +2199,10 @@ void QuadPlane::vtol_position_controller(void)
@@ -2199,6 +2199,10 @@ void QuadPlane::vtol_position_controller(void)
poscontrol . last_run_ms = now_ms ;
}
// avoid running the z controller in approach and airbrake if we're not already running it
// and tilt is more than tilt max
bool suppress_z_controller = false ;
// horizontal position control
switch ( poscontrol . get_state ( ) ) {
@ -2231,6 +2235,20 @@ void QuadPlane::vtol_position_controller(void)
@@ -2231,6 +2235,20 @@ void QuadPlane::vtol_position_controller(void)
aspeed = groundspeed ;
}
if ( tiltrotor . enabled ( ) & & poscontrol . get_state ( ) = = QPOS_AIRBRAKE ) {
if ( ( now_ms - last_pidz_active_ms > 2000 & & tiltrotor . tilt_over_max_angle ( ) ) | |
tiltrotor . current_tilt > = tiltrotor . get_fully_forward_tilt ( ) ) {
// use low throttle stabilization when airbraking on a
// tiltrotor. We don't want quite zero throttle as we
// want some drag, but don't want to run the Z
// controller which can result in high throttle on
// motors that are tilted forward, thus increasing
// speed
suppress_z_controller = true ;
hold_stabilize ( 0.01 ) ;
}
}
// speed for crossover to POSITION1 controller
const float aspeed_threshold = MAX ( plane . aparm . airspeed_min - 2 , assist_speed ) ;
@ -2253,9 +2271,10 @@ void QuadPlane::vtol_position_controller(void)
@@ -2253,9 +2271,10 @@ void QuadPlane::vtol_position_controller(void)
const float stop_distance = stopping_distance ( ) ;
if ( poscontrol . get_state ( ) = = QPOS_AIRBRAKE & & ! ( tiltrotor . enabled ( ) & & ! tiltrotor . has_vtol_motor ( ) & & ( tiltrotor . current_tilt > = tiltrotor . get_fully_forward_tilt ( ) ) ) ) {
// don't ouput VTOL throttle on tiltrotors if there are no fixed VTOL motors and the tilt is still forward
if ( ! suppress_z_controller & & poscontrol . get_state ( ) = = QPOS_AIRBRAKE ) {
hold_hover ( 0 ) ;
// don't run Z controller again in this loop
suppress_z_controller = true ;
}
/*
@ -2428,8 +2447,9 @@ void QuadPlane::vtol_position_controller(void)
@@ -2428,8 +2447,9 @@ void QuadPlane::vtol_position_controller(void)
// if continuous tiltrotor only advance to position 2 once tilts have finished moving
poscontrol . set_state ( QPOS_POSITION2 ) ;
poscontrol . pilot_correction_done = false ;
gcs ( ) . send_text ( MAV_SEVERITY_INFO , " VTOL position2 started v=%.1f d=%.1f " ,
( double ) ahrs . groundspeed ( ) , ( double ) plane . auto_state . wp_distance ) ;
gcs ( ) . send_text ( MAV_SEVERITY_INFO , " VTOL position2 started v=%.1f d=%.1f h=%.1f " ,
( double ) ahrs . groundspeed ( ) , ( double ) plane . auto_state . wp_distance ,
plane . relative_ground_altitude ( plane . g . rangefinder_landing ) ) ;
}
break ;
}
@ -2601,8 +2621,14 @@ void QuadPlane::vtol_position_controller(void)
@@ -2601,8 +2621,14 @@ void QuadPlane::vtol_position_controller(void)
case QPOS_LAND_COMPLETE :
break ;
}
run_z_controller ( ) ;
/*
run the z controller unless something has already run it or set a target throttle
*/
if ( ! suppress_z_controller ) {
// otherwise run z controller
run_z_controller ( ) ;
}
if ( now_ms - poscontrol . last_log_ms > = 40 ) {
// log poscontrol at 25Hz