Parser for processing the ROS Xacro file format. Xacro files from different versions of ROS require different options to be set. The differences are documented in the spec.
Options required for xacros created with a ROS version <= release 8 (ROS Indigo):
parser.inOrder = false;
parser.requirePrefix = false;
parser.localProperties = false;Options required for xacros created with a ROS version >= release 9 (ROS Jade):
parser.inOrder = true;
parser.requirePrefix = true;
parser.localProperties = true;On this page
Properties
inOrder: boolean = true
Since ROS Jade xacro allows for in order
processing, which allows variables to be used to define include paths and order-dependent
property definitions. The equivalent of the --inorder xacro command line flag.
requirePrefix: boolean = true
Since ROS Jade xacro requires all tags be prefixed with "xacro:".
Setting requirePrefix to false disables this requirement.
localProperties: boolean = true
Since ROS Jade xacro scopes property definitions to the containing macro.
Setting localProperties to false disables this behavior.
rospackCommands: Object<string, function(...string): string> | ( command: string, ...args: string ) => string = {}
A map of rospack command stem to handling function that take all arguments as function
parameters. An example implementation of the rospack find command:
parser.rospackCommands =
{
find: function( pkg ) {
switch( pkg ) {
case 'valkyrie_description':
return '/absolute/path/to/valkyrie_description/';
case 'r2_description':
return '/absolute/path/to/r2_description/'
}
}
};Alternatively a function can be provided to evaluate the command:
parser.rospackCommands = ( command, ...args ) => {
if ( command === 'find' ) {
const [ pkg ] = args;
switch( pkg ) {
case 'valkyrie_description':
return '/absolute/path/to/valkyrie_description/';
case 'r2_description':
return '/absolute/path/to/r2_description/'
}
}
};arguments: Object<string, (string|number|boolean)> = {}
A map of argument names to values that will be substituted for $(arg name) tags.
parser.arguments =
{
transmission_hw_interface: "hardware_interface/PositionJointInterface",
arm_x_separation: -0.4,
laser_visual: true,
};workingPath: string = ''
The working directory to search for dependent files in when parsing include tags.
Methods
async getFileContents( path: string ): Promise<string>An overrideable function that takes a file path and returns the contents of that file as a
string. Used for loading a documents referenced in include tags.
async parse( data: string ): Promise<XMLDocument>Parses the passed xacro contents using the options specified on the object and returns an xml document of the processed xacro file.