Skip to content

Commit

Permalink
mc_pos_control: max deceleration as default
Browse files Browse the repository at this point in the history
  • Loading branch information
Stifael committed Mar 27, 2017
1 parent e73eec7 commit 2da9fd6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
26 changes: 16 additions & 10 deletions src/modules/mc_pos_control/mc_pos_control_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1372,20 +1372,26 @@ MulticopterPositionControl::vel_sp_slewrate(float dt)
matrix::Vector2f vel_xy(_vel(0), _vel(1));
matrix::Vector2f acc_xy = (vel_sp_xy - vel_sp_prev_xy) / dt;

float acc_limit = _acceleration_hor_max.get();
/* as default we use max deceleration as acc limit */
float acc_limit = _deceleration_hor_max.get();

/* deceleration but no direction change and not position control*/
bool slow_deceleration = ((acc_xy * vel_xy) < 0.0f) && ((vel_sp_xy * vel_xy) > 0.0f) && !_run_pos_control;
if (_control_mode.flag_control_manual_enabled) {
/* default for manual */
acc_limit = _acceleration_hor_max.get();

/* deceleration with direction change and not position control*/
bool fast_deceleration = ((acc_xy * vel_xy) < 0.0f) && ((vel_sp_xy * vel_xy) <= 0.0f) && !_run_pos_control;
/* deceleration but no direction change and not position control*/
bool slow_deceleration = ((acc_xy * vel_xy) < 0.0f) && ((vel_sp_xy * vel_xy) > 0.0f) && !_run_pos_control;

if (slow_deceleration) {
acc_limit = _deceleration_hor_slow.get();
}
/* deceleration with direction change and not position control*/
bool fast_deceleration = ((acc_xy * vel_xy) < 0.0f) && ((vel_sp_xy * vel_xy) <= 0.0f) && !_run_pos_control;

if (fast_deceleration) {
acc_limit = _deceleration_hor_max.get();
if (slow_deceleration) {
acc_limit = _deceleration_hor_slow.get();
}

if (fast_deceleration) {
acc_limit = _deceleration_hor_max.get();
}
}

/* limit total horizontal acceleration */
Expand Down
7 changes: 4 additions & 3 deletions src/modules/mc_pos_control/mc_pos_control_params.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ PARAM_DEFINE_FLOAT(MPC_HOLD_MAX_Z, 0.6f);
PARAM_DEFINE_FLOAT(MPC_VELD_LP, 5.0f);

/**
* Maximum horizonal acceleration in velocity controlled modes
* Maximum horizonal manual acceleration in velocity controlled modes
*
* @unit m/s/s
* @min 2.0
Expand All @@ -435,7 +435,8 @@ PARAM_DEFINE_FLOAT(MPC_VELD_LP, 5.0f);
PARAM_DEFINE_FLOAT(MPC_ACC_HOR_MAX, 5.0f);

/**
* Maximum horizontal braking deceleration in velocity controlled modes
* Maximum horizontal manual braking deceleration in velocity controlled modes
* Maximum acceleration for non-manual control modes
*
* @unit m/s/s
* @min 2.0
Expand All @@ -447,7 +448,7 @@ PARAM_DEFINE_FLOAT(MPC_ACC_HOR_MAX, 5.0f);
PARAM_DEFINE_FLOAT(MPC_DEC_HOR_MAX, 10.0f);

/**
* Slow horizontal braking deceleration in velocity controlled modes
* Slow horizontal manual braking deceleration in velocity controlled modes
*
* @unit m/s/s
* @min 0.5
Expand Down

0 comments on commit 2da9fd6

Please sign in to comment.