15 #include "geometry_msgs/msg/pose_stamped.hpp"
16 #include "nav2_util/geometry_utils.hpp"
17 #include "nav2_graceful_controller/ego_polar_coords.hpp"
18 #include "nav2_graceful_controller/smooth_control_law.hpp"
20 namespace nav2_graceful_controller
24 double k_phi,
double k_delta,
double beta,
double lambda,
double slowdown_radius,
25 double v_linear_min,
double v_linear_max,
double v_angular_max)
26 : k_phi_(k_phi), k_delta_(k_delta), beta_(beta), lambda_(lambda), slowdown_radius_(slowdown_radius),
27 v_linear_min_(v_linear_min), v_linear_max_(v_linear_max), v_angular_max_(v_angular_max)
32 double k_phi,
double k_delta,
double beta,
double lambda)
46 const double v_linear_min,
const double v_linear_max,
const double v_angular_max)
54 const geometry_msgs::msg::Pose & target,
const geometry_msgs::msg::Pose & current,
55 const bool & backward)
62 curvature = backward ? -curvature : curvature;
76 v = backward ? -v : v;
79 double w = curvature * v;
83 v = (curvature != 0.0) ? (w_bound / curvature) : v;
86 geometry_msgs::msg::Twist cmd_vel;
88 cmd_vel.angular.z = w_bound;
93 const geometry_msgs::msg::Pose & target,
const bool & backward)
100 const geometry_msgs::msg::Pose & target,
101 const geometry_msgs::msg::Pose & current,
102 const bool & backward)
105 geometry_msgs::msg::Pose next;
106 double yaw = tf2::getYaw(current.orientation);
107 next.position.x = current.position.x + vel.linear.x * dt * cos(yaw);
108 next.position.y = current.position.y + vel.linear.x * dt * sin(yaw);
109 yaw += vel.angular.z * dt;
110 next.orientation = nav2_util::geometry_utils::orientationAroundZAxis(yaw);
120 double feedback_term = (1.0 + (
k_phi_ / (1.0 + std::pow(
k_phi_ * phi, 2)))) * sin(delta);
122 return -1.0 / r * (prop_term + feedback_term);
void setCurvatureConstants(const double k_phi, const double k_delta, const double beta, const double lambda)
Set the values that define the curvature.
double calculateCurvature(double r, double phi, double delta)
Calculate the path curvature using a Lyapunov-based feedback control law from "A smooth control law f...
geometry_msgs::msg::Twist calculateRegularVelocity(const geometry_msgs::msg::Pose &target, const geometry_msgs::msg::Pose ¤t, const bool &backward=false)
Compute linear and angular velocities command using the curvature.
double k_phi_
Ratio of the rate of change in phi to the rate of change in r. Controls the convergence of the slow s...
void setSpeedLimit(const double v_linear_min, const double v_linear_max, const double v_angular_max)
Update the velocity limits.
double v_linear_min_
Minimum linear velocity.
geometry_msgs::msg::Pose calculateNextPose(const double dt, const geometry_msgs::msg::Pose &target, const geometry_msgs::msg::Pose ¤t, const bool &backward=false)
Calculate the next pose of the robot by generating a velocity command using the curvature and the cur...
double v_linear_max_
Maximum linear velocity.
SmoothControlLaw(double k_phi, double k_delta, double beta, double lambda, double slowdown_radius, double v_linear_min, double v_linear_max, double v_angular_max)
Constructor for nav2_graceful_controller::SmoothControlLaw.
void setSlowdownRadius(const double slowdown_radius)
Set the slowdown radius.
double beta_
Constant factor applied to the path curvature. This value must be positive. Determines how fast the v...
double k_delta_
Constant factor applied to the heading error feedback. Controls the convergence of the fast subsystem...
double slowdown_radius_
Radial threshold applied to the slowdown rule.
double lambda_
Constant factor applied to the path curvature. This value must be greater or equal to 1....
double v_angular_max_
Maximum angular velocity.
Egocentric polar coordinates defined as the difference between the robot pose and the target pose rel...