mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-30 06:53:33 +08:00
mc_pos_control: only update constraints if topic updated
- update failsafe constraints
This commit is contained in:
committed by
Matthias Grob
parent
39b0c7b2bf
commit
ac8f4e3c48
@@ -249,12 +249,14 @@ void MulticopterPositionControl::Run()
|
|||||||
_control.setState(_states);
|
_control.setState(_states);
|
||||||
|
|
||||||
vehicle_constraints_s constraints;
|
vehicle_constraints_s constraints;
|
||||||
_vehicle_constraints_sub.update(&constraints);
|
|
||||||
_control.setConstraints(constraints);
|
|
||||||
_control.setThrustLimits(constraints.minimum_thrust, _param_mpc_thr_max.get());
|
|
||||||
|
|
||||||
if (constraints.reset_integral) {
|
if (_vehicle_constraints_sub.update(&constraints)) {
|
||||||
_control.resetIntegral();
|
_control.setConstraints(constraints);
|
||||||
|
_control.setThrustLimits(constraints.minimum_thrust, _param_mpc_thr_max.get());
|
||||||
|
|
||||||
|
if (constraints.reset_integral) {
|
||||||
|
_control.resetIntegral();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run position control
|
// Run position control
|
||||||
@@ -269,8 +271,12 @@ void MulticopterPositionControl::Run()
|
|||||||
}
|
}
|
||||||
|
|
||||||
failsafe(time_stamp_now, setpoint, _states, !was_in_failsafe);
|
failsafe(time_stamp_now, setpoint, _states, !was_in_failsafe);
|
||||||
|
|
||||||
_control.setInputSetpoint(setpoint);
|
_control.setInputSetpoint(setpoint);
|
||||||
|
|
||||||
constraints = {0, NAN, NAN, NAN, NAN, NAN, NAN, NAN, false, {}};
|
constraints = {0, NAN, NAN, NAN, NAN, NAN, NAN, NAN, false, {}};
|
||||||
|
_control.setConstraints(constraints);
|
||||||
|
|
||||||
_control.update(dt);
|
_control.update(dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user