Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4627d5d

Browse files
Dennis Mannhartdagar
Dennis Mannhart
authored andcommitted
mc_pos_control_main smooth takeoff: enable position-xy/yaw control once above 0.5m from takeoff reference
1 parent 345d327 commit 4627d5d

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

src/modules/mc_pos_control/mc_pos_control_main.cpp

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -676,21 +676,35 @@ MulticopterPositionControl::run()
676676
update_smooth_takeoff(setpoint.z, setpoint.vz);
677677
}
678678

679+
// disable horizontal / yaw control during smooth takeoff and limit maximum speed upwards
679680
if (_in_smooth_takeoff) {
681+
680682
// during smooth takeoff, constrain speed to takeoff speed
681683
constraints.speed_up = _takeoff_speed;
682-
// disable yaw command
683-
setpoint.yaw = setpoint.yawspeed = NAN;
684-
// don't control position in xy
685-
setpoint.x = setpoint.y = NAN;
686-
setpoint.vx = setpoint.vy = NAN;
687-
setpoint.thrust[0] = setpoint.thrust[1] = NAN;
688-
689-
if (PX4_ISFINITE(_states.velocity(0)) && PX4_ISFINITE(_states.velocity(1))) {
690-
setpoint.vx = setpoint.vy = 0.0f; // try to keep zero velocity
691-
692-
} else {
693-
setpoint.thrust[0] = setpoint.thrust[1] = 0.0f; // just keeping pointing upwards
684+
// altitude above reference takeoff
685+
const float alt_above_tko = -(_states.position(2) - _takeoff_reference_z);
686+
// altitude threshold at which full control is enabled
687+
const float alt_threshold = 0.5f; //at 0.5m above grouund, control all setpoints
688+
689+
// disable position-xy / yaw control when close to ground
690+
if (alt_above_tko <= alt_threshold) {
691+
// don't control position in xy
692+
setpoint.x = setpoint.y = NAN;
693+
setpoint.vx = setpoint.vy = NAN;
694+
setpoint.thrust[0] = setpoint.thrust[1] = NAN;
695+
setpoint.yaw = setpoint.yawspeed = NAN;
696+
697+
if (PX4_ISFINITE(_states.velocity(0)) && PX4_ISFINITE(_states.velocity(1))) {
698+
setpoint.vx = setpoint.vy = 0.0f; // try to keep zero velocity
699+
700+
} else {
701+
setpoint.thrust[0] = setpoint.thrust[1] = 0.0f; // just keeping pointing upwards
702+
}
703+
704+
// if there is a valid yaw estimate, just set setpoint to yaw
705+
if (PX4_ISFINITE(_states.yaw)) {
706+
setpoint.yaw = _states.yaw;
707+
}
694708
}
695709
}
696710

0 commit comments

Comments
 (0)