From 2fe4e3a1d1b94dc54b51e8ad623027b3a70b9b37 Mon Sep 17 00:00:00 2001 From: Felix Exner Date: Wed, 15 Nov 2023 05:11:05 +0000 Subject: [PATCH 1/3] Remove ros2_control tag from package There definitively is a need for using the robot description without the ros2_control tag in general e.g. when simply viewing the robot model. This commit removes the dependency to the ros2_control tag from the macro instantiating a robot and adds new files describing the control mechanisms of the individual joints and sensors. These files can be included in ros2_control files setting up a specific control structure (e.g. hardware driver, mock hardware, gazebo). --- urdf/inc/ur_joint_control.xacro | 128 ++++++++++++ urdf/inc/ur_sensors.xacro | 13 ++ urdf/ur.ros2_control.xacro | 349 -------------------------------- urdf/ur.urdf.xacro | 85 +------- urdf/ur_macro.xacro | 74 +------ 5 files changed, 147 insertions(+), 502 deletions(-) create mode 100644 urdf/inc/ur_joint_control.xacro create mode 100644 urdf/inc/ur_sensors.xacro delete mode 100644 urdf/ur.ros2_control.xacro diff --git a/urdf/inc/ur_joint_control.xacro b/urdf/inc/ur_joint_control.xacro new file mode 100644 index 0000000..2226fa0 --- /dev/null +++ b/urdf/inc/ur_joint_control.xacro @@ -0,0 +1,128 @@ + + + + + + {-2*pi} + {2*pi} + + + -3.15 + 3.15 + + + + ${initial_positions['shoulder_pan_joint']} + + + 0.0 + + + 0.0 + + + + + {-2*pi} + {2*pi} + + + -3.15 + 3.15 + + + + ${initial_positions['shoulder_lift_joint']} + + + 0.0 + + + 0.0 + + + + + {-pi} + {pi} + + + -3.15 + 3.15 + + + + ${initial_positions['elbow_joint']} + + + 0.0 + + + 0.0 + + + + + {-2*pi} + {2*pi} + + + -3.2 + 3.2 + + + + ${initial_positions['wrist_1_joint']} + + + 0.0 + + + 0.0 + + + + + {-2*pi} + {2*pi} + + + -3.2 + 3.2 + + + + ${initial_positions['wrist_2_joint']} + + + 0.0 + + + 0.0 + + + + + {-2*pi} + {2*pi} + + + -3.2 + 3.2 + + + + ${initial_positions['wrist_3_joint']} + + + 0.0 + + + 0.0 + + + + diff --git a/urdf/inc/ur_sensors.xacro b/urdf/inc/ur_sensors.xacro new file mode 100644 index 0000000..13f60ec --- /dev/null +++ b/urdf/inc/ur_sensors.xacro @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/urdf/ur.ros2_control.xacro b/urdf/ur.ros2_control.xacro deleted file mode 100644 index 98f7047..0000000 --- a/urdf/ur.ros2_control.xacro +++ /dev/null @@ -1,349 +0,0 @@ - - - - - - - - - gazebo_ros2_control/GazeboSystem - - - ign_ros2_control/IgnitionSystem - - - mock_components/GenericSystem - ${mock_sensor_commands} - 0.0 - - - ur_robot_driver/URPositionHardwareInterface - ${robot_ip} - ${script_filename} - ${output_recipe_filename} - ${input_recipe_filename} - ${headless_mode} - ${reverse_port} - ${script_sender_port} - ${reverse_ip} - ${script_command_port} - ${trajectory_port} - ${tf_prefix} - ${non_blocking_read} - 2000 - 0.03 - ${use_tool_communication} - ${hash_kinematics} - ${tool_voltage} - ${tool_parity} - ${tool_baud_rate} - ${tool_stop_bits} - ${tool_rx_idle_chars} - ${tool_tx_idle_chars} - ${tool_device_name} - ${tool_tcp_port} - ${keep_alive_count} - - - - - {-2*pi} - {2*pi} - - - -3.15 - 3.15 - - - - ${initial_positions['shoulder_pan_joint']} - - - 0.0 - - - 0.0 - - - - - {-2*pi} - {2*pi} - - - -3.15 - 3.15 - - - - ${initial_positions['shoulder_lift_joint']} - - - 0.0 - - - 0.0 - - - - - {-pi} - {pi} - - - -3.15 - 3.15 - - - - ${initial_positions['elbow_joint']} - - - 0.0 - - - 0.0 - - - - - {-2*pi} - {2*pi} - - - -3.2 - 3.2 - - - - ${initial_positions['wrist_1_joint']} - - - 0.0 - - - 0.0 - - - - - {-2*pi} - {2*pi} - - - -3.2 - 3.2 - - - - ${initial_positions['wrist_2_joint']} - - - 0.0 - - - 0.0 - - - - - {-2*pi} - {2*pi} - - - -3.2 - 3.2 - - - - ${initial_positions['wrist_3_joint']} - - - 0.0 - - - 0.0 - - - - - - - - - - - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/urdf/ur.urdf.xacro b/urdf/ur.urdf.xacro index 52ed07c..710d9da 100644 --- a/urdf/ur.urdf.xacro +++ b/urdf/ur.urdf.xacro @@ -19,40 +19,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -66,59 +35,11 @@ kinematics_parameters_file="$(arg kinematics_params)" physical_parameters_file="$(arg physical_params)" visual_parameters_file="$(arg visual_params)" - transmission_hw_interface="$(arg transmission_hw_interface)" safety_limits="$(arg safety_limits)" safety_pos_margin="$(arg safety_pos_margin)" safety_k_position="$(arg safety_k_position)" - use_mock_hardware="$(arg use_mock_hardware)" - mock_sensor_commands="$(arg mock_sensor_commands)" - sim_gazebo="$(arg sim_gazebo)" - sim_ignition="$(arg sim_ignition)" - headless_mode="$(arg headless_mode)" - initial_positions="${xacro.load_yaml(initial_positions_file)}" - use_tool_communication="$(arg use_tool_communication)" - tool_voltage="$(arg tool_voltage)" - tool_parity="$(arg tool_parity)" - tool_baud_rate="$(arg tool_baud_rate)" - tool_stop_bits="$(arg tool_stop_bits)" - tool_rx_idle_chars="$(arg tool_rx_idle_chars)" - tool_tx_idle_chars="$(arg tool_tx_idle_chars)" - tool_device_name="$(arg tool_device_name)" - tool_tcp_port="$(arg tool_tcp_port)" - robot_ip="$(arg robot_ip)" - script_filename="$(arg script_filename)" - output_recipe_filename="$(arg output_recipe_filename)" - input_recipe_filename="$(arg input_recipe_filename)" - reverse_ip="$(arg reverse_ip)" - script_command_port="$(arg script_command_port)" - reverse_port="$(arg reverse_port)" - script_sender_port="$(arg script_sender_port)" - trajectory_port="$(arg trajectory_port)" + force_abs_paths="$(arg force_abs_paths)" > - - - - - - - - $(arg simulation_controllers) - - - - - - - - - - - $(arg simulation_controllers) - $(arg tf_prefix)controller_manager - - - - diff --git a/urdf/ur_macro.xacro b/urdf/ur_macro.xacro index b418d12..39c094d 100644 --- a/urdf/ur_macro.xacro +++ b/urdf/ur_macro.xacro @@ -50,7 +50,6 @@ - Muhammad Asif Rana --> - + force_abs_paths:=false + "> - - - - - - - - - - + force_abs_paths="${force_abs_paths}"/> From c4a50a8eeb0b4bdeaab37df6af29659cd9917096 Mon Sep 17 00:00:00 2001 From: Felix Exner Date: Wed, 15 Nov 2023 05:54:02 +0000 Subject: [PATCH 2/3] Add mock components ros2_control example --- README.md | 8 ++++ urdf/ros2_control_mock_hardware.xacro | 30 +++++++++++++ urdf/ur_mocked.urdf.xacro | 61 +++++++++++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 urdf/ros2_control_mock_hardware.xacro create mode 100644 urdf/ur_mocked.urdf.xacro diff --git a/README.md b/README.md index 0cf7640..be4edff 100644 --- a/README.md +++ b/README.md @@ -81,3 +81,11 @@ parameters file. As mentioned above, see the `urdf/ur.urdf.xacro` file as an example to integrate a UR robot into your scene description. Basically, you could create a copy of that file and extend it with the modifications from your specific scene. + +### Using description with ros2_control +The description itself does not contain a `ros2_control` tag. However, the package provides a couple +of helper files to create your own `ros2_control` tag describing the robot's joint control +mechanisms. See the [`urdf/ur_mocked.urdf.xacro`](urdf/ur_mocked.urdf.xacro) +file as an example using [mock +hardware](https://control.ros.org/master/doc/ros2_control/hardware_interface/doc/mock_components_userdoc.html) +to control the robot. diff --git a/urdf/ros2_control_mock_hardware.xacro b/urdf/ros2_control_mock_hardware.xacro new file mode 100644 index 0000000..042293c --- /dev/null +++ b/urdf/ros2_control_mock_hardware.xacro @@ -0,0 +1,30 @@ + + + + + + + + + + + mock_components/GenericSystem + ${mock_sensor_commands} + 0.0 + + + + + + + diff --git a/urdf/ur_mocked.urdf.xacro b/urdf/ur_mocked.urdf.xacro new file mode 100644 index 0000000..519bfb2 --- /dev/null +++ b/urdf/ur_mocked.urdf.xacro @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 059f026d52c171f2124278f206dff7e88a01eb13 Mon Sep 17 00:00:00 2001 From: Felix Exner Date: Wed, 15 Nov 2023 06:06:52 +0000 Subject: [PATCH 3/3] Parametrize urdf tests with all robot models, tf_prefix and mock hardware --- test/test_ur_urdf_xacro.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/test_ur_urdf_xacro.py b/test/test_ur_urdf_xacro.py index b19428d..fd837b2 100644 --- a/test/test_ur_urdf_xacro.py +++ b/test/test_ur_urdf_xacro.py @@ -32,20 +32,23 @@ import shutil import subprocess import tempfile +import pytest from ament_index_python.packages import get_package_share_directory -def test_ur_urdf_xacro(): +@pytest.mark.parametrize( + "ur_type", ["ur3", "ur3e", "ur5", "ur5e", "ur10", "ur10e", "ur16e", "ur20"] +) +@pytest.mark.parametrize("description_file", ["ur.urdf.xacro", "ur_mocked.urdf.xacro"]) +@pytest.mark.parametrize("prefix", ["", "my_ur_"]) +def test_ur_urdf_xacro(ur_type, description_file, prefix): # Initialize Arguments - ur_type = "ur3" safety_limits = "true" safety_pos_margin = "0.15" safety_k_position = "20" # General Arguments description_package = "ur_description" - description_file = "ur.urdf.xacro" - prefix = '""' joint_limit_params = os.path.join( get_package_share_directory(description_package), "config", ur_type, "joint_limits.yaml"