@@ -195,27 +195,23 @@ 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 path Path to retreive goal pose from
198+ * @param goal Goal pose
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 models::Path & path )
204+ const geometry_msgs::msg::Pose & goal )
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-
210206 if (goal_checker) {
211207 geometry_msgs::msg::Pose pose_tolerance;
212208 geometry_msgs::msg::Twist velocity_tolerance;
213209 goal_checker->getTolerances (pose_tolerance, velocity_tolerance);
214210
215211 const auto pose_tolerance_sq = pose_tolerance.position .x * pose_tolerance.position .x ;
216212
217- auto dx = robot.position .x - goal_x ;
218- auto dy = robot.position .y - goal_y ;
213+ auto dx = robot.position .x - goal. position . x ;
214+ auto dy = robot.position .y - goal. position . y ;
219215
220216 auto dist_sq = dx * dx + dy * dy;
221217
@@ -231,24 +227,19 @@ inline bool withinPositionGoalTolerance(
231227 * @brief Check if the robot pose is within tolerance to the goal
232228 * @param pose_tolerance Pose tolerance to use
233229 * @param robot Pose of robot
234- * @param path Path to retreive goal pose from
230+ * @param goal Goal pose
235231 * @return bool If robot is within tolerance to the goal
236232 */
237233inline bool withinPositionGoalTolerance (
238234 float pose_tolerance,
239235 const geometry_msgs::msg::Pose & robot,
240- const models::Path & path )
236+ const geometry_msgs::msg::Pose & goal )
241237{
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;
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 );
250241
251- auto dist_sq = dx * dx + dy * dy ;
242+ const float pose_tolerance_sq = pose_tolerance * pose_tolerance ;
252243
253244 if (dist_sq < pose_tolerance_sq) {
254245 return true ;
0 commit comments