locusrobotics/robot_navigation

Acceleration limit for backward driving

Closed this issue · 1 comments

Thazz commented

When applying acceleration/deceleration limits in velocity iterator, one should be looking for difference in velocity magnitude (absolute value).

inline double projectVelocity(double v0, double accel, double decel, double dt, double target)
{
double v1;
if (v0 < target)
{
v1 = v0 + accel * dt;
return std::min(target, v1);
}
else
{
v1 = v0 + decel * dt;
return std::max(target, v1);
}
}

Currently, If the robot is driving backwards and its velocity changes from e.g v0 = -1 m/s to target = -1.5 m/s, deceleration limit is used (as v0 > target), although robot is actually accelerating. The same goes for deceleration.

I can provide PR if needed.

DLu commented

Makes sense! Please make a PR.