@@ -51,6 +51,20 @@ CoverageNavigator::configure(
5151
5252 // Odometry smoother object for getting current speed
5353 odom_smoother_ = odom_smoother;
54+
55+ // Groot monitoring
56+ if (!node->has_parameter (getName () + " .enable_groot_monitoring" )) {
57+ node->declare_parameter (getName () + " .enable_groot_monitoring" , false );
58+ }
59+
60+ if (!node->has_parameter (getName () + " .groot_server_port" )) {
61+ node->declare_parameter (getName () + " .groot_server_port" , 1667 );
62+ }
63+
64+ bt_action_server_->setGrootMonitoring (
65+ node->get_parameter (getName () + " .enable_groot_monitoring" ).as_bool (),
66+ node->get_parameter (getName () + " .groot_server_port" ).as_int ());
67+
5468 return true ;
5569}
5670
@@ -90,11 +104,12 @@ CoverageNavigator::goalReceived(ActionT::Goal::ConstSharedPtr goal)
90104 RCLCPP_ERROR (
91105 logger_, " BT file not found: %s. Navigation canceled." ,
92106 bt_xml_filename.c_str ());
107+ bt_action_server_->setInternalError (ActionT::Result::FAILED_TO_LOAD_BEHAVIOR_TREE,
108+ std::string (" Error loading XML file: " ) + bt_xml_filename + " . Navigation canceled." );
93109 return false ;
94110 }
95111
96- initializeGoalPose (goal);
97- return true ;
112+ return initializeGoalPose (goal);
98113}
99114
100115void
@@ -185,7 +200,13 @@ CoverageNavigator::onPreempt(ActionT::Goal::ConstSharedPtr goal)
185200 // if pending goal requests the same BT as the current goal, accept the pending goal
186201 // if pending goal has an empty behavior_tree field, it requests the default BT file
187202 // accept the pending goal if the current goal is running the default BT file
188- initializeGoalPose (bt_action_server_->acceptPendingGoal ());
203+ if (!initializeGoalPose (bt_action_server_->acceptPendingGoal ())) {
204+ RCLCPP_WARN (
205+ logger_,
206+ " Preemption request was rejected since the goal could not be "
207+ " initialized. For now, continuing to track the last goal until completion." );
208+ bt_action_server_->terminatePendingGoal ();
209+ }
189210 } else {
190211 RCLCPP_WARN (
191212 logger_,
@@ -198,14 +219,19 @@ CoverageNavigator::onPreempt(ActionT::Goal::ConstSharedPtr goal)
198219 }
199220}
200221
201- void
222+ bool
202223CoverageNavigator::initializeGoalPose (ActionT::Goal::ConstSharedPtr goal)
203224{
204225 geometry_msgs::msg::PoseStamped current_pose;
205- nav2_util::getCurrentPose (
206- current_pose, *feedback_utils_.tf ,
207- feedback_utils_.global_frame , feedback_utils_.robot_frame ,
208- feedback_utils_.transform_tolerance );
226+ if (!nav2_util::getCurrentPose (
227+ current_pose, *feedback_utils_.tf ,
228+ feedback_utils_.global_frame , feedback_utils_.robot_frame ,
229+ feedback_utils_.transform_tolerance ))
230+ {
231+ bt_action_server_->setInternalError (ActionT::Result::TF_ERROR,
232+ " Initial robot pose is not available." );
233+ return false ;
234+ }
209235
210236 if (goal->field_filepath .size () == 0 ) {
211237 RCLCPP_INFO (
@@ -227,6 +253,8 @@ CoverageNavigator::initializeGoalPose(ActionT::Goal::ConstSharedPtr goal)
227253 blackboard->set <std::vector<geometry_msgs::msg::Polygon>>(
228254 polygon_blackboard_id_, goal->polygons );
229255 blackboard->set <std::string>(polygon_frame_blackboard_id_, goal->frame_id );
256+
257+ return true ;
230258}
231259
232260} // namespace opennav_coverage_navigator
0 commit comments