Skip to content

Commit

Permalink
Bug fix: set the BT Navigator "default_nav_to_pose_bt_xml" and "defau…
Browse files Browse the repository at this point in the history
…lt_nav_through_pose_bt_xml" from the yaml file (#2664)

* removing the has_parameter() and replacing with the get_parameter()

* fixing navigate_through_poses as well
  • Loading branch information
padhupradheep authored and SteveMacenski committed Dec 16, 2021
1 parent a1eac8a commit ce7fc22
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
13 changes: 6 additions & 7 deletions nav2_bt_navigator/src/navigators/navigate_through_poses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,12 @@ NavigateThroughPosesNavigator::getDefaultBTFilepath(
{
std::string default_bt_xml_filename;
auto node = parent_node.lock();
if (!node->has_parameter("default_nav_through_poses_bt_xml")) {
std::string pkg_share_dir =
ament_index_cpp::get_package_share_directory("nav2_bt_navigator");
std::string tree_file = pkg_share_dir +
"/behavior_trees/navigate_through_poses_w_replanning_and_recovery.xml";
node->declare_parameter("default_nav_through_poses_bt_xml", tree_file);
}
std::string pkg_share_dir =
ament_index_cpp::get_package_share_directory("nav2_bt_navigator");
node->declare_parameter<std::string>(
"default_nav_through_poses_bt_xml",
pkg_share_dir +
"/behavior_trees/navigate_through_poses_w_replanning_and_recovery.xml");
node->get_parameter("default_nav_through_poses_bt_xml", default_bt_xml_filename);

return default_bt_xml_filename;
Expand Down
13 changes: 6 additions & 7 deletions nav2_bt_navigator/src/navigators/navigate_to_pose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,12 @@ NavigateToPoseNavigator::getDefaultBTFilepath(
{
std::string default_bt_xml_filename;
auto node = parent_node.lock();
if (!node->has_parameter("default_nav_to_pose_bt_xml")) {
std::string pkg_share_dir =
ament_index_cpp::get_package_share_directory("nav2_bt_navigator");
std::string tree_file = pkg_share_dir +
"/behavior_trees/navigate_to_pose_w_replanning_and_recovery.xml";
node->declare_parameter("default_nav_to_pose_bt_xml", tree_file);
}
std::string pkg_share_dir =
ament_index_cpp::get_package_share_directory("nav2_bt_navigator");
node->declare_parameter<std::string>(
"default_nav_to_pose_bt_xml",
pkg_share_dir +
"/behavior_trees/navigate_to_pose_w_replanning_and_recovery.xml");
node->get_parameter("default_nav_to_pose_bt_xml", default_bt_xml_filename);

return default_bt_xml_filename;
Expand Down

0 comments on commit ce7fc22

Please sign in to comment.