@@ -68,6 +68,14 @@ class BasicAPIRPP : public nav2_regulated_pure_pursuit_controller::RegulatedPure
6868 return circleSegmentIntersection (p1, p2, r);
6969 }
7070
71+ geometry_msgs::msg::PoseStamped
72+ projectCarrotPastGoalWrapper (
73+ const double & dist,
74+ const nav_msgs::msg::Path & path)
75+ {
76+ return projectCarrotPastGoal (dist, path);
77+ }
78+
7179 geometry_msgs::msg::PoseStamped getLookAheadPointWrapper (
7280 const double & dist, const nav_msgs::msg::Path & path)
7381 {
@@ -466,6 +474,30 @@ INSTANTIATE_TEST_SUITE_P(
466474}
467475));
468476
477+ TEST (RegulatedPurePursuitTest, projectCarrotPastGoal) {
478+ auto ctrl = std::make_shared<BasicAPIRPP>();
479+ auto node = std::make_shared<rclcpp_lifecycle::LifecycleNode>(" testRPP" );
480+ std::string name = " PathFollower" ;
481+ auto tf = std::make_shared<tf2_ros::Buffer>(node->get_clock ());
482+ auto costmap =
483+ std::make_shared<nav2_costmap_2d::Costmap2DROS>(" fake_costmap" );
484+ rclcpp_lifecycle::State state;
485+ costmap->on_configure (state);
486+ ctrl->configure (node, name, tf, costmap);
487+
488+ nav_msgs::msg::Path path;
489+ path.poses .resize (1 );
490+ path.poses [0 ].pose .position .x = 1.0 ;
491+ // For a path with a single pose the carrot should be directly in line
492+ // This avoids turning
493+ auto pt = ctrl->projectCarrotPastGoalWrapper (10.0 , path);
494+ EXPECT_EQ (pt.pose .position .x , 10.0 );
495+
496+ path.poses [0 ].pose .position .x = -1.0 ;
497+ pt = ctrl->projectCarrotPastGoalWrapper (10.0 , path);
498+ EXPECT_EQ (pt.pose .position .x , -10.0 );
499+ }
500+
469501TEST (RegulatedPurePursuitTest, lookaheadAPI)
470502{
471503 auto ctrl = std::make_shared<BasicAPIRPP>();
0 commit comments