-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[Graceful Controller] Add deceleration limit #5511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
9c29521
fce731d
a243818
c9396b4
aac6f73
c74360a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,9 +21,11 @@ namespace nav2_graceful_controller | |
{ | ||
|
||
SmoothControlLaw::SmoothControlLaw( | ||
double k_phi, double k_delta, double beta, double lambda, double slowdown_radius, | ||
double k_phi, double k_delta, double beta, double lambda, | ||
double slowdown_radius, double deceleration_max, | ||
double v_linear_min, double v_linear_max, double v_angular_max) | ||
: k_phi_(k_phi), k_delta_(k_delta), beta_(beta), lambda_(lambda), slowdown_radius_(slowdown_radius), | ||
: k_phi_(k_phi), k_delta_(k_delta), beta_(beta), lambda_(lambda), | ||
slowdown_radius_(slowdown_radius), deceleration_max_(deceleration_max), | ||
v_linear_min_(v_linear_min), v_linear_max_(v_linear_max), v_angular_max_(v_angular_max) | ||
{ | ||
} | ||
|
@@ -42,6 +44,11 @@ void SmoothControlLaw::setSlowdownRadius(double slowdown_radius) | |
slowdown_radius_ = slowdown_radius; | ||
} | ||
|
||
void SmoothControlLaw::setMaxDeceleration(double deceleration_max) | ||
{ | ||
deceleration_max_ = deceleration_max; | ||
} | ||
|
||
void SmoothControlLaw::setSpeedLimit( | ||
const double v_linear_min, const double v_linear_max, const double v_angular_max) | ||
{ | ||
|
@@ -52,7 +59,7 @@ void SmoothControlLaw::setSpeedLimit( | |
|
||
geometry_msgs::msg::Twist SmoothControlLaw::calculateRegularVelocity( | ||
const geometry_msgs::msg::Pose & target, const geometry_msgs::msg::Pose & current, | ||
const bool & backward) | ||
const double & target_distance, const bool & backward) | ||
{ | ||
// Convert the target to polar coordinates | ||
auto ego_coords = EgocentricPolarCoordinates(target, current, backward); | ||
|
@@ -66,7 +73,10 @@ geometry_msgs::msg::Twist SmoothControlLaw::calculateRegularVelocity( | |
double v = v_linear_max_ / (1.0 + beta_ * std::pow(fabs(curvature), lambda_)); | ||
|
||
// Slowdown when the robot is near the target to remove singularity | ||
v = std::min(v_linear_max_ * (ego_coords.r / slowdown_radius_), v); | ||
v = std::min(v_linear_max_ * (target_distance / slowdown_radius_), v); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why change from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
// Constraint robot velocity within deceleration limits | ||
v = std::min(sqrt(2 * target_distance * deceleration_max_), v); | ||
|
||
// Set some small v_min when far away from origin to promote faster | ||
// turning motion when the curvature is very high | ||
|
@@ -92,16 +102,20 @@ geometry_msgs::msg::Twist SmoothControlLaw::calculateRegularVelocity( | |
geometry_msgs::msg::Twist SmoothControlLaw::calculateRegularVelocity( | ||
const geometry_msgs::msg::Pose & target, const bool & backward) | ||
{ | ||
return calculateRegularVelocity(target, geometry_msgs::msg::Pose(), backward); | ||
geometry_msgs::msg::Pose current_pose = geometry_msgs::msg::Pose(); | ||
double target_distance = nav2_util::geometry_utils::euclidean_distance(target, current_pose); | ||
return calculateRegularVelocity(target, current_pose, target_distance, backward); | ||
} | ||
|
||
geometry_msgs::msg::Pose SmoothControlLaw::calculateNextPose( | ||
const double dt, | ||
const geometry_msgs::msg::Pose & target, | ||
const geometry_msgs::msg::Pose & current, | ||
const double & target_distance, | ||
const bool & backward) | ||
{ | ||
geometry_msgs::msg::Twist vel = calculateRegularVelocity(target, current, backward); | ||
geometry_msgs::msg::Twist vel = calculateRegularVelocity(target, current, target_distance, | ||
backward); | ||
geometry_msgs::msg::Pose next; | ||
double yaw = tf2::getYaw(current.orientation); | ||
next.position.x = current.position.x + vel.linear.x * dt * cos(yaw); | ||
|
Uh oh!
There was an error while loading. Please reload this page.