Embodied AI Glossary中文

Xacro (XML Macros)

Xacro(XML 宏)XacroCommon

An XML macro language that adds variables, macros, and includes to URDF, cutting down on repetitive robot descriptions.

Xacro is an XML macro language and companion tool package in the ROS ecosystem, built specifically for writing URDF (the Unified Robot Description Format, which uses XML to describe a robot's links, joints, mass, and shape). Plain URDF has no variables or functions, so a symmetric dual-arm robot ends up needing nearly identical links and joints copied twice, and changing one dimension means editing many places. Xacro adds properties (constants), macros (parameterized templates), basic math, conditional expansion, and an include mechanism for combining multiple files. A finished .xacro file is expanded into plain URDF at launch time by the xacro command, then handed off to robot_state_publisher, RViz, Gazebo, or MoveIt. Most vendor-provided ROS robot description packages ship in .xacro form.

ExampleWrite an arm macro parameterized by prefix and mounting position for a dual-arm robot, then call it twice with left_ and right_ to generate all the links and joints for both arms.

Also called
.xacro file
Related
Unified Robot Description Format · Semantic Robot Description Format (SRDF) · MJCF (MuJoCo XML Format) · robot_state_publisher · Robot Operating System 2 · Mesh File (STL / OBJ / DAE / glTF)
Sources
ROS Wiki: xacro
ros/xacro (GitHub)

See it in the full glossary →