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

Skip to content

Commit a9f0981

Browse files
MaEtUgRLorenzMeier
authored andcommitted
mc_pos_control: fix adjusting the wrong setpoint
There are two local_position_setpoint in the position controller. One describing the setpoint the task gives to the position controller and a second one with the output of the position controller. I corrected the wrong one during takeoff because the new takeoff thrust ramp runs after the controller and not before.
1 parent ad6eb19 commit a9f0981

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/modules/mc_pos_control/mc_pos_control_main.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -675,21 +675,20 @@ MulticopterPositionControl::run()
675675
_takeoff.updateTakeoffState(_control_mode.flag_armed, _vehicle_land_detected.landed, constraints.want_takeoff, local_pos_sp.thrust[2], !_control_mode.flag_control_climb_rate_enabled);
676676
local_pos_sp.thrust[2] = _takeoff.updateThrustRamp(local_pos_sp.thrust[2], _dt);
677677

678-
if (_takeoff.getTakeoffState() < TakeoffState::flight) {
679-
// we set thrust to zero, this will help to decide if we are actually landed or not
680-
setpoint.thrust[0] = setpoint.thrust[1] = 0.0f;
678+
if (_takeoff.getTakeoffState() < TakeoffState::flight && !PX4_ISFINITE(setpoint.thrust[2])) {
679+
// we are not flying yet and need to avoid any corrections
680+
// set the horizontal thrust to zero
681+
local_pos_sp.thrust[0] = local_pos_sp.thrust[1] = 0.0f;
681682
// set yaw-sp to current yaw to avoid any corrections
682-
setpoint.yaw = _states.yaw;
683-
setpoint.yawspeed = 0.f;
683+
// TODO: we need a clean way to disable yaw control
684+
local_pos_sp.yaw = _states.yaw;
685+
local_pos_sp.yawspeed = 0.f;
684686
// prevent any integrator windup
685687
_control.resetIntegralXY();
686688
_control.resetIntegralZ();
687689
}
688690

689691
if (_takeoff.getTakeoffState() < TakeoffState::rampup && !PX4_ISFINITE(setpoint.thrust[2])) {
690-
// Keep throttle low when landed and NOT in smooth takeoff
691-
setpoint.thrust[0] = setpoint.thrust[1] = setpoint.thrust[2] = 0.0f;
692-
setpoint.yaw = _states.yaw;
693692
// reactivate the task which will reset the setpoint to current state
694693
_flight_tasks.reActivate();
695694
}

0 commit comments

Comments
 (0)