@@ -76,6 +76,8 @@ void RegulatedPurePursuitController::configure(
7676 carrot_pub_ = node->create_publisher <geometry_msgs::msg::PointStamped>(" lookahead_point" , 1 );
7777 curvature_carrot_pub_ = node->create_publisher <geometry_msgs::msg::PointStamped>(
7878 " curvature_lookahead_point" , 1 );
79+ is_rotating_to_heading_pub_ = node->create_publisher <std_msgs::msg::Bool>(
80+ " is_rotating_to_heading" , 1 );
7981}
8082
8183void RegulatedPurePursuitController::cleanup ()
@@ -88,6 +90,7 @@ void RegulatedPurePursuitController::cleanup()
8890 global_path_pub_.reset ();
8991 carrot_pub_.reset ();
9092 curvature_carrot_pub_.reset ();
93+ is_rotating_to_heading_pub_.reset ();
9194}
9295
9396void RegulatedPurePursuitController::activate ()
@@ -100,6 +103,7 @@ void RegulatedPurePursuitController::activate()
100103 global_path_pub_->on_activate ();
101104 carrot_pub_->on_activate ();
102105 curvature_carrot_pub_->on_activate ();
106+ is_rotating_to_heading_pub_->on_activate ();
103107}
104108
105109void RegulatedPurePursuitController::deactivate ()
@@ -112,6 +116,7 @@ void RegulatedPurePursuitController::deactivate()
112116 global_path_pub_->on_deactivate ();
113117 carrot_pub_->on_deactivate ();
114118 curvature_carrot_pub_->on_deactivate ();
119+ is_rotating_to_heading_pub_->on_deactivate ();
115120}
116121
117122std::unique_ptr<geometry_msgs::msg::PointStamped> RegulatedPurePursuitController::createCarrotMsg (
@@ -228,11 +233,14 @@ geometry_msgs::msg::TwistStamped RegulatedPurePursuitController::computeVelocity
228233 // - otherwise equal to curvature_lookahead_pose (which can be interpolated after goal)
229234 double angle_to_heading;
230235 if (shouldRotateToGoalHeading (carrot_pose)) {
236+ is_rotating_to_heading_ = true ;
231237 double angle_to_goal = tf2::getYaw (transformed_plan.poses .back ().pose .orientation );
232238 rotateToHeading (linear_vel, angular_vel, angle_to_goal, speed);
233239 } else if (shouldRotateToPath (rotate_to_path_carrot_pose, angle_to_heading, x_vel_sign)) {
240+ is_rotating_to_heading_ = true ;
234241 rotateToHeading (linear_vel, angular_vel, angle_to_heading, speed);
235242 } else {
243+ is_rotating_to_heading_ = false ;
236244 applyConstraints (
237245 regulation_curvature, speed,
238246 collision_checker_->costAtPose (pose.pose .position .x , pose.pose .position .y ), transformed_plan,
@@ -267,6 +275,11 @@ geometry_msgs::msg::TwistStamped RegulatedPurePursuitController::computeVelocity
267275 throw nav2_core::NoValidControl (" RegulatedPurePursuitController detected collision ahead!" );
268276 }
269277
278+ // Publish whether we are rotating to goal heading
279+ std_msgs::msg::Bool is_rotating_to_heading_msg;
280+ is_rotating_to_heading_msg.data = is_rotating_to_heading_;
281+ is_rotating_to_heading_pub_->publish (is_rotating_to_heading_msg);
282+
270283 // populate and return message
271284 geometry_msgs::msg::TwistStamped cmd_vel;
272285 cmd_vel.header = pose.header ;
0 commit comments