Skip to content

Commit 94d3b20

Browse files
committed
Format remaining files
1 parent 5eedc6f commit 94d3b20

5 files changed

Lines changed: 410 additions & 279 deletions

File tree

Industrial/ur5_gripper_description/launch/gazebo.launch.py

Lines changed: 55 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,22 @@
33

44
import os
55
from launch import LaunchDescription
6-
from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription, RegisterEventHandler, SetEnvironmentVariable
6+
from launch.actions import (
7+
DeclareLaunchArgument,
8+
ExecuteProcess,
9+
IncludeLaunchDescription,
10+
RegisterEventHandler,
11+
SetEnvironmentVariable,
12+
)
713
from launch.conditions import IfCondition
814
from launch.event_handlers import OnProcessExit
915
from launch.launch_description_sources import PythonLaunchDescriptionSource
10-
from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution
16+
from launch.substitutions import (
17+
Command,
18+
FindExecutable,
19+
LaunchConfiguration,
20+
PathJoinSubstitution,
21+
)
1122
from launch_ros.actions import Node
1223
from launch_ros.substitutions import FindPackageShare
1324
from ament_index_python.packages import get_package_share_directory
@@ -19,20 +30,20 @@ def generate_launch_description():
1930
pkg_share_dir = get_package_share_directory("ur5_gripper_description")
2031
# Go up from install/ur5_gripper_description/share/ur5_gripper_description to install/
2132
workspace_dir = os.path.dirname(os.path.dirname(os.path.dirname(pkg_share_dir)))
22-
33+
2334
# Prepare environment variables for Gazebo
24-
gz_lib_path = os.path.join(workspace_dir, 'gz_ros2_control', 'lib')
25-
ur_share = os.path.join(workspace_dir, 'ur5_gripper_description', 'share')
26-
robotiq_share = os.path.join(workspace_dir, 'robotiq_description', 'share')
27-
35+
gz_lib_path = os.path.join(workspace_dir, "gz_ros2_control", "lib")
36+
ur_share = os.path.join(workspace_dir, "ur5_gripper_description", "share")
37+
robotiq_share = os.path.join(workspace_dir, "robotiq_description", "share")
38+
2839
gz_env = {
29-
'GZ_SIM_RESOURCE_PATH': f"{ur_share}:{robotiq_share}:{os.environ.get('GZ_SIM_RESOURCE_PATH', '')}",
30-
'GZ_SIM_SYSTEM_PLUGIN_PATH': f"{gz_lib_path}:{os.environ.get('GZ_SIM_SYSTEM_PLUGIN_PATH', '')}",
31-
'LD_LIBRARY_PATH': f"{gz_lib_path}:{os.environ.get('LD_LIBRARY_PATH', '')}"
40+
"GZ_SIM_RESOURCE_PATH": f"{ur_share}:{robotiq_share}:{os.environ.get('GZ_SIM_RESOURCE_PATH', '')}",
41+
"GZ_SIM_SYSTEM_PLUGIN_PATH": f"{gz_lib_path}:{os.environ.get('GZ_SIM_SYSTEM_PLUGIN_PATH', '')}",
42+
"LD_LIBRARY_PATH": f"{gz_lib_path}:{os.environ.get('LD_LIBRARY_PATH', '')}",
3243
}
3344
# Declare arguments
3445
declared_arguments = []
35-
46+
3647
declared_arguments.append(
3748
DeclareLaunchArgument(
3849
"ur_type",
@@ -41,23 +52,23 @@ def generate_launch_description():
4152
choices=["ur3", "ur3e", "ur5", "ur5e", "ur10", "ur10e", "ur16e"],
4253
)
4354
)
44-
55+
4556
declared_arguments.append(
4657
DeclareLaunchArgument(
4758
"prefix",
4859
default_value='""',
4960
description="Prefix of the joint names",
5061
)
5162
)
52-
63+
5364
declared_arguments.append(
5465
DeclareLaunchArgument(
5566
"launch_rviz",
5667
default_value="false",
5768
description="Launch RViz?",
5869
)
5970
)
60-
71+
6172
declared_arguments.append(
6273
DeclareLaunchArgument(
6374
"gz_args",
@@ -76,15 +87,15 @@ def generate_launch_description():
7687
xacro_file = os.path.join(
7788
get_package_share_directory("ur5_gripper_description"),
7889
"urdf",
79-
"ur5_robotiq85_gripper.urdf.xacro"
90+
"ur5_robotiq85_gripper.urdf.xacro",
8091
)
81-
92+
8293
controllers_file = os.path.join(
8394
get_package_share_directory("ur5_gripper_description"),
8495
"config",
85-
"ur5_controllers.yaml"
96+
"ur5_controllers.yaml",
8697
)
87-
98+
8899
# Process xacro directly to avoid Command() stderr issues
89100
robot_description_content = xacro.process_file(
90101
xacro_file,
@@ -96,20 +107,17 @@ def generate_launch_description():
96107
"sim_gazebo": "false",
97108
"sim_gz": "true",
98109
"simulation_controllers": controllers_file,
99-
}
110+
},
100111
).toxml()
101-
112+
102113
robot_description = {"robot_description": robot_description_content}
103114

104115
# Node for robot state publisher
105116
node_robot_state_publisher = Node(
106117
package="robot_state_publisher",
107118
executable="robot_state_publisher",
108119
output="screen",
109-
parameters=[
110-
robot_description,
111-
{"use_sim_time": True}
112-
],
120+
parameters=[robot_description, {"use_sim_time": True}],
113121
)
114122

115123
# Gazebo Sim (Harmonic) - with environment variables
@@ -118,23 +126,22 @@ def generate_launch_description():
118126
f'export GZ_SIM_SYSTEM_PLUGIN_PATH="{gz_env["GZ_SIM_SYSTEM_PLUGIN_PATH"]}" && '
119127
f'export GZ_SIM_RESOURCE_PATH="{gz_env["GZ_SIM_RESOURCE_PATH"]}" && '
120128
f'export LD_LIBRARY_PATH="{gz_env["LD_LIBRARY_PATH"]}" && '
121-
'gz sim -r -v 4 empty.sdf'
122-
)
123-
124-
gazebo = ExecuteProcess(
125-
cmd=['bash', '-c', gz_cmd],
126-
output='screen',
127-
shell=False
129+
"gz sim -r -v 4 empty.sdf"
128130
)
129131

132+
gazebo = ExecuteProcess(cmd=["bash", "-c", gz_cmd], output="screen", shell=False)
133+
130134
# Spawn robot
131135
spawn_entity = Node(
132136
package="ros_gz_sim",
133137
executable="create",
134138
arguments=[
135-
"-topic", "robot_description",
136-
"-name", "ur5_robotiq",
137-
"-allow_renaming", "true",
139+
"-topic",
140+
"robot_description",
141+
"-name",
142+
"ur5_robotiq",
143+
"-allow_renaming",
144+
"true",
138145
],
139146
output="screen",
140147
)
@@ -152,7 +159,11 @@ def generate_launch_description():
152159
load_joint_state_broadcaster = Node(
153160
package="controller_manager",
154161
executable="spawner",
155-
arguments=["joint_state_broadcaster", "--controller-manager", "/controller_manager"],
162+
arguments=[
163+
"joint_state_broadcaster",
164+
"--controller-manager",
165+
"/controller_manager",
166+
],
156167
output="screen",
157168
parameters=[{"use_sim_time": True}],
158169
)
@@ -165,7 +176,7 @@ def generate_launch_description():
165176
output="screen",
166177
parameters=[{"use_sim_time": True}],
167178
)
168-
179+
169180
# Load gripper controller
170181
load_gripper_controller = Node(
171182
package="controller_manager",
@@ -179,7 +190,7 @@ def generate_launch_description():
179190
rviz_config_file = PathJoinSubstitution(
180191
[FindPackageShare("ur5_gripper_description"), "rviz", "view_robot.rviz"]
181192
)
182-
193+
183194
rviz_node = Node(
184195
package="rviz2",
185196
executable="rviz2",
@@ -198,13 +209,15 @@ def generate_launch_description():
198209
)
199210
)
200211

201-
delay_joint_trajectory_controller_after_joint_state_broadcaster = RegisterEventHandler(
202-
event_handler=OnProcessExit(
203-
target_action=load_joint_state_broadcaster,
204-
on_exit=[load_joint_trajectory_controller],
212+
delay_joint_trajectory_controller_after_joint_state_broadcaster = (
213+
RegisterEventHandler(
214+
event_handler=OnProcessExit(
215+
target_action=load_joint_state_broadcaster,
216+
on_exit=[load_joint_trajectory_controller],
217+
)
205218
)
206219
)
207-
220+
208221
delay_gripper_controller_after_joint_trajectory = RegisterEventHandler(
209222
event_handler=OnProcessExit(
210223
target_action=load_joint_trajectory_controller,

Industrial/ur5_gripper_description/launch/view_ur.launch.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@
3030

3131
from launch import LaunchDescription
3232
from launch.actions import DeclareLaunchArgument
33-
from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution
33+
from launch.substitutions import (
34+
Command,
35+
FindExecutable,
36+
LaunchConfiguration,
37+
PathJoinSubstitution,
38+
)
3439
from launch_ros.actions import Node
3540
from launch_ros.substitutions import FindPackageShare
3641

@@ -45,7 +50,7 @@ def generate_launch_description():
4550
choices=["ur3", "ur3e", "ur5", "ur5e", "ur10", "ur10e", "ur16e"],
4651
)
4752
)
48-
53+
4954
declared_arguments.append(
5055
DeclareLaunchArgument(
5156
"safety_limits",
@@ -107,7 +112,9 @@ def generate_launch_description():
107112
[
108113
PathJoinSubstitution([FindExecutable(name="xacro")]),
109114
" ",
110-
PathJoinSubstitution([FindPackageShare(description_package), "urdf", description_file]),
115+
PathJoinSubstitution(
116+
[FindPackageShare(description_package), "urdf", description_file]
117+
),
111118
" ",
112119
"safety_limits:=",
113120
safety_limits,

0 commit comments

Comments
 (0)