SMACC2
Functions
sm_test_moveit_ur5e_gazebo_sim Namespace Reference

Functions

def construct_angle_radians (loader, node)
 
def construct_angle_degrees (loader, node)
 
def load_yaml (package_name, file_path)
 
def launch_setup (context, *args, **kwargs)
 
def generate_launch_description ()
 

Function Documentation

◆ construct_angle_degrees()

def sm_test_moveit_ur5e_gazebo_sim.construct_angle_degrees (   loader,
  node 
)
utility function for converting degrees into radians from yaml.

Definition at line 42 of file sm_test_moveit_ur5e_gazebo_sim.launch.py.

42def construct_angle_degrees(loader, node):
43 """utility function for converting degrees into radians from yaml."""
44 return math.radians(construct_angle_radians(loader, node))
45
46

References construct_angle_radians().

Here is the call graph for this function:

◆ construct_angle_radians()

def sm_test_moveit_ur5e_gazebo_sim.construct_angle_radians (   loader,
  node 
)
utility function to construct radian values from yaml.

Definition at line 33 of file sm_test_moveit_ur5e_gazebo_sim.launch.py.

33def construct_angle_radians(loader, node):
34 """utility function to construct radian values from yaml."""
35 value = loader.construct_scalar(node)
36 try:
37 return float(value)
38 except SyntaxError:
39 raise Exception("invalid expression: %s" % value)
40
41

Referenced by construct_angle_degrees().

Here is the caller graph for this function:

◆ generate_launch_description()

def sm_test_moveit_ur5e_gazebo_sim.generate_launch_description ( )

Definition at line 212 of file sm_test_moveit_ur5e_gazebo_sim.launch.py.

213 declared_arguments = []
214 # General arguments
215 declared_arguments.append(
216 DeclareLaunchArgument(
217 "runtime_config_package",
218 default_value="ur_bringup",
219 description='Package with the controller\'s configuration in "config" folder. \
220 Usually the argument is not set, it enables use of a custom setup.',
221 )
222 )
223 declared_arguments.append(
224 DeclareLaunchArgument(
225 "controllers_file",
226 default_value="ur_controllers.yaml",
227 description="YAML file with the controllers configuration.",
228 )
229 )
230 declared_arguments.append(
231 DeclareLaunchArgument(
232 "description_package",
233 default_value="ur_description",
234 description="Description package with robot URDF/XACRO files. Usually the argument \
235 is not set, it enables use of a custom description.",
236 )
237 )
238 declared_arguments.append(
239 DeclareLaunchArgument(
240 "description_file",
241 default_value="ur.urdf.xacro",
242 description="URDF/XACRO description file with the robot.",
243 )
244 )
245 declared_arguments.append(
246 DeclareLaunchArgument(
247 "moveit_config_package",
248 default_value="ur_moveit_config",
249 description="MoveIt config package with robot SRDF/XACRO files. Usually the argument \
250 is not set, it enables use of a custom moveit config.",
251 )
252 )
253 declared_arguments.append(
254 DeclareLaunchArgument(
255 "moveit_config_file",
256 default_value="ur.srdf.xacro",
257 description="MoveIt SRDF/XACRO description file with the robot.",
258 )
259 )
260 declared_arguments.append(
261 DeclareLaunchArgument(
262 "prefix",
263 default_value='""',
264 description="Prefix of the joint names, useful for \
265 multi-robot setup. If changed than also joint names in the controllers' configuration \
266 have to be updated.",
267 )
268 )
269 declared_arguments.append(
270 DeclareLaunchArgument("launch_rviz", default_value="true", description="Launch RViz?")
271 )
272
273 return LaunchDescription(declared_arguments + [OpaqueFunction(function=launch_setup)])

◆ launch_setup()

def sm_test_moveit_ur5e_gazebo_sim.launch_setup (   context,
args,
**  kwargs 
)

Definition at line 67 of file sm_test_moveit_ur5e_gazebo_sim.launch.py.

67def launch_setup(context, *args, **kwargs):
68
69 ur_type = "ur5e"
70
71 # General arguments
72 runtime_config_package = LaunchConfiguration("runtime_config_package")
73 controllers_file = LaunchConfiguration("controllers_file")
74 description_package = LaunchConfiguration("description_package")
75 description_file = LaunchConfiguration("description_file")
76 moveit_config_package = LaunchConfiguration("moveit_config_package")
77 moveit_config_file = LaunchConfiguration("moveit_config_file")
78 prefix = LaunchConfiguration("prefix")
79
80 robot_description_content = Command(
81 [
82 PathJoinSubstitution([FindExecutable(name="xacro")]),
83 " ",
84 PathJoinSubstitution(
85 [FindPackageShare(description_package), "urdf", description_file]
86 ),
87 " ",
88 "name:=",
89 "ur",
90 " ",
91 "ur_type:=",
92 ur_type,
93 " ",
94 "prefix:=",
95 prefix,
96 " ",
97 ]
98 )
99 robot_description = {"robot_description": robot_description_content}
100
101 # MoveIt Configuration
102 robot_description_semantic_content = Command(
103 [
104 PathJoinSubstitution([FindExecutable(name="xacro")]),
105 " ",
106 PathJoinSubstitution(
107 [FindPackageShare(moveit_config_package), "srdf", moveit_config_file]
108 ),
109 " ",
110 "name:=",
111 "ur",
112 " ",
113 "ur_type:=",
114 ur_type,
115 " ",
116 "prefix:=",
117 prefix,
118 " ",
119 ]
120 )
121 robot_description_semantic = {"robot_description_semantic": robot_description_semantic_content}
122
123 kinematics_yaml = load_yaml("ur_moveit_config", "config/kinematics.yaml")
124 robot_description_kinematics = {"robot_description_kinematics": kinematics_yaml}
125
126 smacc2_sm_config = PathJoinSubstitution(
127 [
128 FindPackageShare("sm_test_moveit_ur5_sim"),
129 "config",
130 "sm_test_moveit_ur5_sim_config.yaml",
131 ]
132 )
133
134 sm_test_moveit_ur5_sim_node = Node(
135 package="sm_test_moveit_ur5_sim",
136 executable="sm_test_moveit_ur5_sim_node",
137 # prefix="xterm -xrm 'XTerm*scrollBar: true' -xrm 'xterm*rightScrollBar: true' -hold -sl 10000 -geometry 1000x600 -e gdbserver localhost:3000",
138 prefix="xterm -xrm 'XTerm*scrollBar: true' -xrm 'xterm*rightScrollBar: true' -hold -sl 10000 -geometry 1000x600 -e",
139 parameters=[
140 {"use_sim_time": True},
141 robot_description,
142 robot_description_semantic,
143 robot_description_kinematics,
144 smacc2_sm_config,
145 ],
146 )
147
148 smacc2_sm_rviz = PathJoinSubstitution(
149 [
150 FindPackageShare("sm_test_moveit_ur5_sim"),
151 "rviz",
152 "rviz.rviz",
153 ]
154 )
155
156 # Launch rviz
157 start_rviz_cmd = Node(
158 package="rviz2",
159 executable="rviz2",
160 name="rviz2",
161 arguments=["-d", smacc2_sm_rviz],
162 output="screen",
163 parameters=[
164 {"use_sim_time": True},
165 robot_description,
166 robot_description_semantic,
167 robot_description_kinematics,
168 ],
169 )
170
171 ur_control_launch = IncludeLaunchDescription(
172 PythonLaunchDescriptionSource(
173 [FindPackageShare("ur_simulation_gazebo"), "/launch", "/ur_sim_control.launch.py"]
174 ),
175 launch_arguments={
176 "ur_type": ur_type,
177 "runtime_config_package": runtime_config_package,
178 "controllers_file": controllers_file,
179 "description_package": description_package,
180 "description_file": description_file,
181 "prefix": prefix,
182 "launch_rviz": "false",
183 }.items(),
184 )
185
186 ur_moveit_launch = IncludeLaunchDescription(
187 PythonLaunchDescriptionSource(
188 [FindPackageShare("ur_moveit_config"), "/launch", "/ur_moveit.launch.py"]
189 ),
190 launch_arguments={
191 "ur_type": ur_type,
192 "description_package": description_package,
193 "description_file": description_file,
194 "moveit_config_package": moveit_config_package,
195 "moveit_config_file": moveit_config_file,
196 "use_sim_time": "true",
197 "prefix": prefix,
198 "launch_rviz": "false",
199 }.items(),
200 )
201
202 nodes_to_launch = [
203 ur_control_launch,
204 ur_moveit_launch,
205 sm_test_moveit_ur5_sim_node,
206 start_rviz_cmd,
207 ]
208
209 return nodes_to_launch
210
211

References load_yaml().

Here is the call graph for this function:

◆ load_yaml()

def sm_test_moveit_ur5e_gazebo_sim.load_yaml (   package_name,
  file_path 
)

Definition at line 47 of file sm_test_moveit_ur5e_gazebo_sim.launch.py.

47def load_yaml(package_name, file_path):
48 package_path = get_package_share_directory(package_name)
49 absolute_file_path = os.path.join(package_path, file_path)
50
51 try:
52 yaml.SafeLoader.add_constructor("!radians", construct_angle_radians)
53 yaml.SafeLoader.add_constructor("!degrees", construct_angle_degrees)
54 except Exception:
55 raise Exception("yaml support not available; install python-yaml")
56
57 try:
58 with open(absolute_file_path) as file:
59 return yaml.safe_load(file)
60 except OSError: # parent of IOError, OSError *and* WindowsError where available
61 return None
62
63
64# TODO(destogl): END this should be removed when MoveIt can handle parameters properly
65
66

Referenced by launch_setup().

Here is the caller graph for this function: