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>
In
ROS, it is very common to create your own custom package of launch files, i.e. containing just alaunchfolder containing just.launchfiles and with all its dependencies listed in theCMakeLists.txtfile. Installing this package will also install the dependencies needed to start its launch files.The project structure may look like this:
This way you just need to source your worskspace:
to launch your launch file from anywhere: