launch xxx.launch in catkin_ws

90 Views Asked by At

To start several nodes together, I write a launch file in catkin_ws. The first layer of my ws is: devel build src launch. In src, I have several pkg, and each of them has a node. However, I can only use cmd:

roslaunch start.launch

in ws/launch.

Can someone tell me if I want to use roslaunch start.launch in ws/ , what I need to do?

I think if I put all nodes in one pkg and there is a launch directory in this pkg, I can "roslaunch" this launch file in workspace. But it is not convenient to manage my code.

My launch file looks like this: start.launch

 <launch>
    <node pkg="rslidar_sdk" name="rslidar_sdk_node" type="rslidar_sdk_node" output="screen">
    <param name="config_path" value=""/> 
   </node>
   <node pkg="cam_node" name="cam_node" type="cam_node" output="screen">
   <param name="config_path" value=""/>
   </node>
   <node pkg="imu_node" name="imu_node" type="imu_node" output="screen">
   <param name="config_path" value=""/>
   </node>
   <node pkg="lidarconv" name="lidarconv_node" type="lidarconv_node" output="screen">
   <param name="config_path" value=""/>
   </node>  
    <!-- rosrun rs_to_velodyne rs_to_velodyne XYZIRT XYZIRT -->
    </launch>
1

There are 1 best solutions below

0
SystemSigma_ On

In ROS, it is very common to create your own custom package of launch files, i.e. containing just a launch folder containing just .launch files and with all its dependencies listed in the CMakeLists.txt file. Installing this package will also install the dependencies needed to start its launch files.

The project structure may look like this:

catkin_ws/
   devel/
   build/
   src/
      my_launch_pkg/
          launch/
              start.launch
          CMakeLists.txt

This way you just need to source your worskspace:

cd catkin_ws && source devel/setup.bash

to launch your launch file from anywhere:

roslaunch my_launch_pkg start.launch