@@ -364,11 +364,13 @@ void PlannerServer::computePlanThroughPoses()
364364
365365 auto start_time = steady_clock_.now ();
366366
367- // Initialize the ComputePathToPose goal and result
367+ // Initialize the ComputePathThroughPoses goal and result
368368 auto goal = action_server_poses_->get_current_goal ();
369369 auto result = std::make_shared<ActionThroughPoses::Result>();
370370 nav_msgs::msg::Path concat_path;
371371
372+ geometry_msgs::msg::PoseStamped curr_start, curr_goal;
373+
372374 try {
373375 if (isServerInactive (action_server_poses_) || isCancelRequested (action_server_poses_)) {
374376 return ;
@@ -378,11 +380,8 @@ void PlannerServer::computePlanThroughPoses()
378380
379381 getPreemptedGoalIfRequested (action_server_poses_, goal);
380382
381- if (goal->goals .size () == 0 ) {
382- RCLCPP_WARN (
383- get_logger (),
384- " Compute path through poses requested a plan with no viapoint poses, returning." );
385- action_server_poses_->terminate_current ();
383+ if (goal->goals .empty ()) {
384+ throw nav2_core::NoViapointsGiven (" No viapoints given" );
386385 }
387386
388387 // Use start pose if provided otherwise use current robot pose
@@ -392,8 +391,6 @@ void PlannerServer::computePlanThroughPoses()
392391 }
393392
394393 // Get consecutive paths through these points
395- std::vector<geometry_msgs::msg::PoseStamped>::iterator goal_iter;
396- geometry_msgs::msg::PoseStamped curr_start, curr_goal;
397394 for (unsigned int i = 0 ; i != goal->goals .size (); i++) {
398395 // Get starting point
399396 if (i == 0 ) {
@@ -436,13 +433,42 @@ void PlannerServer::computePlanThroughPoses()
436433 }
437434
438435 action_server_poses_->succeeded_current (result);
436+ } catch (nav2_core::StartOccupied & ex) {
437+ exceptionWarning (curr_start, curr_goal, goal->planner_id , ex);
438+ result->error_code = ActionThroughPosesGoal::START_OCCUPIED;
439+ action_server_poses_->terminate_current (result);
440+ } catch (nav2_core::GoalOccupied & ex) {
441+ exceptionWarning (curr_start, curr_goal, goal->planner_id , ex);
442+ result->error_code = ActionThroughPosesGoal::GOAL_OCCUPIED;
443+ action_server_poses_->terminate_current (result);
444+ } catch (nav2_core::NoValidPathCouldBeFound & ex) {
445+ exceptionWarning (curr_start, curr_goal, goal->planner_id , ex);
446+ result->error_code = ActionThroughPosesGoal::NO_VALID_PATH;
447+ action_server_poses_->terminate_current (result);
448+ } catch (nav2_core::PlannerTimedOut & ex) {
449+ exceptionWarning (curr_start, curr_goal, goal->planner_id , ex);
450+ result->error_code = ActionThroughPosesGoal::TIMEOUT;
451+ action_server_poses_->terminate_current (result);
452+ } catch (nav2_core::StartOutsideMapBounds & ex) {
453+ exceptionWarning (curr_start, curr_goal, goal->planner_id , ex);
454+ result->error_code = ActionThroughPosesGoal::START_OUTSIDE_MAP;
455+ action_server_poses_->terminate_current (result);
456+ } catch (nav2_core::GoalOutsideMapBounds & ex) {
457+ exceptionWarning (curr_start, curr_goal, goal->planner_id , ex);
458+ result->error_code = ActionThroughPosesGoal::GOAL_OUTSIDE_MAP;
459+ action_server_poses_->terminate_current (result);
460+ } catch (nav2_core::PlannerTFError & ex) {
461+ exceptionWarning (curr_start, curr_goal, goal->planner_id , ex);
462+ result->error_code = ActionThroughPosesGoal::TF_ERROR;
463+ action_server_poses_->terminate_current (result);
464+ } catch (nav2_core::NoViapointsGiven & ex) {
465+ exceptionWarning (curr_start, curr_goal, goal->planner_id , ex);
466+ result->error_code = ActionThroughPosesGoal::NO_VIAPOINTS_GIVEN;
467+ action_server_poses_->terminate_current (result);
439468 } catch (std::exception & ex) {
440- RCLCPP_WARN (
441- get_logger (),
442- " %s plugin failed to plan through %zu points with final goal (%.2f, %.2f): \" %s\" " ,
443- goal->planner_id .c_str (), goal->goals .size (), goal->goals .back ().pose .position .x ,
444- goal->goals .back ().pose .position .y , ex.what ());
445- action_server_poses_->terminate_current ();
469+ exceptionWarning (curr_start, curr_goal, goal->planner_id , ex);
470+ result->error_code = ActionThroughPosesGoal::UNKNOWN;
471+ action_server_poses_->terminate_current (result);
446472 }
447473}
448474
@@ -497,39 +523,38 @@ PlannerServer::computePlan()
497523 " Planner loop missed its desired rate of %.4f Hz. Current loop rate is %.4f Hz" ,
498524 1 / max_planner_duration_, 1 / cycle_duration.seconds ());
499525 }
500-
501526 action_server_pose_->succeeded_current (result);
502527 } catch (nav2_core::StartOccupied & ex) {
503528 exceptionWarning (start, goal->goal , goal->planner_id , ex);
504- result->error_code = nav2_msgs::action::ComputePathToPose::Goal ::START_OCCUPIED;
529+ result->error_code = ActionToPoseGoal ::START_OCCUPIED;
505530 action_server_pose_->terminate_current (result);
506531 } catch (nav2_core::GoalOccupied & ex) {
507532 exceptionWarning (start, goal->goal , goal->planner_id , ex);
508- result->error_code = nav2_msgs::action::ComputePathToPose::Goal ::GOAL_OCCUPIED;
533+ result->error_code = ActionToPoseGoal ::GOAL_OCCUPIED;
509534 action_server_pose_->terminate_current (result);
510535 } catch (nav2_core::NoValidPathCouldBeFound & ex) {
511536 exceptionWarning (start, goal->goal , goal->planner_id , ex);
512- result->error_code = nav2_msgs::action::ComputePathToPose::Goal ::NO_VALID_PATH;
537+ result->error_code = ActionToPoseGoal ::NO_VALID_PATH;
513538 action_server_pose_->terminate_current (result);
514539 } catch (nav2_core::PlannerTimedOut & ex) {
515540 exceptionWarning (start, goal->goal , goal->planner_id , ex);
516- result->error_code = nav2_msgs::action::ComputePathToPose::Goal ::TIMEOUT;
541+ result->error_code = ActionToPoseGoal ::TIMEOUT;
517542 action_server_pose_->terminate_current (result);
518543 } catch (nav2_core::StartOutsideMapBounds & ex) {
519544 exceptionWarning (start, goal->goal , goal->planner_id , ex);
520- result->error_code = nav2_msgs::action::ComputePathToPose::Goal ::START_OUTSIDE_MAP;
545+ result->error_code = ActionToPoseGoal ::START_OUTSIDE_MAP;
521546 action_server_pose_->terminate_current (result);
522547 } catch (nav2_core::GoalOutsideMapBounds & ex) {
523548 exceptionWarning (start, goal->goal , goal->planner_id , ex);
524- result->error_code = nav2_msgs::action::ComputePathToPose::Goal ::GOAL_OUTSIDE_MAP;
549+ result->error_code = ActionToPoseGoal ::GOAL_OUTSIDE_MAP;
525550 action_server_pose_->terminate_current (result);
526551 } catch (nav2_core::PlannerTFError & ex) {
527552 exceptionWarning (start, goal->goal , goal->planner_id , ex);
528- result->error_code = nav2_msgs::action::ComputePathToPose::Goal ::TF_ERROR;
553+ result->error_code = ActionToPoseGoal ::TF_ERROR;
529554 action_server_pose_->terminate_current (result);
530555 } catch (std::exception & ex) {
531556 exceptionWarning (start, goal->goal , goal->planner_id , ex);
532- result->error_code = nav2_msgs::action::ComputePathToPose::Goal ::UNKNOWN;
557+ result->error_code = ActionToPoseGoal ::UNKNOWN;
533558 action_server_pose_->terminate_current (result);
534559 }
535560}
0 commit comments