ROS基础--launch文件的编写
1.找个功能包,准备用这个功能包写launch文件,我就用上一篇的hello.cpp打印C++变量赋值的功能包进行练习
roscd helloros
mkdir launch
cd launch
touch helloros.launch
gedit helloros.launch
2.书写launch文件
<?xml version="1.0"?>
<launch>
<node pkg="helloros" type="hello" respawn="false" name="hello_ros" output="screen">
</node>
</launch>
上面就写完了,pkg就是功能包的名字,type是可执行文件的名字,如果忘记可以查看cmakelist.txt中的add_executable()项,配置的时候写过的,name是节点启动后的名字,忘记的话可以启动节点后用rosnode list查看,respawn是可选项,表示节点退出后是否重新启动,默认为false,output是输出log的位置,默认输出到log,想看的话就输出到screen屏幕上。上面的launch文件格式为手打的,试了一下手打没问题,当然也可以复制别人的,然后修改内容。
3.启动roslaunch,测试一下写的成果
roslaunch helloros helloros.launch
成功打印出了上篇中的两个字符串,完事了。