From e09cabde2bbf1a8d3a87352e11a201700ebba089 Mon Sep 17 00:00:00 2001
From: Carl Delsey <carl.r.delsey@intel.com>
Date: Fri, 11 Oct 2019 16:47:30 -0700
Subject: [PATCH] Install Behavior Trees in correct location (#1231)

* Install behavior trees in correct location

* Fix up bt paths in launch files.
---
 nav2_bringup/bringup/launch/nav2_bringup_launch.py            | 4 ++--
 .../bringup/launch/nav2_multi_tb3_simulation_launch.py        | 3 +--
 nav2_bringup/bringup/launch/nav2_navigation_launch.py         | 4 ++--
 nav2_bringup/bringup/launch/nav2_tb3_simulation_launch.py     | 2 +-
 nav2_bt_navigator/CMakeLists.txt                              | 4 +---
 nav2_system_tests/src/system/test_system_launch.py            | 3 +--
 6 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/nav2_bringup/bringup/launch/nav2_bringup_launch.py b/nav2_bringup/bringup/launch/nav2_bringup_launch.py
index e4877888..3d1c7065 100644
--- a/nav2_bringup/bringup/launch/nav2_bringup_launch.py
+++ b/nav2_bringup/bringup/launch/nav2_bringup_launch.py
@@ -14,7 +14,7 @@
 
 import os
 
-from ament_index_python.packages import get_package_prefix, get_package_share_directory
+from ament_index_python.packages import get_package_share_directory
 
 from nav2_common.launch import Node
 
@@ -74,7 +74,7 @@ def generate_launch_description():
     declare_bt_xml_cmd = DeclareLaunchArgument(
         'bt_xml_file',
         default_value=os.path.join(
-            get_package_prefix('nav2_bt_navigator'),
+            get_package_share_directory('nav2_bt_navigator'),
             'behavior_trees', 'navigate_w_replanning_and_recovery.xml'),
         description='Full path to the behavior tree xml file to use')
 
diff --git a/nav2_bringup/bringup/launch/nav2_multi_tb3_simulation_launch.py b/nav2_bringup/bringup/launch/nav2_multi_tb3_simulation_launch.py
index ef548f51..935b896b 100644
--- a/nav2_bringup/bringup/launch/nav2_multi_tb3_simulation_launch.py
+++ b/nav2_bringup/bringup/launch/nav2_multi_tb3_simulation_launch.py
@@ -18,7 +18,6 @@
 
 import os
 
-from ament_index_python.packages import get_package_prefix
 from ament_index_python.packages import get_package_share_directory
 
 from nav2_common.launch import ReplaceString
@@ -76,7 +75,7 @@ def generate_launch_description():
     declare_bt_xml_cmd = DeclareLaunchArgument(
         'bt_xml_file',
         default_value=os.path.join(
-            get_package_prefix('nav2_bt_navigator'),
+            get_package_share_directory('nav2_bt_navigator'),
             'behavior_trees', 'navigate_w_replanning_and_recovery.xml'),
         description='Full path to the behavior tree xml file to use')
 
diff --git a/nav2_bringup/bringup/launch/nav2_navigation_launch.py b/nav2_bringup/bringup/launch/nav2_navigation_launch.py
index 4f8f2194..3b4d56f4 100644
--- a/nav2_bringup/bringup/launch/nav2_navigation_launch.py
+++ b/nav2_bringup/bringup/launch/nav2_navigation_launch.py
@@ -14,7 +14,7 @@
 
 import os
 
-from ament_index_python.packages import get_package_prefix, get_package_share_directory
+from ament_index_python.packages import get_package_share_directory
 
 from nav2_common.launch import RewrittenYaml
 from nav2_common.launch import Node
@@ -85,7 +85,7 @@ def generate_launch_description():
 
         DeclareLaunchArgument(
             'bt_xml_file',
-            default_value=os.path.join(get_package_prefix('nav2_bt_navigator'),
+            default_value=os.path.join(get_package_share_directory('nav2_bt_navigator'),
                 'behavior_trees', 'navigate_w_replanning_and_recovery.xml'),
             description='Full path to the behavior tree xml file to use'),
 
diff --git a/nav2_bringup/bringup/launch/nav2_tb3_simulation_launch.py b/nav2_bringup/bringup/launch/nav2_tb3_simulation_launch.py
index 45d18d8b..835027ec 100644
--- a/nav2_bringup/bringup/launch/nav2_tb3_simulation_launch.py
+++ b/nav2_bringup/bringup/launch/nav2_tb3_simulation_launch.py
@@ -84,7 +84,7 @@ def generate_launch_description():
     declare_bt_xml_cmd = DeclareLaunchArgument(
         'bt_xml_file',
         default_value=os.path.join(
-            get_package_prefix('nav2_bt_navigator'),
+            get_package_share_directory('nav2_bt_navigator'),
             'behavior_trees', 'navigate_w_replanning_and_recovery.xml'),
         description='Full path to the behavior tree xml file to use')
 
diff --git a/nav2_bt_navigator/CMakeLists.txt b/nav2_bt_navigator/CMakeLists.txt
index bed3bfdc..478b863e 100644
--- a/nav2_bt_navigator/CMakeLists.txt
+++ b/nav2_bt_navigator/CMakeLists.txt
@@ -69,9 +69,7 @@ install(DIRECTORY include/
   DESTINATION include/
 )
 
-install(DIRECTORY behavior_trees/
-  DESTINATION behavior_trees/
-)
+install(DIRECTORY behavior_trees DESTINATION share/${PROJECT_NAME})
 
 if(BUILD_TESTING)
   find_package(ament_lint_auto REQUIRED)
diff --git a/nav2_system_tests/src/system/test_system_launch.py b/nav2_system_tests/src/system/test_system_launch.py
index 766456c4..d10016c6 100755
--- a/nav2_system_tests/src/system/test_system_launch.py
+++ b/nav2_system_tests/src/system/test_system_launch.py
@@ -18,7 +18,6 @@ import os
 import sys
 
 
-from ament_index_python.packages import get_package_prefix
 from ament_index_python.packages import get_package_share_directory
 from launch import LaunchDescription
 from launch import LaunchService
@@ -34,7 +33,7 @@ def generate_launch_description():
     bringup_package = get_package_share_directory('nav2_bringup')
     params_file = os.path.join(bringup_package, 'params/nav2_params.yaml')
     astar = (os.getenv('ASTAR').lower() == 'true')
-    bt_navigator_install_path = get_package_prefix('nav2_bt_navigator')
+    bt_navigator_install_path = get_package_share_directory('nav2_bt_navigator')
     bt_navigator_xml = os.path.join(bt_navigator_install_path,
                                     'behavior_trees',
                                     os.getenv('BT_NAVIGATOR_XML'))
-- 
GitLab