
In general you will want to make a xacro for your composite system (i.e., robots, sensors, environment, etc.). In the industrial world this is equivalent to your workcell. The ROS-Industrial guys have a training unit on creating modular xacro macros for building workcells here. Good macros will accept parent links and relative offsets for easily building configurations.
As an example, you might end up with something that looks like the following for you high-level macro that will create your desired configuration:
<?xml version="1.0" ?>
<robot name="my_robot" xmlns:xacro="http://ros.org/wiki/xacro">
<xacro:include filename="$(find my_robot_support)/urdf/awesome_robot_macro.xacro"/>
<xacro:include filename="$(find my_sensor_a_support)/urdf/sensor_a_macro.xacro"/>
<xacro:include filename="$(find my_sensor_b_support)/urdf/sensor_b_macro.xacro"/>
<xacro:property name="pi" value="3.141592"/>
<!-- the robot -->
<xacro:awesome_robot />
<!-- my sensor A (mounted to the table) -->
<xacro:sensor_a parent_link="$base_link"
x_val="0.400" y_val="0.500" z_val="0.000"
roll="0.000" pitch="0.000" yaw="1.200"/>
<!-- my sensor B (mounted to the robot's tool flange) -->
<xacro:sensor_b parent_link="<span class="math-container">$tool0"
x_val="0.000" y_val="0.000" z_val="0.000"
roll="$</span>{pi/2}" pitch="0.000" yaw="${-pi}"/>
....
</robot>
Originally posted by BrettHemes with karma: 525 on 2017-05-26
This answer was ACCEPTED on the original site
Post score: 1
Original comments
Comment by gvdhoorn on 2017-05-26:
An alternative pattern would be to create the connecting links and joints outside the xacro macros (ie: at the top-level level). That removes the need for those additional parameters and increases visibility of the connecting structures.