Mastering ROS for Robotics Programming(Second Edition)
上QQ阅读APP看书,第一时间看更新

Converting xacro to URDF

After designing the xacro file, we can use the following command to convert it to a URDF file:

    $ rosrun xacro xacro pan_tilt.xacro --inorder > pan_tilt_generated.urdf
  

The --inorder option has been recently introduced in ROS to increase the power of the conversion tool. It allows us to process the document in read order, adding more features than there were in older ROS versions.

We can use the following line in the ROS launch file for converting xacro to URDF and use it as a robot_description parameter:

  <param name="robot_description" command="$(find xacro)/xacro --inorder 
$(find mastering_ros_robot_description_pkg)/urdf/pan_tilt.xacro"
/>

We can view the xacro of pan-and-tilt by making a launch file, and it can be launched using the following command:

    $ roslaunch mastering_ros_robot_description_pkg view_pan_tilt_xacro.launch