1. 程式人生 > >ROS中rosrun和roslaunch命令的對比

ROS中rosrun和roslaunch命令的對比

https://blog.csdn.net/hcx25909/article/details/7802754

 在ROS中執行節點的命令有兩個:rosrun和roslaunch。

        官網上的解釋如下:

        rosrun allows you to run an executable in an arbitrary package without having to cd (or roscd) there first.

          roslaunch is a tool for easily launching multiple ROS nodes locally and remotely via SSH, as well as setting parameters on the Parameter Server. It includes options to automatically respawn processes that have already died. roslaunch takes in one or more XML configuration files (with the .launch extension) that specify the parameters to set and nodes to launch, as well as the machines that they should be run on.

         測試發現,rosrun是執行一個單獨節點的命令,如果要執行多個節點,則需要使用多次rosrun命令。

       而roslaunch採用XML的格式對需要執行的節點進行描述,可以同時執行多個節點。例如:

<launch>
  <node name="listener" pkg="rospy_tutorials" type="listener.py" output="screen"/>
  <node name="publish_on_shutdown" pkg="rospy_tutorials" type="publish_on_shutdown.py" output="screen"/>
</launch>

       可以同時執行listener和publish_on_shutdown兩個節點。