Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags. |
Create resources using files
Description: How to create a robot using a Yaml or an XML fileTutorial Level: INTERMEDIATE
Creating a laser sensor with an XML file
You can create a laser sensor in the following way (hokuyo.xml file):
<laser> <laser_specifications> <max_range>4</max_range> <num_rays>270</num_rays> <pose> <x>0</x> <y>0</y> <theta>0</theta> </pose> <noise> <noise_specifications> <noise_mean>0</noise_mean> <noise_std>0.03</noise_std> </noise_specifications> </noise> </laser_specifications> </laser>
Of course, thanks to the recursive file parsing of stdr_parser you can use the gauss_small.xml noise file, which exists in the stdr_resources package:
<laser> <laser_specifications> <max_range>4</max_range> <max_angle> <pose> <x>0</x> <y>0</y> <theta>0</theta> </pose> <noise> <filename>gauss_small.xml</filename> </noise> </laser_specifications> </laser>
Creating a robot with the two laser sensors
In order to create a robot that employs two of the laser sensors that you build in the previous step, you can simply write the following XML file:
<robot> <robot_specifications> <footprint> <radius>0.3</radius> </footprint> <laser> <filename>hokuyo.xml</filename> </laser> <laser> <filename>hokuyo.xml</filename> </laser> </robot_specifications> <robot>
The problem here is that the orientation of the two laser sensors will be the same, and specifically equal to 0, as stated in the hokuyo.xml resource file. In order to fix that, each value of an "internal" node, can be overriden in the following way:
<robot> <robot_specifications> <footprint> <radius>0.3</radius> </footprint> <laser> <filename>hokuyo.xml</filename> <laser_specifications> <pose> <theta>1.57</theta> </pose> </laser_specifications> </laser> <laser> <filename>hokuyo.xml</filename> <laser_specifications> <pose> <theta>-1.57</theta> </pose> </laser_specifications> </laser> </robot_specifications> <robot>
In that way the orientations of the LRFs are changed. In a similar way we can alterate the number of rays or the maximum distance of the second LRF:
<robot> <robot_specifications> <footprint> <radius>0.3</radius> </footprint> <laser> <filename>hokuyo.xml</filename> <laser_specifications> <pose> <theta>1.57</theta> </pose> </laser_specifications> </laser> <laser> <filename>hokuyo.xml</filename> <laser_specifications> <pose> <theta>-1.57</theta> </pose> <max_range>10</max_range> <num_rays>180</num_rays> </laser_specifications> </laser> </robot_specifications> <robot>