ManualSmoothingXY: brake with large default jerk max

This commit is contained in:
Dennis Mannhart
2018-04-05 07:30:12 +02:00
committed by Beat Küng
parent 25c33d18b0
commit 59bddf339a
@@ -166,8 +166,14 @@ ManualSmoothingXY::_getStateAcceleration(const matrix::Vector2f &vel_sp, const m
switch (intention) { switch (intention) {
case Intention::brake: { case Intention::brake: {
/* First iteration where user demands brake */ if (_intention == Intention::direction_change) {
if (intention != _intention) { /* Vehicle switched from direciton change to brake.
* Don't do any slwerate but rather just stop.
*/
_jerk_state_dependent = 1e6f;
_vel_sp_prev = vel;
} else if (intention != _intention) {
/* we start braking with lowest acceleration /* we start braking with lowest acceleration
* This make stopping smoother. */ * This make stopping smoother. */
_acc_state_dependent = _dec_xy_min; _acc_state_dependent = _dec_xy_min;
@@ -176,12 +182,12 @@ ManualSmoothingXY::_getStateAcceleration(const matrix::Vector2f &vel_sp, const m
* that the vehicle will stop much quicker at large speed but * that the vehicle will stop much quicker at large speed but
* very slow at low speed. * very slow at low speed.
*/ */
_jerk_state_dependent = _jerk_max; // default _jerk_state_dependent = 1e6f; // default
if (_jerk_max > _jerk_min) { if (_jerk_max > _jerk_min) {
_jerk_state_dependent = (_jerk_max - _jerk_min) _jerk_state_dependent = math::min((_jerk_max - _jerk_min)
/ _vel_manual * vel.length() + _jerk_min; / _vel_manual * vel.length() + _jerk_min, _jerk_max);
} }
/* Since user wants to brake smoothly but NOT continuing to fly /* Since user wants to brake smoothly but NOT continuing to fly