-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathmoveit_planning_example.launch.py
122 lines (108 loc) · 4.58 KB
/
moveit_planning_example.launch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Copyright 2022 Áron Svastits
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from launch import LaunchDescription
from launch_ros.actions import Node
from ament_index_python.packages import get_package_share_directory
from moveit_configs_utils import MoveItConfigsBuilder
from launch.actions.include_launch_description import IncludeLaunchDescription
from launch.actions import DeclareLaunchArgument, OpaqueFunction
from launch.launch_description_sources.python_launch_description_source import (
PythonLaunchDescriptionSource,
)
from launch.substitutions import LaunchConfiguration
def launch_setup(context, *args, **kwargs):
robot_model = LaunchConfiguration("robot_model")
ns = LaunchConfiguration("namespace")
x = LaunchConfiguration("x")
y = LaunchConfiguration("y")
z = LaunchConfiguration("z")
roll = LaunchConfiguration("roll")
pitch = LaunchConfiguration("pitch")
yaw = LaunchConfiguration("yaw")
if ns.perform(context) == "":
tf_prefix = ""
else:
tf_prefix = ns.perform(context) + "_"
moveit_config = (
MoveItConfigsBuilder("kuka_lbr_iisy")
.robot_description(
file_path=get_package_share_directory("kuka_lbr_iisy_support")
+ f"/urdf/{robot_model.perform(context)}.urdf.xacro",
mappings={
"x": x.perform(context),
"y": y.perform(context),
"z": z.perform(context),
"roll": roll.perform(context),
"pitch": pitch.perform(context),
"yaw": yaw.perform(context),
"prefix": tf_prefix,
},
)
.robot_description_semantic(
get_package_share_directory("kuka_lbr_iisy_moveit_config")
+ f"/urdf/{robot_model.perform(context)}.srdf"
)
.robot_description_kinematics(file_path="config/kinematics.yaml")
.trajectory_execution(file_path="config/moveit_controllers.yaml")
.planning_scene_monitor(
publish_robot_description=True, publish_robot_description_semantic=True
)
.joint_limits(
file_path=get_package_share_directory("kuka_lbr_iisy_support")
+ f"/config/{robot_model.perform(context)}_joint_limits.yaml"
)
.to_moveit_configs()
)
rviz_config_file = (
get_package_share_directory("kuka_resources") + "/config/planning_6_axis.rviz"
)
robot_description_kinematics = {
"robot_description_kinematics": {
"manipulator": {"kinematics_solver": "kdl_kinematics_plugin/KDLKinematicsPlugin"}
}
}
startup_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
[get_package_share_directory("kuka_iiqka_eac_driver"), "/launch/startup.launch.py"]
),
)
move_group_server = Node(
package="moveit_ros_move_group",
executable="move_group",
output="screen",
parameters=[moveit_config.to_dict(), {"publish_planning_scene_hz": 30.0}],
)
rviz = Node(
package="rviz2",
executable="rviz2",
name="rviz2",
output="log",
arguments=["-d", rviz_config_file, "--ros-args", "--log-level", "error"],
parameters=[
robot_description_kinematics,
],
)
to_start = [startup_launch, move_group_server, rviz]
return to_start
def generate_launch_description():
launch_arguments = []
launch_arguments.append(DeclareLaunchArgument("robot_model", default_value="lbr_iisy3_r760"))
launch_arguments.append(DeclareLaunchArgument("namespace", default_value=""))
launch_arguments.append(DeclareLaunchArgument("x", default_value="0"))
launch_arguments.append(DeclareLaunchArgument("y", default_value="0"))
launch_arguments.append(DeclareLaunchArgument("z", default_value="0"))
launch_arguments.append(DeclareLaunchArgument("roll", default_value="0"))
launch_arguments.append(DeclareLaunchArgument("pitch", default_value="0"))
launch_arguments.append(DeclareLaunchArgument("yaw", default_value="0"))
return LaunchDescription(launch_arguments + [OpaqueFunction(function=launch_setup)])