mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-11 13:11:36 +08:00
Omni Pos-Ctrl: Reduced jerking when a large command is given in offboard
- OMNI_ATT_MODE = 2 uses OMNI_DFC_MAX_THR parameter to limit the horizontal commanded thrust now - Other modes are not affected
This commit is contained in:
@@ -89,7 +89,7 @@ bool PositionControl::setInputSetpoint(const vehicle_local_position_setpoint_s &
|
||||
return mapping_succeeded;
|
||||
}
|
||||
|
||||
void PositionControl::setConstraints(const vehicle_constraints_s &constraints)
|
||||
void PositionControl::setConstraints(const vehicle_constraints_s &constraints, const float lim_thr_hor_max)
|
||||
{
|
||||
_constraints = constraints;
|
||||
|
||||
@@ -107,6 +107,8 @@ void PositionControl::setConstraints(const vehicle_constraints_s &constraints)
|
||||
_constraints.speed_down = _lim_vel_down;
|
||||
}
|
||||
|
||||
_lim_thr_hor_max = lim_thr_hor_max;
|
||||
|
||||
// ignore _constraints.speed_xy TODO: remove it completely as soon as no task uses it anymore to avoid confusion
|
||||
}
|
||||
|
||||
@@ -321,6 +323,7 @@ void PositionControl::_velocityControl(const float dt)
|
||||
float thrust_max_NE_tilt = fabsf(_thr_sp(2)) * tanf(_constraints.tilt);
|
||||
float thrust_max_NE = sqrtf(_lim_thr_max * _lim_thr_max - _thr_sp(2) * _thr_sp(2));
|
||||
thrust_max_NE = math::min(thrust_max_NE_tilt, thrust_max_NE);
|
||||
thrust_max_NE = math::min(_lim_thr_hor_max, thrust_max_NE);
|
||||
|
||||
// Saturate thrust in NE-direction.
|
||||
_thr_sp(0) = thrust_desired_NE(0);
|
||||
|
||||
@@ -137,8 +137,9 @@ public:
|
||||
* Pass constraints that are stricter than the global limits
|
||||
* Note: NAN value means no constraint, take maximum limit of controller.
|
||||
* @param constraints a PositionControl structure with supported constraints
|
||||
* @param lim_thr_hor_max maximum horizontal thrust (read from parameter for OMNI_ATT_MODE = 2, otherwise = 1.0F)
|
||||
*/
|
||||
void setConstraints(const vehicle_constraints_s &constraints);
|
||||
void setConstraints(const vehicle_constraints_s &constraints, const float lim_thr_hor_max);
|
||||
|
||||
/**
|
||||
* Apply P-position and PID-velocity controller that updates the member
|
||||
@@ -207,6 +208,7 @@ private:
|
||||
float _lim_thr_min{}; ///< Minimum collective thrust allowed as output [-1,0] e.g. -0.9
|
||||
float _lim_thr_max{}; ///< Maximum collective thrust allowed as output [-1,0] e.g. -0.1
|
||||
float _lim_tilt{}; ///< Maximum tilt from level the output attitude is allowed to have
|
||||
float _lim_thr_hor_max; ///< Maximum direct-force horizontal thrust allowed as output [0, 1]
|
||||
|
||||
float _hover_thrust{}; ///< Thrust [0,1] with which the vehicle hovers not aacelerating down or up with level orientation
|
||||
|
||||
|
||||
@@ -647,7 +647,9 @@ MulticopterPositionControl::Run()
|
||||
|
||||
// Run position control
|
||||
_control.setState(_states);
|
||||
_control.setConstraints(constraints);
|
||||
|
||||
float max_hor_thrust = (_param_omni_att_mode.get() == 2) ? _param_omni_dfc_max_thr.get() : 1.0F;
|
||||
_control.setConstraints(constraints, max_hor_thrust);
|
||||
|
||||
if (!_control.setInputSetpoint(setpoint)) {
|
||||
warn_rate_limited("PositionControl: invalid setpoints");
|
||||
|
||||
Reference in New Issue
Block a user