separated amcl related nodes in another launch file
authorHenrique Scharlau Coelho <henriquescharlaucoelho@gmail.com>
Sat, 4 Nov 2023 00:27:26 +0000 (21:27 -0300)
committerHenrique Scharlau Coelho <henriquescharlaucoelho@gmail.com>
Sat, 4 Nov 2023 00:27:26 +0000 (21:27 -0300)
this was made to prepare for the addition of the other localization
methods.
maybe a python launch file would be better, for example, to set
the node names of the lifecycle manager node

twil_2dnav/launch/localization_amcl.launch.xml [new file with mode: 0644]
twil_2dnav/launch/nav2_navigator.launch.xml

diff --git a/twil_2dnav/launch/localization_amcl.launch.xml b/twil_2dnav/launch/localization_amcl.launch.xml
new file mode 100644 (file)
index 0000000..e8a3229
--- /dev/null
@@ -0,0 +1,26 @@
+<launch>
+    <node name="depthimage_to_laserscan" pkg="depthimage_to_laserscan" exec="depthimage_to_laserscan_node">
+        <remap from="depth" to="/camera/depth/image_raw"/> 
+        <remap from="depth_camera_info" to="/camera/depth/camera_info"/> 
+        <remap from="scan" to="/camera/depth/image_scan"/> 
+        <param name="output_frame" type="str" value="camera_link"/> 
+    </node>
+
+    <node pkg="nav2_amcl" exec="amcl" name="amcl">
+        <param name="use_sim_time" value="$(var use_sim_time)"/>
+        <param from="$(find-pkg-share twil_2dnav)/config/amcl_params.yaml"/>
+    </node>
+
+    <node pkg="nav2_lifecycle_manager" exec="lifecycle_manager" name="lifecycle_manager_nav2">
+        <param name="use_sim_time" value="$(var use_sim_time)"/>
+        <param name="autostart" value="$(var autostart)"/>
+        <param name="node_names" value="[
+            'map_server',
+            'amcl',
+            'controller_server',
+            'planner_server',
+            'behavior_server',
+            'bt_navigator']"/>
+    </node>
+</launch>
+
index 0cf56b3..d303822 100644 (file)
@@ -24,6 +24,7 @@
     <arg name="map" default="$(find-pkg-share ufrgs_maps)/map/centenario1.yaml"/>
     <arg name="autostart" default="true"/>
     <arg name="controller" default=""/>
+    <arg name="localization" default="amcl"/>
 
     <node pkg="nav2_map_server" name="map_server" exec="map_server">
         <param name="use_sim_time" value="$(var use_sim_time)"/>
@@ -49,6 +50,7 @@
         <remap from="cmd_vel" to="$(var controller)/command"/>
     </node>
 
+
     <node pkg="nav2_bt_navigator" exec="bt_navigator" name="bt_navigator">
         <param name="use_sim_time" value="$(var use_sim_time)"/>
         <param from="$(find-pkg-share twil_2dnav)/config/bt_navigator_params.yaml"/>
         <remap from="odom" to="$(var controller)/odom"/>
     </node>
 
-    <node pkg="nav2_amcl" exec="amcl" name="amcl">
-        <param name="use_sim_time" value="$(var use_sim_time)"/>
-        <param from="$(find-pkg-share twil_2dnav)/config/amcl_params.yaml"/>
-    </node>
-
-    <node pkg="nav2_lifecycle_manager" exec="lifecycle_manager" name="lifecycle_manager_nav2">
-        <param name="use_sim_time" value="$(var use_sim_time)"/>
-        <param name="autostart" value="$(var autostart)"/>
-        <param name="node_names" value="[
-            'map_server',
-            'amcl',
-                       'controller_server',
-                       'planner_server',
-                       'behavior_server',
-                       'bt_navigator']"/>
-    </node>
-
-    <node pkg="robot_localization" exec="ekf_node" name="ekf_filter_node" output="screen">
+    <node pkg="robot_localization" exec="ekf_node" name="ekf_filter_node">
         <param name="use_sim_time" value="$(var use_sim_time)"/>
         <param name="odom0" value="$(var controller)/odom"/>
         <param from="$(find-pkg-share twil_2dnav)/config/ekf_params.yaml"/>
     </node>
 
-    <node name="depthimage_to_laserscan" pkg="depthimage_to_laserscan" exec="depthimage_to_laserscan_node">
-        <remap from="depth" to="/camera/depth/image_raw"/> 
-        <remap from="depth_camera_info" to="/camera/depth/camera_info"/> 
-        <remap from="scan" to="/camera/depth/image_scan"/> 
-        <param name="output_frame" type="str" value="camera_link"/> 
-    </node>
+       <include file="$(find-pkg-share twil_2dnav)/launch/localization_$(var localization).launch.xml">
+       </include>
 
 </launch>