Ros uses the Rosrun command to start a node, and if you need to start Node Manager (master) and multiple nodes at the same time, you need to use the launch file to configure it. The launch file is a special XML format file, usually with a. Launch as a file suffix. Each launch file must contain a root element.
Roslaunch is used in the following ways:
$ roslaunch Pkg-name Launch-file-name
The following is an example of a typical launch file:
<launch> <!--These are the arguments you can pass this launch file, for example Paus Ed:=true--> <arg name= "Debug" default= "true"/> <!--We resume the logic in Empty_world.launch, changing
Only the name of the ' The World ' is launched--> <include file= "$ (find Gazebo_ros)/launch/empty_world.launch" > <arg name= "Debug" value= "$ (arg debug)"/> </include> <!--Load the URDF into the ROS Parameter serv Er--> <arg name= "model"/> <param name= "robot_description" command= "$ (Find Xacro)/xacro.py $ (arg mo del) "/> <!--Run A Python script to the send a service called to Gazebo_ros to spawn a URDF robot--> <no De name= "Urdf_spawner" pkg= "Gazebo_ros" type= "Spawn_model" respawn= "false" output= "screen" args= "-urdf-model robot1- param robot_description-z 0.05 "/> </launch>
Launch
Each launch file must and can contain only one root element. The root element is defined by a pair of launch tags, and all other element tags should be included within the two tags.
<launch> ...
</launch>
Arg
Roslaunch supports startup parameter arg, which can be used to change the program's operation by setting Arg. Name is the start parameter's default value, and value is the parameter value of the parameter.
The only difference between default and value is that the command-line arguments roslaunch pkg-name launch-file-name arg-name:= "Set-value" can override default value, but cannot override the value of parameter values. where the $ (arg arg-name) appears in the launch file, runtime Roslaunch replaces it with the parameter value. And you can use arg within the Include Element tab to set the parameter values in the contained launch file.
param
Prarmeter and argument are different in Ros, although translations are the same. parameter is the numeric value used by the ROS system in operation, stored in a parameter server (parameter server), where each active node can obtain parameter values through the ROS::p the Aram::get function. Users can also get parameter values by Rosparam and argument only in the boot file. Their values cannot be directly obtained by the node.
include
Reusing other launch files in a launch file can reduce the amount of code written and improve the simplicity of the file. Use the include element include in the launch file to include all nodes and parameters in other launch files.
<include file= "$ (find Pkg-name)/launch/launch-file-name" > <arg name= "arg_name" value=
"Set-value"/>
</include>
node
The form of a node is:
<node name= "Node-name" pkg= "Pkg-name" type= "Executable-name"/>
Node's three properties are the names of the nodes, the package names, and the executable files, respectively. The Name property assigns names to nodes, overwriting any names that are assigned to nodes by calling Ros::init. Node parameter values can also be set by using ARG within node tags. If the node tag has a children tag, it needs to be defined explicitly. That is/node> at the end