Skip to content

Commit 55ae011

Browse files
committed
CollisionPrevention: Added Case where velocity gets reduced to zero if we are closer to the obstacle than the minimal distance
1 parent ec1efcc commit 55ae011

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Diff for: src/lib/collision_prevention/CollisionPrevention.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -604,8 +604,15 @@ void CollisionPrevention::_getVelocityCompensationAcceleration(const float vehic
604604

605605
const float max_vel = math::trajectory::computeMaxSpeedFromDistance(_param_mpc_jerk_max.get(),
606606
_param_mpc_acc_hor.get(), stop_distance, 0.f);
607-
// we dont take the minimum of the last term because of stop_distance is zero but current velocity is not, we want the acceleration to become negative and slow us down.
608-
const float curr_acc_vel_constraint = _param_mpc_xy_vel_p_acc.get() * (max_vel - curr_vel_parallel);
607+
608+
float curr_acc_vel_constraint;
609+
610+
if (stop_distance >= 0.f) {
611+
curr_acc_vel_constraint = _param_mpc_xy_vel_p_acc.get() * math::min((max_vel - curr_vel_parallel), 0.f);
612+
613+
} else {
614+
curr_acc_vel_constraint = -1.f * _param_mpc_xy_vel_p_acc.get() * curr_vel_parallel;
615+
}
609616

610617
if (curr_acc_vel_constraint < vel_comp_accel) {
611618
vel_comp_accel = curr_acc_vel_constraint;

0 commit comments

Comments
 (0)