|
6 | 6 | <xacro:include filename="$(find ur_description)/urdf/ur_macro.xacro"/> |
7 | 7 | <!-- include ros2 control --> |
8 | 8 | <xacro:include filename="$(find ur_description)/urdf/ur.ros2_control.xacro" /> |
| 9 | + <!-- include ros2_control hardware instantiation (for now, then migrate later to responsible packages) --> |
| 10 | + <xacro:include filename="$(find ur_description)/urdf/ur_hardware.xacro"/> |
9 | 11 |
|
10 | 12 | <!-- possible 'ur_type' values: ur3, ur3e, ur5, ur5e, ur10, ur10e, ur16e --> |
11 | 13 | <!-- the default value should raise an error in case this was called without defining the type --> |
|
17 | 19 | <xacro:arg name="kinematics_params" default="$(find ur_description)/config/$(arg ur_type)/default_kinematics.yaml"/> |
18 | 20 | <xacro:arg name="physical_params" default="$(find ur_description)/config/$(arg ur_type)/physical_parameters.yaml"/> |
19 | 21 | <xacro:arg name="visual_params" default="$(find ur_description)/config/$(arg ur_type)/visual_parameters.yaml"/> |
| 22 | + |
20 | 23 | <xacro:arg name="transmission_hw_interface" default=""/> |
21 | 24 | <xacro:arg name="safety_limits" default="false"/> |
22 | 25 | <xacro:arg name="safety_pos_margin" default="0.15"/> |
|
54 | 57 | <xacro:property name="initial_positions_file" default="$(arg initial_positions_file)"/> |
55 | 58 | <xacro:property name="sim_gazebo" default="$(arg sim_gazebo)"/> |
56 | 59 | <xacro:property name="sim_ignition" default="$(arg sim_ignition)"/> |
| 60 | + <xacro:property name="fake_hardware" default="$(arg use_fake_hardware)"/> |
| 61 | + |
57 | 62 |
|
58 | 63 | <!-- create link fixed to the "world" --> |
59 | 64 | <link name="world" /> |
60 | 65 |
|
61 | 66 | <!-- load model data --> |
| 67 | + <!-- This puts a bunch of named parameters in the top-level scope which are consumed inside later macros--> |
| 68 | + <!-- See https://github.com/ros/xacro/pull/105 --> |
62 | 69 | <xacro:read_model_data |
63 | 70 | joint_limits_parameters_file="$(arg joint_limit_params)" |
64 | 71 | kinematics_parameters_file="$(arg kinematics_params)" |
|
78 | 85 | <origin xyz="0 0 0" rpy="0 0 0" /> <!-- position robot in the world --> |
79 | 86 | </xacro:ur_robot> |
80 | 87 |
|
81 | | - |
82 | | - <!-- ros2 control instance --> |
| 88 | + <!-- ros2 control, if needed --> |
| 89 | + <!-- ur_description might eventually prepare fake/mock hardware only, delegating the <hardware> block to a consumer package --> |
| 90 | + <xacro:property name="needs_non_joint_interfaces" value="${not (sim_gazebo or sim_ignition)}"/> |
| 91 | + <!-- Kinematics hash comes from read_model_data --> |
83 | 92 | <xacro:ur_ros2_control |
84 | | - name="$(arg name)" prefix="$(arg prefix)" |
85 | | - use_fake_hardware="$(arg use_fake_hardware)" |
86 | | - fake_sensor_commands="$(arg fake_sensor_commands)" |
87 | | - sim_gazebo="$(arg sim_gazebo)" |
88 | | - sim_ignition="$(arg sim_ignition)" |
89 | | - headless_mode="$(arg headless_mode)" |
90 | | - initial_positions="${xacro.load_yaml(initial_positions_file)}" |
91 | | - use_tool_communication="$(arg use_tool_communication)" |
92 | | - tool_voltage="$(arg tool_voltage)" |
93 | | - tool_parity="$(arg tool_parity)" |
94 | | - tool_baud_rate="$(arg tool_baud_rate)" |
95 | | - tool_stop_bits="$(arg tool_stop_bits)" |
96 | | - tool_rx_idle_chars="$(arg tool_rx_idle_chars)" |
97 | | - tool_tx_idle_chars="$(arg tool_tx_idle_chars)" |
98 | | - tool_device_name="$(arg tool_device_name)" |
99 | | - tool_tcp_port="$(arg tool_tcp_port)" |
100 | | - robot_ip="$(arg robot_ip)" |
101 | | - script_filename="$(arg script_filename)" |
102 | | - output_recipe_filename="$(arg output_recipe_filename)" |
103 | | - input_recipe_filename="$(arg input_recipe_filename)" |
104 | | - reverse_ip="$(arg reverse_ip)" |
105 | | - script_command_port="$(arg script_command_port)" |
106 | | - tf_prefix="" |
107 | | - hash_kinematics="${kinematics_hash}" |
108 | | - /> |
| 93 | + name="$(arg name)" prefix="$(arg prefix)" |
| 94 | + add_non_joint_interfaces="${needs_non_joint_interfaces}" |
| 95 | + initial_positions="${xacro.load_yaml(initial_positions_file)}" |
| 96 | + > |
| 97 | + <!-- dz: For now, I conditionally pass the right <hardware> as a block param. --> |
| 98 | + <!-- dz: Later, this wouldn't be necessary, a consumer package could create and pass it in its top-level xacro --> |
| 99 | + <ros2_control_hardware> |
| 100 | + <xacro:unless value="${sim_gazebo or sim_ignition or fake_hardware}"> |
| 101 | + <xacro:ur_real_hardware_block |
| 102 | + headless_mode="$(arg headless_mode)" |
| 103 | + initial_positions="${xacro.load_yaml(initial_positions_file)}" |
| 104 | + use_tool_communication="$(arg use_tool_communication)" |
| 105 | + tool_voltage="$(arg tool_voltage)" |
| 106 | + tool_parity="$(arg tool_parity)" |
| 107 | + tool_baud_rate="$(arg tool_baud_rate)" |
| 108 | + tool_stop_bits="$(arg tool_stop_bits)" |
| 109 | + tool_rx_idle_chars="$(arg tool_rx_idle_chars)" |
| 110 | + tool_tx_idle_chars="$(arg tool_tx_idle_chars)" |
| 111 | + tool_device_name="$(arg tool_device_name)" |
| 112 | + tool_tcp_port="$(arg tool_tcp_port)" |
| 113 | + robot_ip="$(arg robot_ip)" |
| 114 | + script_filename="$(arg script_filename)" |
| 115 | + output_recipe_filename="$(arg output_recipe_filename)" |
| 116 | + input_recipe_filename="$(arg input_recipe_filename)" |
| 117 | + reverse_ip="$(arg reverse_ip)" |
| 118 | + script_command_port="$(arg script_command_port)" |
| 119 | + transmission_hw_interface="$(arg transmission_hw_interface)" |
| 120 | + tf_prefix="" |
| 121 | + hash_kinematics="${kinematics_hash}" |
| 122 | + /> |
| 123 | + </xacro:unless> |
| 124 | + <xacro:if value="${fake_hardware and not (sim_gazebo or sim_ignition)}"> |
| 125 | + <hardware> |
| 126 | + <plugin>mock_components/GenericSystem</plugin> |
| 127 | + <param name="fake_sensor_commands">$(arg fake_sensor_commands)</param> |
| 128 | + <param name="state_following_offset">0.0</param> |
| 129 | + </hardware> |
| 130 | + </xacro:if> |
| 131 | + <xacro:if value="${sim_gazebo}"> |
| 132 | + <hardware> |
| 133 | + <plugin>gazebo_ros2_control/GazeboSystem</plugin> |
| 134 | + </hardware> |
| 135 | + </xacro:if> |
| 136 | + <xacro:if value="${sim_ignition}"> |
| 137 | + <hardware> |
| 138 | + <plugin>ign_ros2_control/IgnitionSystem</plugin> |
| 139 | + </hardware> |
| 140 | + </xacro:if> |
| 141 | + </ros2_control_hardware> |
| 142 | + </xacro:ur_ros2_control> |
| 143 | + |
| 144 | + |
109 | 145 |
|
| 146 | + <!-- dz: These move to their respective simulation packages --> |
110 | 147 | <xacro:if value="$(arg sim_gazebo)"> |
111 | 148 | <!-- Gazebo plugins --> |
112 | 149 | <gazebo reference="world"> |
|
0 commit comments