File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed
nav2_behavior_tree/include/nav2_behavior_tree
nav2_bt_navigator/src/navigators Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -135,6 +135,15 @@ class BtActionServer
135135 return default_bt_xml_filename_;
136136 }
137137
138+ /* *
139+ * @brief Getter function for BT search
140+ * @return string Containing BT search directories
141+ */
142+ std::vector<std::string> getSearchDirectories () const
143+ {
144+ return search_directories_;
145+ }
146+
138147 /* *
139148 * @brief Wrapper function to accept pending goal if a preempt has been requested
140149 * @return Shared pointer to pending action goal
Original file line number Diff line number Diff line change @@ -72,6 +72,14 @@ NavigateThroughPosesNavigator::getDefaultBTFilepath(
7272bool
7373NavigateThroughPosesNavigator::goalReceived (ActionT::Goal::ConstSharedPtr goal)
7474{
75+ auto bt_xml_filename = goal->behavior_tree ;
76+ auto bt_search_directories = bt_action_server_->getSearchDirectories ();
77+ if (!bt_action_server_->loadBehaviorTree (bt_xml_filename, bt_search_directories)) {
78+ bt_action_server_->setInternalError (ActionT::Result::FAILED_TO_LOAD_BEHAVIOR_TREE,
79+ " Error loading XML file: " + bt_xml_filename + " . Navigation canceled." );
80+ return false ;
81+ }
82+
7583 return initializeGoalPoses (goal);
7684}
7785
Original file line number Diff line number Diff line change @@ -82,6 +82,14 @@ NavigateToPoseNavigator::cleanup()
8282bool
8383NavigateToPoseNavigator::goalReceived (ActionT::Goal::ConstSharedPtr goal)
8484{
85+ auto bt_xml_filename = goal->behavior_tree ;
86+ auto bt_search_directories = bt_action_server_->getSearchDirectories ();
87+ if (!bt_action_server_->loadBehaviorTree (bt_xml_filename, bt_search_directories)) {
88+ bt_action_server_->setInternalError (ActionT::Result::FAILED_TO_LOAD_BEHAVIOR_TREE,
89+ std::string (" Error loading XML file: " ) + bt_xml_filename + " . Navigation canceled." );
90+ return false ;
91+ }
92+
8593 return initializeGoalPose (goal);
8694}
8795
You can’t perform that action at this time.
0 commit comments