|
| 1 | +<?xml version ="1.0"?> |
| 2 | +<robot xmlns:xacro="http://wiki.ros.org/xacro" name="pruning_robot"> |
| 3 | + <!-- WORLD LINK --> |
| 4 | + <link name="world"/> |
| 5 | + |
| 6 | + <!-- robot name parameter --> |
| 7 | + <xacro:arg name="name" default="pruning_robot"/> |
| 8 | + <xacro:arg name="robot_stack_qty" default='0'/> |
| 9 | + <xacro:arg name="mesh_base_path" default=''/> |
| 10 | + <xacro:arg name="urdf_base_path" default=''/> |
| 11 | + |
| 12 | + |
| 13 | + <!-- generate generic robot with stack_qty number of links, link parents --> |
| 14 | + <xacro:macro name='arg_assignment_loop' params='stack_qty'> |
| 15 | + <xacro:if value="${stack_qty}"> |
| 16 | + <xacro:arg name="parent${stack_qty - 1}" default="world"/> |
| 17 | + <xacro:arg name="robot_part${stack_qty - 1}" default="world"/> |
| 18 | + <xacro:arg_assignment_loop stack_qty="${stack_qty - 1}"/> |
| 19 | + </xacro:if> |
| 20 | + </xacro:macro> |
| 21 | + <xacro:arg_assignment_loop stack_qty="$(arg robot_stack_qty)"/> |
| 22 | + |
| 23 | + <xacro:macro name="main_loop" params="stack_qty"> |
| 24 | + <xacro:if value="${stack_qty}"> |
| 25 | + <!-- Generic robot properties --> |
| 26 | + <xacro:property name='resolved_part' value="$(arg robot_part${stack_qty - 1})"/> |
| 27 | + <xacro:property name='resolved_part_base' value="${resolved_part}__base}"/> |
| 28 | + <xacro:property name='resolved_parent_part' value="$(arg parent${stack_qty - 1})"/> |
| 29 | + <xacro:if value="${ str(resolved_parent_part) == 'world'}"> |
| 30 | + <xacro:property name='resolved_parent_link' value='world'/> |
| 31 | + </xacro:if> |
| 32 | + <xacro:unless value="${ str(resolved_parent_part) == 'world' }"> |
| 33 | + <xacro:property name='resolved_parent_link' value="${resolved_parent_part}__tool0"/> |
| 34 | + </xacro:unless> |
| 35 | + |
| 36 | + <!-- UR5e --> |
| 37 | + <xacro:if value="${ str(resolved_part) == 'ur5e' }"> |
| 38 | + <xacro:include filename="$(find ur_description)/urdf/ur_macro.xacro"/> |
| 39 | + <xacro:arg name="ur_type" default='ur5e'/> |
| 40 | + <xacro:arg name="ur_prefix" default='$(arg ur_type)__'/> |
| 41 | + |
| 42 | + <xacro:arg name="joint_limit_params" default="$(find ur_description)/config/$(arg ur_type)/joint_limits.yaml"/> |
| 43 | + <xacro:arg name="kinematics_params" default="$(find ur_description)/config/$(arg ur_type)/default_kinematics.yaml"/> |
| 44 | + <xacro:arg name="physical_params" default="$(find ur_description)/config/$(arg ur_type)/physical_parameters.yaml"/> |
| 45 | + <xacro:arg name="visual_params" default="$(find ur_description)/config/$(arg ur_type)/visual_parameters.yaml"/> |
| 46 | + <xacro:arg name="transmission_hw_interface" default=""/> |
| 47 | + <xacro:arg name="safety_limits" default="false"/> |
| 48 | + <xacro:arg name="safety_pos_margin" default="0.15"/> |
| 49 | + <xacro:arg name="safety_k_position" default="20"/> |
| 50 | + <!-- ros2_control related parameters --> |
| 51 | + <xacro:arg name="headless_mode" default="false" /> |
| 52 | + <xacro:arg name="robot_ip" default="0.0.0.0" /> |
| 53 | + <xacro:arg name="script_filename" default=""/> |
| 54 | + <xacro:arg name="output_recipe_filename" default=""/> |
| 55 | + <xacro:arg name="input_recipe_filename" default=""/> |
| 56 | + <xacro:arg name="reverse_ip" default="0.0.0.0"/> |
| 57 | + <xacro:arg name="script_command_port" default="50004"/> |
| 58 | + <xacro:arg name="reverse_port" default="50001"/> |
| 59 | + <xacro:arg name="script_sender_port" default="50002"/> |
| 60 | + <xacro:arg name="trajectory_port" default="50003"/> |
| 61 | + <!-- tool communication related parameters--> |
| 62 | + <xacro:arg name="use_tool_communication" default="false" /> |
| 63 | + <xacro:arg name="tool_voltage" default="0" /> |
| 64 | + <xacro:arg name="tool_parity" default="0" /> |
| 65 | + <xacro:arg name="tool_baud_rate" default="115200" /> |
| 66 | + <xacro:arg name="tool_stop_bits" default="1" /> |
| 67 | + <xacro:arg name="tool_rx_idle_chars" default="1.5" /> |
| 68 | + <xacro:arg name="tool_tx_idle_chars" default="3.5" /> |
| 69 | + <xacro:arg name="tool_device_name" default="/tmp/ttyUR" /> |
| 70 | + <xacro:arg name="tool_tcp_port" default="54321" /> |
| 71 | + |
| 72 | + <!-- Simulation parameters --> |
| 73 | + <xacro:arg name="use_fake_hardware" default="false" /> |
| 74 | + <xacro:arg name="fake_sensor_commands" default="false" /> |
| 75 | + <xacro:arg name="sim_gazebo" default="false" /> |
| 76 | + <xacro:arg name="sim_ignition" default="false" /> |
| 77 | + <xacro:arg name="simulation_controllers" default="" /> |
| 78 | + |
| 79 | + <!-- initial position for simulations (Fake Hardware, Gazebo, Ignition) --> |
| 80 | + <xacro:arg name="initial_positions_file" default="$(find ur_description)/config/initial_positions.yaml"/> |
| 81 | + |
| 82 | + <!-- convert to property to use substitution in function --> |
| 83 | + <xacro:property name="initial_positions_file" default="$(arg initial_positions_file)"/> |
| 84 | + |
| 85 | + <!-- arm --> |
| 86 | + <xacro:ur_robot |
| 87 | + name="$(arg name)" |
| 88 | + tf_prefix="$(arg ur_prefix)" |
| 89 | + parent="${resolved_parent_link}" |
| 90 | + joint_limits_parameters_file="$(arg joint_limit_params)" |
| 91 | + kinematics_parameters_file="$(arg kinematics_params)" |
| 92 | + physical_parameters_file="$(arg physical_params)" |
| 93 | + visual_parameters_file="$(arg visual_params)" |
| 94 | + transmission_hw_interface="$(arg transmission_hw_interface)" |
| 95 | + safety_limits="$(arg safety_limits)" |
| 96 | + safety_pos_margin="$(arg safety_pos_margin)" |
| 97 | + safety_k_position="$(arg safety_k_position)" |
| 98 | + use_fake_hardware="$(arg use_fake_hardware)" |
| 99 | + fake_sensor_commands="$(arg fake_sensor_commands)" |
| 100 | + sim_gazebo="$(arg sim_gazebo)" |
| 101 | + sim_ignition="$(arg sim_ignition)" |
| 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 | + reverse_port="$(arg reverse_port)" |
| 120 | + script_sender_port="$(arg script_sender_port)" |
| 121 | + trajectory_port="$(arg trajectory_port)" |
| 122 | + > |
| 123 | + <origin xyz="0 0 0" rpy="0 0 0" /> <!-- position robot in the world --> |
| 124 | + </xacro:ur_robot> |
| 125 | + </xacro:if> |
| 126 | + |
| 127 | + <!-- Robot cart --> |
| 128 | + <xacro:if value="${ str(resolved_part) == 'cart' }"> |
| 129 | + <xacro:include filename="$(arg urdf_base_path)/base_mounts/cart/macro/cart_macro.urdf.xacro"/> |
| 130 | + <xacro:cart_macro |
| 131 | + cart_prefix="cart__" |
| 132 | + cart_parent="${resolved_parent_part}" |
| 133 | + mesh_base_path="$(arg mesh_base_path)" |
| 134 | + /> |
| 135 | + </xacro:if> |
| 136 | + |
| 137 | + <xacro:if value="${ str(resolved_part) == 'mock_pruner' }"> |
| 138 | + <xacro:include filename="$(arg urdf_base_path)/end_effectors/mock_pruner/macro/mock_pruner_macro.urdf.xacro"/> |
| 139 | + <!-- Args --> |
| 140 | + <xacro:arg name="mock_pruner_prefix" default="mock_pruner__" /> |
| 141 | + <xacro:arg name="mesh_base_path" default="" /> |
| 142 | + <xacro:arg name="tof0_offset" default="0.1 0.0 0.142" /> |
| 143 | + <xacro:arg name="tof1_offset" default="-0.1 0.0 0.142"/> |
| 144 | + |
| 145 | + <!-- mock_pruner --> |
| 146 | + <xacro:mock_pruner_macro |
| 147 | + eef_prefix="$(arg mock_pruner_prefix)" |
| 148 | + parent_link="${resolved_parent_link}" |
| 149 | + mesh_base_path="$(arg mesh_base_path)" |
| 150 | + urdf_base_path="$(arg urdf_base_path)" |
| 151 | + tof0_offset='$(arg tof0_offset)' |
| 152 | + tof1_offset='$(arg tof1_offset)' |
| 153 | + camera_offset='' |
| 154 | + /> |
| 155 | + </xacro:if> |
| 156 | + <!-- <link name="$(arg robot_part${stack_qty - 1})" /> --> |
| 157 | + |
| 158 | + |
| 159 | + <!-- </xacro:unless> --> |
| 160 | + |
| 161 | + <!-- call macro recursively --> |
| 162 | + <xacro:main_loop stack_qty="${stack_qty - 1}"/> |
| 163 | + </xacro:if> |
| 164 | + </xacro:macro> |
| 165 | + |
| 166 | + <!-- call main loop --> |
| 167 | + <xacro:main_loop stack_qty="$(arg robot_stack_qty)"/> |
| 168 | + |
| 169 | + |
| 170 | + |
| 171 | +</robot> |
0 commit comments