mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-01 23:11:37 +08:00
Parameter update - Rename variables in lib
using paramter_update.py script
This commit is contained in:
@@ -46,8 +46,8 @@ ManualSmoothingXY::ManualSmoothingXY(ModuleParams *parent, const Vector2f &vel)
|
||||
ModuleParams(parent), _vel_sp_prev(vel)
|
||||
|
||||
{
|
||||
_acc_state_dependent = _acc_xy_max.get();
|
||||
_jerk_state_dependent = _jerk_max.get();
|
||||
_acc_state_dependent = _param_mpc_acc_hor.get();
|
||||
_jerk_state_dependent = _param_mpc_jerk_max.get();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -134,17 +134,17 @@ ManualSmoothingXY::_setStateAcceleration(const Vector2f &vel_sp, const Vector2f
|
||||
} else if (intention != _intention) {
|
||||
// start the brake with lowest acceleration which
|
||||
// makes stopping smoother
|
||||
_acc_state_dependent = _dec_xy_min.get();
|
||||
_acc_state_dependent = _param_mpc_dec_hor_slow.get();
|
||||
|
||||
// Adjust jerk based on current velocity. This ensures
|
||||
// that the vehicle will stop much quicker at large speed but
|
||||
// very slow at low speed.
|
||||
_jerk_state_dependent = 1e6f; // default
|
||||
|
||||
if (_jerk_max.get() > _jerk_min.get() && _jerk_min.get() > FLT_EPSILON) {
|
||||
if (_param_mpc_jerk_max.get() > _param_mpc_jerk_min.get() && _param_mpc_jerk_min.get() > FLT_EPSILON) {
|
||||
|
||||
_jerk_state_dependent = math::min((_jerk_max.get() - _jerk_min.get())
|
||||
/ _vel_max * vel.length() + _jerk_min.get(), _jerk_max.get());
|
||||
_jerk_state_dependent = math::min((_param_mpc_jerk_max.get() - _param_mpc_jerk_min.get())
|
||||
/ _vel_max * vel.length() + _param_mpc_jerk_min.get(), _param_mpc_jerk_max.get());
|
||||
}
|
||||
|
||||
// User wants to brake smoothly but does NOT want the vehicle to
|
||||
@@ -154,14 +154,14 @@ ManualSmoothingXY::_setStateAcceleration(const Vector2f &vel_sp, const Vector2f
|
||||
}
|
||||
|
||||
/* limit jerk when braking to zero */
|
||||
float jerk = (_acc_hover.get() - _acc_state_dependent) / dt;
|
||||
float jerk = (_param_mpc_acc_hor_max.get() - _acc_state_dependent) / dt;
|
||||
|
||||
if (jerk > _jerk_state_dependent) {
|
||||
_acc_state_dependent = _jerk_state_dependent * dt
|
||||
+ _acc_state_dependent;
|
||||
|
||||
} else {
|
||||
_acc_state_dependent = _acc_hover.get();
|
||||
_acc_state_dependent = _param_mpc_acc_hor_max.get();
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -174,19 +174,19 @@ ManualSmoothingXY::_setStateAcceleration(const Vector2f &vel_sp, const Vector2f
|
||||
// Because previous setpoint is equal to current setpoint,
|
||||
// slewrate will have no effect. Nonetheless, just set
|
||||
// acceleration to maximum.
|
||||
_acc_state_dependent = _acc_hover.get();
|
||||
_acc_state_dependent = _param_mpc_acc_hor_max.get();
|
||||
break;
|
||||
}
|
||||
|
||||
case Intention::acceleration: {
|
||||
// Limit acceleration linearly based on velocity setpoint.
|
||||
_acc_state_dependent = (_acc_xy_max.get() - _dec_xy_min.get())
|
||||
/ _vel_max * vel_sp.length() + _dec_xy_min.get();
|
||||
_acc_state_dependent = (_param_mpc_acc_hor.get() - _param_mpc_dec_hor_slow.get())
|
||||
/ _vel_max * vel_sp.length() + _param_mpc_dec_hor_slow.get();
|
||||
break;
|
||||
}
|
||||
|
||||
case Intention::deceleration: {
|
||||
_acc_state_dependent = _dec_xy_min.get();
|
||||
_acc_state_dependent = _param_mpc_dec_hor_slow.get();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,11 +97,11 @@ public:
|
||||
* Overwrite methods:
|
||||
* Needed if different parameter values than default required.
|
||||
*/
|
||||
void overwriteHoverAcceleration(float acc) { _acc_hover.set(acc); }
|
||||
void overwriteMaxAcceleration(float acc) { _acc_xy_max.set(acc); }
|
||||
void overwriteDecelerationMin(float dec) { _dec_xy_min.set(dec); }
|
||||
void overwriteJerkMax(float jerk) { _jerk_max.set(jerk); }
|
||||
void overwriteJerkMin(float jerk) { _jerk_min.set(jerk); }
|
||||
void overwriteHoverAcceleration(float acc) { _param_mpc_acc_hor_max.set(acc); }
|
||||
void overwriteMaxAcceleration(float acc) { _param_mpc_acc_hor.set(acc); }
|
||||
void overwriteDecelerationMin(float dec) { _param_mpc_dec_hor_slow.set(dec); }
|
||||
void overwriteJerkMax(float jerk) { _param_mpc_jerk_max.set(jerk); }
|
||||
void overwriteJerkMin(float jerk) { _param_mpc_jerk_min.set(jerk); }
|
||||
|
||||
private:
|
||||
/**
|
||||
@@ -165,11 +165,11 @@ private:
|
||||
matrix::Vector2f _vel_sp_prev; /**< previous velocity setpoint */
|
||||
|
||||
DEFINE_PARAMETERS(
|
||||
(ParamFloat<px4::params::MPC_ACC_HOR_MAX>) _acc_hover, /**< acceleration in hover */
|
||||
(ParamFloat<px4::params::MPC_ACC_HOR>) _acc_xy_max, /**< acceleration in flight */
|
||||
(ParamFloat<px4::params::MPC_DEC_HOR_SLOW>) _dec_xy_min, /**< deceleration in flight */
|
||||
(ParamFloat<px4::params::MPC_JERK_MIN>) _jerk_min, /**< jerk min during brake */
|
||||
(ParamFloat<px4::params::MPC_JERK_MAX>) _jerk_max, /**< jerk max during brake */
|
||||
(ParamFloat<px4::params::MPC_VEL_MANUAL>) _vel_manual /**< maximum velocity in manual controlled mode */
|
||||
(ParamFloat<px4::params::MPC_ACC_HOR_MAX>) _param_mpc_acc_hor_max, /**< acceleration in hover */
|
||||
(ParamFloat<px4::params::MPC_ACC_HOR>) _param_mpc_acc_hor, /**< acceleration in flight */
|
||||
(ParamFloat<px4::params::MPC_DEC_HOR_SLOW>) _param_mpc_dec_hor_slow, /**< deceleration in flight */
|
||||
(ParamFloat<px4::params::MPC_JERK_MIN>) _param_mpc_jerk_min, /**< jerk min during brake */
|
||||
(ParamFloat<px4::params::MPC_JERK_MAX>) _param_mpc_jerk_max, /**< jerk max during brake */
|
||||
(ParamFloat<px4::params::MPC_VEL_MANUAL>) _param_mpc_vel_manual /**< maximum velocity in manual controlled mode */
|
||||
)
|
||||
};
|
||||
|
||||
@@ -43,8 +43,8 @@ ManualSmoothingZ::ManualSmoothingZ(ModuleParams *parent, const float &vel, const
|
||||
ModuleParams(parent),
|
||||
_vel(vel), _stick(stick), _vel_sp_prev(vel)
|
||||
{
|
||||
_acc_state_dependent = _acc_max_up.get();
|
||||
_max_acceleration = _acc_max_up.get();
|
||||
_acc_state_dependent = _param_mpc_acc_up_max.get();
|
||||
_max_acceleration = _param_mpc_acc_up_max.get();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -77,7 +77,7 @@ ManualSmoothingZ::updateAcceleration(float &vel_sp, const float dt)
|
||||
if ((_intention != ManualIntentionZ::brake) && (intention == ManualIntentionZ::brake)) {
|
||||
|
||||
// we start with lowest acceleration
|
||||
_acc_state_dependent = _acc_max_down.get();
|
||||
_acc_state_dependent = _param_mpc_acc_down_max.get();
|
||||
|
||||
// reset slew-rate: this ensures that there
|
||||
// is no delay present when user demands to brake
|
||||
@@ -89,13 +89,13 @@ ManualSmoothingZ::updateAcceleration(float &vel_sp, const float dt)
|
||||
case ManualIntentionZ::brake: {
|
||||
|
||||
// limit jerk when braking to zero
|
||||
float jerk = (_acc_max_up.get() - _acc_state_dependent) / dt;
|
||||
float jerk = (_param_mpc_acc_up_max.get() - _acc_state_dependent) / dt;
|
||||
|
||||
if (jerk > _jerk_max.get()) {
|
||||
_acc_state_dependent = _jerk_max.get() * dt + _acc_state_dependent;
|
||||
if (jerk > _param_mpc_jerk_max.get()) {
|
||||
_acc_state_dependent = _param_mpc_jerk_max.get() * dt + _acc_state_dependent;
|
||||
|
||||
} else {
|
||||
_acc_state_dependent = _acc_max_up.get();
|
||||
_acc_state_dependent = _param_mpc_acc_up_max.get();
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -103,8 +103,8 @@ ManualSmoothingZ::updateAcceleration(float &vel_sp, const float dt)
|
||||
|
||||
case ManualIntentionZ::acceleration: {
|
||||
|
||||
_acc_state_dependent = (getMaxAcceleration() - _acc_max_down.get())
|
||||
* fabsf(_stick) + _acc_max_down.get();
|
||||
_acc_state_dependent = (getMaxAcceleration() - _param_mpc_acc_down_max.get())
|
||||
* fabsf(_stick) + _param_mpc_acc_down_max.get();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -117,26 +117,26 @@ ManualSmoothingZ::setMaxAcceleration()
|
||||
{
|
||||
if (_stick < -FLT_EPSILON) {
|
||||
// accelerating upward
|
||||
_max_acceleration = _acc_max_up.get();
|
||||
_max_acceleration = _param_mpc_acc_up_max.get();
|
||||
|
||||
} else if (_stick > FLT_EPSILON) {
|
||||
// accelerating downward
|
||||
_max_acceleration = _acc_max_down.get();
|
||||
_max_acceleration = _param_mpc_acc_down_max.get();
|
||||
|
||||
} else {
|
||||
|
||||
// want to brake
|
||||
if (fabsf(_vel_sp_prev) < FLT_EPSILON) {
|
||||
// at rest
|
||||
_max_acceleration = _acc_max_up.get();
|
||||
_max_acceleration = _param_mpc_acc_up_max.get();
|
||||
|
||||
} else if (_vel_sp_prev < 0.0f) {
|
||||
// braking downward
|
||||
_max_acceleration = _acc_max_down.get();
|
||||
_max_acceleration = _param_mpc_acc_down_max.get();
|
||||
|
||||
} else {
|
||||
// braking upward
|
||||
_max_acceleration = _acc_max_up.get();
|
||||
_max_acceleration = _param_mpc_acc_up_max.get();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,9 +82,9 @@ public:
|
||||
* Overwrite methods:
|
||||
* Needed if different parameter values than default required.
|
||||
*/
|
||||
void overwriteAccelerationUp(float acc_max_up) { _acc_max_up.set(acc_max_up); }
|
||||
void overwriteAccelerationDown(float acc_max_down) {_acc_max_down.set(acc_max_down); }
|
||||
void overwriteJerkMax(float jerk_max) {_jerk_max.set(jerk_max); }
|
||||
void overwriteAccelerationUp(float acc_max_up) { _param_mpc_acc_up_max.set(acc_max_up); }
|
||||
void overwriteAccelerationDown(float acc_max_down) {_param_mpc_acc_down_max.set(acc_max_down); }
|
||||
void overwriteJerkMax(float jerk_max) {_param_mpc_jerk_max.set(jerk_max); }
|
||||
|
||||
private:
|
||||
/**
|
||||
@@ -126,8 +126,8 @@ private:
|
||||
float _vel_sp_prev; /**< previous velocity setpoint */
|
||||
|
||||
DEFINE_PARAMETERS(
|
||||
(ParamFloat<px4::params::MPC_ACC_UP_MAX>) _acc_max_up,
|
||||
(ParamFloat<px4::params::MPC_ACC_DOWN_MAX>) _acc_max_down,
|
||||
(ParamFloat<px4::params::MPC_JERK_MAX>) _jerk_max
|
||||
(ParamFloat<px4::params::MPC_ACC_UP_MAX>) _param_mpc_acc_up_max,
|
||||
(ParamFloat<px4::params::MPC_ACC_DOWN_MAX>) _param_mpc_acc_down_max,
|
||||
(ParamFloat<px4::params::MPC_JERK_MAX>) _param_mpc_jerk_max
|
||||
)
|
||||
};
|
||||
|
||||
@@ -56,7 +56,7 @@ void StraightLine::generateSetpoints(matrix::Vector3f &position_setpoint, matrix
|
||||
{
|
||||
// Check if target position has been reached
|
||||
if (_desired_speed_at_target < VEL_ZERO_THRESHOLD &&
|
||||
(_pos - _target).length() < NAV_ACC_RAD.get()) {
|
||||
(_pos - _target).length() < _param_nav_acc_rad.get()) {
|
||||
// Vehicle has reached target. Lock position
|
||||
position_setpoint = _target;
|
||||
velocity_setpoint = Vector3f(0.0f, 0.0f, 0.0f);
|
||||
@@ -107,7 +107,7 @@ float StraightLine::getMaxAcc()
|
||||
{
|
||||
// check if origin and target are different points
|
||||
if ((_target - _origin).length() < FLT_EPSILON) {
|
||||
return MPC_ACC_HOR_MAX.get();
|
||||
return _param_mpc_acc_hor_max.get();
|
||||
}
|
||||
|
||||
// unit vector in the direction of the straight line
|
||||
@@ -115,7 +115,7 @@ float StraightLine::getMaxAcc()
|
||||
|
||||
// calculate the maximal horizontal acceleration
|
||||
float divider = Vector2f(u_orig_to_target).length();
|
||||
float max_acc_hor = MPC_ACC_HOR_MAX.get();
|
||||
float max_acc_hor = _param_mpc_acc_hor_max.get();
|
||||
|
||||
if (divider > FLT_EPSILON) {
|
||||
max_acc_hor /= divider;
|
||||
@@ -125,7 +125,7 @@ float StraightLine::getMaxAcc()
|
||||
}
|
||||
|
||||
// calculate the maximal vertical acceleration
|
||||
float max_acc_vert_original = u_orig_to_target(2) < 0 ? MPC_ACC_UP_MAX.get() : MPC_ACC_DOWN_MAX.get();
|
||||
float max_acc_vert_original = u_orig_to_target(2) < 0 ? _param_mpc_acc_up_max.get() : _param_mpc_acc_down_max.get();
|
||||
float max_acc_vert = max_acc_vert_original;
|
||||
|
||||
if (fabs(u_orig_to_target(2)) > FLT_EPSILON) {
|
||||
@@ -142,7 +142,7 @@ float StraightLine::getMaxVel()
|
||||
{
|
||||
// check if origin and target are different points
|
||||
if ((_target - _origin).length() < FLT_EPSILON) {
|
||||
return MPC_XY_VEL_MAX.get();
|
||||
return _param_mpc_xy_vel_max.get();
|
||||
}
|
||||
|
||||
// unit vector in the direction of the straight line
|
||||
@@ -150,7 +150,7 @@ float StraightLine::getMaxVel()
|
||||
|
||||
// calculate the maximal horizontal velocity
|
||||
float divider = Vector2f(u_orig_to_target).length();
|
||||
float max_vel_hor = MPC_XY_VEL_MAX.get();
|
||||
float max_vel_hor = _param_mpc_xy_vel_max.get();
|
||||
|
||||
if (divider > FLT_EPSILON) {
|
||||
max_vel_hor /= divider;
|
||||
@@ -160,7 +160,8 @@ float StraightLine::getMaxVel()
|
||||
}
|
||||
|
||||
// calculate the maximal vertical velocity
|
||||
float max_vel_vert_directional = u_orig_to_target(2) < 0 ? MPC_Z_VEL_MAX_UP.get() : MPC_Z_VEL_MAX_DN.get();
|
||||
float max_vel_vert_directional = u_orig_to_target(2) < 0 ? _param_mpc_z_vel_max_up.get() :
|
||||
_param_mpc_z_vel_max_dn.get();
|
||||
float max_vel_vert = max_vel_vert_directional;
|
||||
|
||||
if (fabs(u_orig_to_target(2)) > FLT_EPSILON) {
|
||||
|
||||
@@ -96,13 +96,13 @@ private:
|
||||
|
||||
// parameters for default values
|
||||
DEFINE_PARAMETERS(
|
||||
(ParamFloat<px4::params::MPC_ACC_HOR_MAX>) MPC_ACC_HOR_MAX, /**< maximum horizontal acceleration */
|
||||
(ParamFloat<px4::params::MPC_ACC_UP_MAX>) MPC_ACC_UP_MAX, /**< maximum vertical acceleration upwards */
|
||||
(ParamFloat<px4::params::MPC_ACC_DOWN_MAX>) MPC_ACC_DOWN_MAX, /**< maximum vertical acceleration downwards*/
|
||||
(ParamFloat<px4::params::MPC_XY_VEL_MAX>) MPC_XY_VEL_MAX, /**< maximum horizontal velocity */
|
||||
(ParamFloat<px4::params::MPC_Z_VEL_MAX_UP>) MPC_Z_VEL_MAX_UP, /**< maximum vertical velocity upwards */
|
||||
(ParamFloat<px4::params::MPC_Z_VEL_MAX_DN>) MPC_Z_VEL_MAX_DN, /**< maximum vertical velocity downwards */
|
||||
(ParamFloat<px4::params::NAV_ACC_RAD>) NAV_ACC_RAD /**< acceptance radius if a waypoint is reached */
|
||||
(ParamFloat<px4::params::MPC_ACC_HOR_MAX>) _param_mpc_acc_hor_max, /**< maximum horizontal acceleration */
|
||||
(ParamFloat<px4::params::MPC_ACC_UP_MAX>) _param_mpc_acc_up_max, /**< maximum vertical acceleration upwards */
|
||||
(ParamFloat<px4::params::MPC_ACC_DOWN_MAX>) _param_mpc_acc_down_max, /**< maximum vertical acceleration downwards*/
|
||||
(ParamFloat<px4::params::MPC_XY_VEL_MAX>) _param_mpc_xy_vel_max, /**< maximum horizontal velocity */
|
||||
(ParamFloat<px4::params::MPC_Z_VEL_MAX_UP>) _param_mpc_z_vel_max_up, /**< maximum vertical velocity upwards */
|
||||
(ParamFloat<px4::params::MPC_Z_VEL_MAX_DN>) _param_mpc_z_vel_max_dn, /**< maximum vertical velocity downwards */
|
||||
(ParamFloat<px4::params::NAV_ACC_RAD>) _param_nav_acc_rad /**< acceptance radius if a waypoint is reached */
|
||||
)
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user