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

Skip to content

Commit 511563d

Browse files
Dennis Mannhartdagar
Dennis Mannhart
authored andcommitted
mc_pos_control: enable control in xy during smooth-takeoff from ground but limit tilt
1 parent 3329d69 commit 511563d

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

src/modules/mc_pos_control/mc_pos_control_main.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ class MulticopterPositionControl : public ModuleBase<MulticopterPositionControl>
139139
(ParamInt<px4::params::MPC_POS_MODE>) MPC_POS_MODE,
140140
(ParamInt<px4::params::MPC_ALT_MODE>) MPC_ALT_MODE,
141141
(ParamFloat<px4::params::MPC_IDLE_TKO>) MPC_IDLE_TKO, /**< time constant for smooth takeoff ramp */
142-
(ParamInt<px4::params::MPC_OBS_AVOID>) MPC_OBS_AVOID /**< enable obstacle avoidance */
142+
(ParamInt<px4::params::MPC_OBS_AVOID>) MPC_OBS_AVOID, /**< enable obstacle avoidance */
143+
(ParamFloat<px4::params::MPC_TILTMAX_LND>) MPC_TILTMAX_LND /**< maximum tilt for landing and smooth takeoff */
143144
);
144145

145146
control::BlockDerivative _vel_x_deriv; /**< velocity derivative in x */
@@ -684,25 +685,18 @@ MulticopterPositionControl::run()
684685
// altitude above reference takeoff
685686
const float alt_above_tko = -(_states.position(2) - _takeoff_reference_z);
686687

687-
// disable position-xy / yaw control when close to ground
688+
// disable yaw control when close to ground
688689
if (alt_above_tko <= ALTITUDE_THRESHOLD) {
689-
// don't control position in xy
690-
setpoint.x = setpoint.y = NAN;
691-
setpoint.vx = setpoint.vy = NAN;
692-
setpoint.thrust[0] = setpoint.thrust[1] = NAN;
693-
setpoint.yaw = setpoint.yawspeed = NAN;
694690

695-
if (PX4_ISFINITE(_states.velocity(0)) && PX4_ISFINITE(_states.velocity(1))) {
696-
setpoint.vx = setpoint.vy = 0.0f; // try to keep zero velocity
697-
698-
} else {
699-
setpoint.thrust[0] = setpoint.thrust[1] = 0.0f; // just keeping pointing upwards
700-
}
691+
setpoint.yawspeed = NAN;
701692

702693
// if there is a valid yaw estimate, just set setpoint to yaw
703694
if (PX4_ISFINITE(_states.yaw)) {
704695
setpoint.yaw = _states.yaw;
705696
}
697+
698+
// limit tilt during smooth takeoff when still close to ground
699+
constraints.tilt = math::radians(MPC_TILTMAX_LND.get());
706700
}
707701
}
708702

0 commit comments

Comments
 (0)