URDF is an XML format for representing a robot model.
Xacro (XML Macros) allows user to construct shorter, reusable and more readable XML files by using macros that expand to larger XML expressions.
<?xml version="1.0" ?>
<robot name="my_robot" xmlns:xacro="http://www.ros.org/wiki/xacro">
<link name="link_chassis">
<pose>0 0 0.1 0 0 0</pose>
<inertial>
<mass value="5"/>
<origin xyz="0 0 0.1" rpy="0 0 0"/>
<inertia ixx="0.0395416666667" ixy="0" ixz="0"
iyy="0.106208333333" iyz="0"
izz="0.106208333333"/>
</inertial>
<collision name="collision_chassis">
<geometry>
<box size="1 1 2"/>
</geometry>
</collision>
<visual>
<origin xyz="0 0 0.1" rpy="0 0 0"/>
<geometry>
<box size="1 1 2"/>
</geometry>
</visual>
</link>
</robot>
<?xml version="1.0" encoding="UTF-8"?>
<launch>
<param name="robot_description" command="$(find xacro)/xacro --inorder '$(find my_package)/urdf/robot.urdf'"/>
<arg name="x" default="0"/>
<arg name="y" default="0"/>
<arg name="z" default="1.5"/>
<node name="my_robot_spawn" pkg="gazebo_ros" type="spawn_model" output="screen"
args="-urdf -param robot_description -model my_robot -x $(arg x) -y $(arg y) -z $(arg z)"/>
</launch>
<?xml version="1.0"?>
<launch>
<param name="robot_description" command="$(find xacro)/xacro --inorder '$(find my_package)/urdf/robot.urdf'"/>
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
<param name="use_gui" value="False"/>
</node>
<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher"/>
<node name="rviz" pkg="rviz" type="rviz"/>
</launch>
catkin_create_pkg my_package urdf
roslaunch gazebo_ros empty_world.launch
roslaunch my_package spawn.launch
roslaunch my_package rviz.launch