@@ -107,42 +107,31 @@ class GracefulController : public nav2_core::Controller
107107 void setSpeedLimit (const double & speed_limit, const bool & percentage) override ;
108108
109109protected:
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>>
0 commit comments