Xacro is just a scripting mechanism that allows more modularity and code re-use when defining a URDF model. When using it, what is actually uploaded to the parameter servers (per default as the "robot_description" parameter) actually is a URDF, as that gets generated from the xacro file in the launch file (by expanding the xacro macros used).
As an example, say you have a "robot.urdf.xacro" file. You can run
rosrun xacro xacro.py robot.urdf.xacro > robot.urdf
and that gives you the URDF generated from your xacro file. The same approach is commonly used in launch files when a xacro-based robot_description is uploaded.
Xacro is just another way of defining a URDF, not an alternative to it. It makes certain things easier, for instance you can generate a "wheel" macro and instantiate that 6 times with different parameters to put 6 wheels on your robot, as opposed to copying and pasting the same code six times manually.
Originally posted by Stefan Kohlbrecher with karma: 24361 on 2015-01-31
This answer was ACCEPTED on the original site
Post score: 15
Original comments
Comment by Oguz on 2015-01-31:
Thanks, then I will stick to my SolidWorks Exporter generated URDF.
Comment by Yanhao Zhu on 2019-08-17:
Also new to urdf and have a similar confusion. Really a good answer!