Negative linear velocity in twist_cmd
Closed this issue · 1 comments
Want to check if this is a bug.
While car runs stable around the lap, the linear velocity in twist_cmd is around 11.11.
After some time of car driving around the lap, the twist_cmd starts generating negative values for linear.x. This causes unstable car crashes.
OutputTwist in pure_pursuit_core.cpp has following code,
double max_v = g_lateral_accel_limit / omega;
double a = v * omega;
ROS_INFO("lateral accel = %lf", a);
twist.twist.linear.x = fabs(a) > g_lateral_accel_limit ? max_v
: v;
twist.twist.angular.z = omega;
return twist;
Here lateral accel goes above 5, and if max_v is negative, linear.x is negative.
Since omega can be negative, max_v can also be negative.
I changed max_v definition to
double max_v = fabs(g_lateral_accel_limit / omega);
Then the twist_cmd outputs positive values of linear.x, and car doesnt crash.
Omega is angular velocity which depends on curvature. If curvature can be negative (if car moves in clockwise or anticlockwise curves), then omega can be negative?
twist.angular.z = current_velocity_.twist.linear.x * curvature;
So the question is should we use fabs in the max_v definition above?
Hi @harishbalasub,
We suggest you refer to the Knowledge hub and reach out to your assigned mentor for user-specific issues.
Thanks