Skip to content

Commit 70a6d16

Browse files
urfeexmergify[bot]
authored andcommitted
Add support for UR15 (#97)
(cherry picked from commit 9dc25fb) # Conflicts: # ur_simulation_gz/test/test_description.py # ur_simulation_gz/urdf/ur_gz.urdf.xacro
1 parent 009b471 commit 70a6d16

File tree

5 files changed

+224
-1
lines changed

5 files changed

+224
-1
lines changed

ur_simulation_gz/launch/ur_sim_control.launch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ def generate_launch_description():
225225
"ur10e",
226226
"ur12e",
227227
"ur16e",
228+
"ur15",
228229
"ur20",
229230
"ur30",
230231
],

ur_simulation_gz/launch/ur_sim_moveit.launch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def generate_launch_description():
106106
"ur10e",
107107
"ur12e",
108108
"ur16e",
109+
"ur15",
109110
"ur20",
110111
"ur30",
111112
],
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Copyright (c) 2023 FZI Forschungszentrum Informatik
2+
#
3+
# Redistribution and use in source and binary forms, with or without
4+
# modification, are permitted provided that the following conditions are met:
5+
#
6+
# * Redistributions of source code must retain the above copyright
7+
# notice, this list of conditions and the following disclaimer.
8+
#
9+
# * Redistributions in binary form must reproduce the above copyright
10+
# notice, this list of conditions and the following disclaimer in the
11+
# documentation and/or other materials provided with the distribution.
12+
#
13+
# * Neither the name of the {copyright_holder} nor the names of its
14+
# contributors may be used to endorse or promote products derived from
15+
# this software without specific prior written permission.
16+
#
17+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27+
# POSSIBILITY OF SUCH DAMAGE.
28+
#
29+
# Author: Lukas Sackewitz
30+
31+
import os
32+
import shutil
33+
import subprocess
34+
import tempfile
35+
import pytest
36+
37+
from ament_index_python.packages import get_package_share_directory
38+
39+
40+
@pytest.mark.parametrize(
41+
"ur_type",
42+
[
43+
"ur3",
44+
"ur3e",
45+
"ur5",
46+
"ur5e",
47+
"ur7e",
48+
"ur10",
49+
"ur10e",
50+
"ur12e",
51+
"ur16e",
52+
"ur15",
53+
"ur20",
54+
"ur30",
55+
],
56+
)
57+
@pytest.mark.parametrize("prefix", ["", "my_ur_"])
58+
def test_ur_urdf_xacro(ur_type, prefix):
59+
# Initialize Arguments
60+
safety_limits = "true"
61+
safety_pos_margin = "0.15"
62+
safety_k_position = "20"
63+
# General Arguments
64+
description_package = "ur_description"
65+
66+
joint_limit_params = os.path.join(
67+
get_package_share_directory(description_package), "config", ur_type, "joint_limits.yaml"
68+
)
69+
kinematics_params = os.path.join(
70+
get_package_share_directory(description_package),
71+
"config",
72+
ur_type,
73+
"default_kinematics.yaml",
74+
)
75+
physical_params = os.path.join(
76+
get_package_share_directory(description_package),
77+
"config",
78+
ur_type,
79+
"physical_parameters.yaml",
80+
)
81+
visual_params = os.path.join(
82+
get_package_share_directory(description_package),
83+
"config",
84+
ur_type,
85+
"visual_parameters.yaml",
86+
)
87+
88+
description_file_path = os.path.join(
89+
get_package_share_directory("ur_simulation_gz"), "urdf", "ur_gz.urdf.xacro"
90+
)
91+
92+
(_, tmp_urdf_output_file) = tempfile.mkstemp(suffix=".urdf")
93+
94+
# Compose `xacro` and `check_urdf` command
95+
xacro_command = (
96+
f"{shutil.which('xacro')}"
97+
f" {description_file_path}"
98+
f" joint_limit_params:={joint_limit_params}"
99+
f" kinematics_params:={kinematics_params}"
100+
f" physical_params:={physical_params}"
101+
f" visual_params:={visual_params}"
102+
f" safety_limits:={safety_limits}"
103+
f" safety_pos_margin:={safety_pos_margin}"
104+
f" safety_k_position:={safety_k_position}"
105+
f" name:={ur_type}"
106+
f" prefix:={prefix}"
107+
f" > {tmp_urdf_output_file}"
108+
)
109+
check_urdf_command = f"{shutil.which('check_urdf')} {tmp_urdf_output_file}"
110+
111+
# Try to call processes but finally remove the temp file
112+
try:
113+
xacro_process = subprocess.run(
114+
xacro_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True
115+
)
116+
117+
assert xacro_process.returncode == 0, " --- XACRO command failed ---"
118+
119+
check_urdf_process = subprocess.run(
120+
check_urdf_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True
121+
)
122+
123+
assert (
124+
check_urdf_process.returncode == 0
125+
), "\n --- URDF check failed! --- \nYour xacro does not unfold into a proper urdf robot description. Please check your xacro file."
126+
127+
finally:
128+
os.remove(tmp_urdf_output_file)
129+
130+
131+
if __name__ == "__main__":
132+
test_ur_urdf_xacro()

ur_simulation_gz/test/test_gz.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
# might change, once the gz launch system migration is done using gzserver and such....
7575
# @launch_testing.parametrize(
7676
# "ur_type",
77-
# ["ur3", "ur3e", "ur5", "ur5e", "ur7e", "ur10", "ur10e", "ur12e", "ur16e", "ur20", "ur30"],
77+
# ["ur3", "ur3e", "ur5", "ur5e", "ur7e", "ur10", "ur10e", "ur12e", "ur16e", "ur15", "ur20", "ur30"],
7878
# )
7979
@pytest.mark.launch_test
8080
def generate_test_description():
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?xml version="1.0"?>
2+
<robot xmlns:xacro="http://wiki.ros.org/xacro" name="$(arg name)">
3+
<!-- robot name parameter -->
4+
<xacro:arg name="name" default="ur"/>
5+
<!-- import main macro -->
6+
<xacro:include filename="$(find ur_description)/urdf/ur_macro.xacro"/>
7+
8+
<xacro:include filename="$(find ur_simulation_gz)/urdf/ur_gz.ros2_control.xacro" />
9+
10+
<!-- possible 'ur_type' values: ur3, ur3e, ur5, ur5e, ur7e, ur10, ur10e, ur12e, ur16e, ur15, ur20, ur30 -->
11+
<!-- the default value should raise an error in case this was called without defining the type -->
12+
<xacro:arg name="ur_type" default="ur5x"/>
13+
14+
<!-- parameters -->
15+
<xacro:arg name="tf_prefix" default="" />
16+
<xacro:arg name="joint_limit_params" default="$(find ur_description)/config/$(arg ur_type)/joint_limits.yaml"/>
17+
<xacro:arg name="kinematics_params" default="$(find ur_description)/config/$(arg ur_type)/default_kinematics.yaml"/>
18+
<xacro:arg name="physical_params" default="$(find ur_description)/config/$(arg ur_type)/physical_parameters.yaml"/>
19+
<xacro:arg name="visual_params" default="$(find ur_description)/config/$(arg ur_type)/visual_parameters.yaml"/>
20+
<xacro:arg name="transmission_hw_interface" default=""/>
21+
<xacro:arg name="safety_limits" default="false"/>
22+
<xacro:arg name="safety_pos_margin" default="0.15"/>
23+
<xacro:arg name="safety_k_position" default="20"/>
24+
25+
<xacro:arg name="simulation_controllers" default="" />
26+
<xacro:arg name="ros_namespace" default="" />
27+
28+
<!-- create link fixed to the "world" -->
29+
<link name="world" />
30+
31+
<link name="ground_plane">
32+
<visual>
33+
<origin rpy="0 0 0" xyz="0 0 0"/>
34+
<geometry>
35+
<box size="5 5 0"/>
36+
</geometry>
37+
<material name="ground_white">
38+
<color rgba="1 1 1 0.5"/>
39+
</material>
40+
</visual>
41+
<collision>
42+
<origin rpy="0 0 0" xyz="0 0 0"/>
43+
<geometry>
44+
<box size="5 5 0"/>
45+
</geometry>
46+
</collision>
47+
</link>
48+
49+
<joint name="ground_plane_joint" type="fixed">
50+
<origin xyz="0 0 -0.01" rpy="0 0 0"/>
51+
<parent link="world"/>
52+
<child link="ground_plane"/>
53+
</joint>
54+
55+
<!-- arm -->
56+
<xacro:ur_robot
57+
name="$(arg name)"
58+
tf_prefix="$(arg tf_prefix)"
59+
parent="world"
60+
joint_limits_parameters_file="$(arg joint_limit_params)"
61+
kinematics_parameters_file="$(arg kinematics_params)"
62+
physical_parameters_file="$(arg physical_params)"
63+
visual_parameters_file="$(arg visual_params)"
64+
safety_limits="$(arg safety_limits)"
65+
safety_pos_margin="$(arg safety_pos_margin)"
66+
safety_k_position="$(arg safety_k_position)"
67+
force_abs_paths="true"
68+
>
69+
<origin xyz="0 0 0" rpy="0 0 0" /> <!-- position robot in the world -->
70+
</xacro:ur_robot>
71+
72+
<gazebo reference="world">
73+
</gazebo>
74+
<gazebo>
75+
<plugin filename="gz_ros2_control-system" name="gz_ros2_control::GazeboSimROS2ControlPlugin">
76+
<parameters>$(arg simulation_controllers)</parameters>
77+
<ros>
78+
<namespace>$(arg ros_namespace)</namespace>
79+
</ros>
80+
</plugin>
81+
</gazebo>
82+
83+
<!-- ros2 control instance -->
84+
<xacro:ur_ros2_control
85+
name="$(arg name)"
86+
tf_prefix="$(arg tf_prefix)"
87+
transmission_hw_interface="$(arg transmission_hw_interface)"
88+
/>
89+
</robot>

0 commit comments

Comments
 (0)