@@ -195,23 +195,27 @@ inline models::Path toTensor(const nav_msgs::msg::Path & path)
195195 * @brief Check if the robot pose is within the Goal Checker's tolerances to goal
196196 * @param global_checker Pointer to the goal checker
197197 * @param robot Pose of robot
198- * @param goal Goal pose
198+ * @param path Path to retreive goal pose from
199199 * @return bool If robot is within goal checker tolerances to the goal
200200 */
201201inline bool withinPositionGoalTolerance (
202202 nav2_core::GoalChecker * goal_checker,
203203 const geometry_msgs::msg::Pose & robot,
204- const geometry_msgs::msg::Pose & goal )
204+ const models::Path & path )
205205{
206+ const auto goal_idx = path.x .shape (0 ) - 1 ;
207+ const auto goal_x = path.x (goal_idx);
208+ const auto goal_y = path.y (goal_idx);
209+
206210 if (goal_checker) {
207211 geometry_msgs::msg::Pose pose_tolerance;
208212 geometry_msgs::msg::Twist velocity_tolerance;
209213 goal_checker->getTolerances (pose_tolerance, velocity_tolerance);
210214
211215 const auto pose_tolerance_sq = pose_tolerance.position .x * pose_tolerance.position .x ;
212216
213- auto dx = robot.position .x - goal. position . x ;
214- auto dy = robot.position .y - goal. position . y ;
217+ auto dx = robot.position .x - goal_x ;
218+ auto dy = robot.position .y - goal_y ;
215219
216220 auto dist_sq = dx * dx + dy * dy;
217221
@@ -227,19 +231,24 @@ inline bool withinPositionGoalTolerance(
227231 * @brief Check if the robot pose is within tolerance to the goal
228232 * @param pose_tolerance Pose tolerance to use
229233 * @param robot Pose of robot
230- * @param goal Goal pose
234+ * @param path Path to retreive goal pose from
231235 * @return bool If robot is within tolerance to the goal
232236 */
233237inline bool withinPositionGoalTolerance (
234238 float pose_tolerance,
235239 const geometry_msgs::msg::Pose & robot,
236- const geometry_msgs::msg::Pose & goal )
240+ const models::Path & path )
237241{
238- const double & dist_sq =
239- std::pow (goal.position .x - robot.position .x , 2 ) +
240- std::pow (goal.position .y - robot.position .y , 2 );
242+ const auto goal_idx = path.x .shape (0 ) - 1 ;
243+ const auto goal_x = path.x (goal_idx);
244+ const auto goal_y = path.y (goal_idx);
245+
246+ const auto pose_tolerance_sq = pose_tolerance * pose_tolerance;
247+
248+ auto dx = robot.position .x - goal_x;
249+ auto dy = robot.position .y - goal_y;
241250
242- const float pose_tolerance_sq = pose_tolerance * pose_tolerance ;
251+ auto dist_sq = dx * dx + dy * dy ;
243252
244253 if (dist_sq < pose_tolerance_sq) {
245254 return true ;
0 commit comments