Robot Operating System Cookbook
上QQ阅读APP看书,第一时间看更新

There's more…

As discussed previously, we could also create launch files to load more than one instance of the nodelet class. The following launch file, hello_ros.launch, will load two nodelets with the names Hello1 and Hello2:

<launch> 
<!-- Started nodelet manager --> 
 
  <node pkg="nodelet" type="nodelet" name="standalone_nodelet"  args="manager" output="screen"/> 
<!-- Starting first nodelet --> 
 
  <node pkg="nodelet" type="nodelet" name="Hello1" args="load nodelet_hello_ros/Hello standalone_nodelet" output="screen"> 
  </node>             
 
<!-- Starting second nodelet --> 
 
  <node pkg="nodelet" type="nodelet" name="Hello2" args="load nodelet_hello_ros/Hello standalone_nodelet" output="screen"> 
  </node>             
 
</launch> 

We can launch the nodelets with this launch file as follows:

$ roslaunch nodelet_hello_world hello_ros.launch

Using rqt_graph, we can view how the nodelets interconnect inside the ROS framework:

$rosrun rqt_gui rqt_gui

ROS computational network graph showing two instances of a nodelet