ROS launch中的node name、package、type实际意义、定义与查找方法、具体位置

ros launch文件中的pkg, type具体位置_查看launch文件在的地址_蓝羽飞鸟的博客-CSDN博客

上网查了很多关于lauch文件中的pkg,type,都是说是包和可执行文件,具体这个文件在哪个文件夹也不甚清楚,实操了一番,记录一下。
这里不是写launch文件怎样写,也不是多个node启动,只写一个node,为了说明pkg和type在哪。

下面是一个示例的完整流程:

    cd ~/git (其他文件夹也可)
    git clone https://github.com/ethz-asl/ros_best_practices.git
    ln -s ~/git/ros_best_practices/ ~/catkin_ws/src/ (建立symbolic link, 多个项目时比较方便)
    cd ~/catkin_ws
    catkin build ros_package_template (ros_package_template在ros_best_practices文件夹下)
    source devel/setup.bash (更新work space)
    可以看到~/catkin_ws/src/ros_best_practices/ros_package_template/launch文件夹下已经有了ros_package_template.launch
    这时可以直接用roslaunch ros_package_template ros_package_template.launch命令启动

如果想写一个launch文件,通过launch文件启动的话,可用如下模板

<launch>
  <node pkg="" type="" name=""  output="screen">
  </node>
</launch>

现在的问题是pkg和type应该写哪个

可以在~/catkin_ws/devel/lib 文件夹下看到刚才build好的ros_package_template文件夹,进入ros_package_template文件夹内发现有个可执行文件ros_package_template
所以这时pkg就是文件夹的名字ros_package_template,type就是可执行文件的名字ros_package_template(虽然它俩一样),name可以自己取,仍然取ros_package_template

这个launch文件的内容如下,命名为test.launch,假设把它放在~/git下面

<launch>
  <node pkg="ros_package_template" type="ros_package_template" name="ros_package_template" output="screen">
  </node>
</launch>

启动它时用roslaunch ~/git/test.launch即可


在launch文件中设置yaml文件

1.直接设置,用xml文件格式,yaml文件格式会报错

 https://blog.csdn.net/ljx0365/article/details/115058744

2.直接设置yaml文件的路径

<launch>

<node name="vins_node" pkg="vins" type="vins_node" output="screen" args="/xx/xx/x/.yaml"/>

</launch>

详见:roslaunch command line args - ROS Answers: Open Source Q&A Forum

<launch>
   <node pkg="my_package" type="my_node" name="node_instance" args="-arg1 -arg2" />
</launch>

猜你喜欢

转载自blog.csdn.net/weixin_45834800/article/details/131891771