First, a very brief explanation of launch files and roslaunch
. According to the wiki entry for roslaunch
:
roslaunch
is a tool for easily launching multiple ROS nodes locally and remotely via SSH...
Launch files provide a way, among other things, to launch a node (or nodes) with a single command:
roslaunch <package-name> <launch-file.launch>
Let's say that your package is called my_package
with a node called my_node
saved in the src
folder. You can run (i.e., launch) your node by creating a launch file called my_node.launch
like so:
<launch>
<node pkg="my_package" type="my_node" name="my_node"/>
</launch>
and run it using
roslaunch my_package my_node.launch
The code inside of the launch file is just XML. The launch
tag tells ROS that this is a launch file (they don't have to have a .launch
file extension) and the node
tag tells roslaunch
to run a node. Here are what the node
tags attributes mean:
pkg
: the package your node is in type
attribute says what the executable name is (for C++, for Python this is the filename so you would put the file extension) name
: this is what you want ROS Master to call your node. This is useful for giving nodes meaningful names and using multiple instances of the same node in the same namespace.
You can also configure nodes via parameters and include launch files within launch files (within launch files...) to create a very complex system. In fact, some ROS packages can be composed of nothing but launch files from other packages!
Launch files are one of the many powerful features of ROS because they make it very easy to configure your system and they promote extensibility and resuse. There are many more features of launch files and I recommend that you read through the wiki to get a better understanding of them.
This wiki entry for roslaunch
does a good job of explaining the roslaunch
XML format and the book A Gentle Introduction to ROS has a chapter on how to use launch files as well.
Edit:
TL;DR:
catkin
is used to compile the code into executables (or, for Python you chmod +x
it) and then you tell roslaunch
what executable to execute with the node
tag and its attributes.
Longer explanation:
For the "logical" part: roslaunch
will run exectuables from a package. It knows what executable you want to run through the node
tag's type
attribute. You put the executable's name as the value for type
and roslaunch
knows that you want to run an executable with the same name (from the package that you specified with the pkg
attribute). This can be from C++, Python, or whatever supported language was used to write the node.
The code in the src
folder (or wherever it is located) is not going to be executed by roslaunch
, only executables can be run.
Welcome! I think that in order to get a better response, you should ask at least two separate questions. One about the launch files/source code connection and the other about RPLIDAR and SLAM as these are two different subjects. You can edit this question and then ask a new one as well.