Skip to content

Commit 7b73a38

Browse files
authored
graceful_controller: implement iterative selection of control points (#4795)
* initial pass at iterative Signed-off-by: Michael Ferguson <[email protected]> * add v_angular_min_in_place Signed-off-by: Michael Ferguson <[email protected]> * add orientation filter, fix remaining TODOs Signed-off-by: Michael Ferguson <[email protected]> * try to increase coverage, fixup minor test issues Signed-off-by: Michael Ferguson <[email protected]> * address review comments Signed-off-by: Michael Ferguson <[email protected]> * review comments * update defaults * rename to in_place_collision_resolution Signed-off-by: Michael Ferguson <[email protected]> * revert change in default Signed-off-by: Michael Ferguson <[email protected]> --------- Signed-off-by: Michael Ferguson <[email protected]>
1 parent 017ffa0 commit 7b73a38

File tree

5 files changed

+268
-215
lines changed

5 files changed

+268
-215
lines changed

nav2_graceful_controller/include/nav2_graceful_controller/graceful_controller.hpp

+23-16
Original file line numberDiff line numberDiff line change
@@ -107,42 +107,31 @@ class GracefulController : public nav2_core::Controller
107107
void setSpeedLimit(const double & speed_limit, const bool & percentage) override;
108108

109109
protected:
110-
/**
111-
* @brief Get motion target point.
112-
* @param motion_target_dist Optimal motion target distance
113-
* @param path Current global path
114-
* @return Motion target point
115-
*/
116-
geometry_msgs::msg::PoseStamped getMotionTarget(
117-
const double & motion_target_dist,
118-
const nav_msgs::msg::Path & path);
119-
120110
/**
121111
* @brief Simulate trajectory calculating in every step the new velocity command based on
122112
* a new curvature value and checking for collisions.
123113
*
124-
* @param robot_pose Robot pose
125-
* @param motion_target Motion target point
114+
* @param motion_target Motion target point (in costmap local frame?)
126115
* @param costmap_transform Transform between global and local costmap
127116
* @param trajectory Simulated trajectory
117+
* @param cmd_vel Initial command velocity during simulation
128118
* @param backward Flag to indicate if the robot is moving backward
129119
* @return true if the trajectory is collision free, false otherwise
130120
*/
131121
bool simulateTrajectory(
132-
const geometry_msgs::msg::PoseStamped & robot_pose,
133122
const geometry_msgs::msg::PoseStamped & motion_target,
134123
const geometry_msgs::msg::TransformStamped & costmap_transform,
135124
nav_msgs::msg::Path & trajectory,
136-
const bool & backward);
125+
geometry_msgs::msg::TwistStamped & cmd_vel,
126+
bool backward);
137127

138128
/**
139129
* @brief Rotate the robot to face the motion target with maximum angular velocity.
140130
*
141131
* @param angle_to_target Angle to the motion target
142132
* @return geometry_msgs::msg::Twist Velocity command
143133
*/
144-
geometry_msgs::msg::Twist rotateToTarget(
145-
const double & angle_to_target);
134+
geometry_msgs::msg::Twist rotateToTarget(double angle_to_target);
146135

147136
/**
148137
* @brief Checks if the robot is in collision
@@ -153,6 +142,21 @@ class GracefulController : public nav2_core::Controller
153142
*/
154143
bool inCollision(const double & x, const double & y, const double & theta);
155144

145+
/**
146+
* @brief Compute the distance to each pose in a path
147+
* @param poses Poses to compute distances with
148+
* @param distances Computed distances
149+
*/
150+
void computeDistanceAlongPath(
151+
const std::vector<geometry_msgs::msg::PoseStamped> & poses,
152+
std::vector<double> & distances);
153+
154+
/**
155+
* @brief Control law requires proper orientations, not all planners provide them
156+
* @param path Path to add orientations into, if required
157+
*/
158+
void validateOrientations(std::vector<geometry_msgs::msg::PoseStamped> & path);
159+
156160
std::shared_ptr<tf2_ros::Buffer> tf_buffer_;
157161
std::string plugin_name_;
158162
std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros_;
@@ -164,6 +168,9 @@ class GracefulController : public nav2_core::Controller
164168
double goal_dist_tolerance_;
165169
bool goal_reached_;
166170

171+
// True from the time a new path arrives until we have completed an initial rotation
172+
bool do_initial_rotation_;
173+
167174
std::shared_ptr<rclcpp_lifecycle::LifecyclePublisher<nav_msgs::msg::Path>> transformed_plan_pub_;
168175
std::shared_ptr<rclcpp_lifecycle::LifecyclePublisher<nav_msgs::msg::Path>> local_plan_pub_;
169176
std::shared_ptr<rclcpp_lifecycle::LifecyclePublisher<geometry_msgs::msg::PointStamped>>

nav2_graceful_controller/include/nav2_graceful_controller/parameter_handler.hpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ namespace nav2_graceful_controller
3333
struct Parameters
3434
{
3535
double transform_tolerance;
36-
double motion_target_dist;
36+
double min_lookahead;
37+
double max_lookahead;
3738
double max_robot_pose_search_dist;
3839
double k_phi;
3940
double k_delta;
@@ -44,12 +45,14 @@ struct Parameters
4445
double v_linear_max_initial;
4546
double v_angular_max;
4647
double v_angular_max_initial;
48+
double v_angular_min_in_place;
4749
double slowdown_radius;
4850
bool initial_rotation;
49-
double initial_rotation_min_angle;
50-
bool final_rotation;
51+
double initial_rotation_tolerance;
52+
bool prefer_final_rotation;
5153
double rotation_scaling_factor;
5254
bool allow_backward;
55+
double in_place_collision_resolution;
5356
};
5457

5558
/**

0 commit comments

Comments
 (0)