moveit2
The MoveIt Motion Planning Framework for ROS 2.
Loading...
Searching...
No Matches
testpoints.py
Go to the documentation of this file.
1#!/usr/bin/env python
2# Software License Agreement (BSD License)
3#
4# Copyright (c) 2018 Pilz GmbH & Co. KG
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions
9# are met:
10#
11# * Redistributions of source code must retain the above copyright
12# notice, this list of conditions and the following disclaimer.
13# * Redistributions in binary form must reproduce the above
14# copyright notice, this list of conditions and the following
15# disclaimer in the documentation and/or other materials provided
16# with the distribution.
17# * Neither the name of Pilz GmbH & Co. KG nor the names of its
18# contributors may be used to endorse or promote products derived
19# from this software without specific prior written permission.
20#
21# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32# POSSIBILITY OF SUCH DAMAGE.
33
34from geometry_msgs.msg import Point
37import math
38import rospy
39
40__REQUIRED_API_VERSION__ = "1"
41
42robot_configs = {}
43robot_configs["prbt"] = {
44 "initJointPose": [0.0, 0.0, math.radians(-25), 0.0, -1.57, 0],
45 "L": 0.2,
46 "M": 0.1,
47 "planning_group": "manipulator",
48 "target_link": "prbt_tcp",
49 "reference_frame": "prbt_base",
50 "default_or": from_euler(0, math.radians(180), math.radians(90)),
51 "P1_position": Point(0.3, 0.0, 0.5),
52 "P1_orientation": from_euler(0, math.radians(180), math.radians(135)),
53}
54
55robot_configs["panda"] = {
56 "initJointPose": [0.0, -0.785, 0.0, -2.356, 0.0, 1.571, 0.785],
57 "L": 0.2,
58 "M": 0.1,
59 "planning_group": "panda_arm",
60 "target_link": "panda_link8",
61 "reference_frame": "panda_link0",
62 "default_or": Quaternion(0.924, -0.382, 0.000, 0.000),
63 "P1_position": Point(0.2, 0.0, 0.8),
64}
65
66
67def start_program(robot_name):
68 print("Executing " + __file__)
69
70 test_sequence(**robot_configs[robot_name])
71
72
74 initJointPose,
75 L,
76 M,
77 planning_group,
78 target_link,
79 reference_frame,
80 default_or,
81 P1_position,
82 P1_orientation,
83):
84 r = Robot(__REQUIRED_API_VERSION__)
85
86 r.move(Ptp(goal=initJointPose, planning_group=planning_group))
87
88 P1 = Pose(position=P1_position, orientation=P1_orientation)
89
90 P2 = Pose(
91 position=Point(P1.position.x + L, P1.position.y + L, P1.position.z - M),
92 orientation=default_or,
93 )
94 P3 = Pose(
95 position=Point(P1.position.x, P1.position.y + 2 * L, P1.position.z - 2 * M),
96 orientation=default_or,
97 )
98 P4 = Pose(
99 position=Point(P1.position.x, P1.position.y + L, P1.position.z - M),
100 orientation=default_or,
101 )
102
103 ptp1 = Ptp(
104 goal=P1,
105 acc_scale=0.3,
106 planning_group=planning_group,
107 target_link=target_link,
108 reference_frame=reference_frame,
109 )
110 ptp2 = Ptp(
111 goal=P2,
112 acc_scale=0.3,
113 planning_group=planning_group,
114 target_link=target_link,
115 reference_frame=reference_frame,
116 )
117 ptp3 = Ptp(
118 goal=P3,
119 acc_scale=0.3,
120 planning_group=planning_group,
121 target_link=target_link,
122 reference_frame=reference_frame,
123 )
124 ptp4 = Ptp(
125 goal=P4,
126 acc_scale=0.3,
127 planning_group=planning_group,
128 target_link=target_link,
129 reference_frame=reference_frame,
130 )
131 lin1 = Lin(
132 goal=P1,
133 acc_scale=0.1,
134 planning_group=planning_group,
135 target_link=target_link,
136 reference_frame=reference_frame,
137 )
138 lin2 = Lin(
139 goal=P2,
140 acc_scale=0.1,
141 planning_group=planning_group,
142 target_link=target_link,
143 reference_frame=reference_frame,
144 )
145 lin3 = Lin(
146 goal=P3,
147 acc_scale=0.1,
148 planning_group=planning_group,
149 target_link=target_link,
150 reference_frame=reference_frame,
151 )
152 lin4 = Lin(
153 goal=P4,
154 acc_scale=0.1,
155 planning_group=planning_group,
156 target_link=target_link,
157 reference_frame=reference_frame,
158 )
159
160 r.move(ptp1) # PTP_12 test
161 r.move(ptp2) # PTP_23
162 r.move(ptp3) # PTP_34
163 r.move(ptp4) # PTP_41
164 r.move(ptp1)
165
166 r.move(lin1) # LIN_12
167 r.move(lin2) # LIN_23
168 r.move(lin3) # LIN_34
169 r.move(lin4) # LIN_41
170 r.move(lin1)
171
172 circ3_interim_2 = Circ(
173 goal=P3,
174 interim=P2.position,
175 acc_scale=0.2,
176 planning_group=planning_group,
177 target_link=target_link,
178 reference_frame=reference_frame,
179 )
180 circ1_center_2 = Circ(
181 goal=P1,
182 center=P2.position,
183 acc_scale=0.2,
184 planning_group=planning_group,
185 target_link=target_link,
186 reference_frame=reference_frame,
187 )
188
189 for radius in [0, 0.1]:
190 r.move(Ptp(goal=initJointPose, planning_group=planning_group))
191
192 seq = Sequence()
193 seq.append(ptp1, blend_radius=radius)
194 seq.append(circ3_interim_2, blend_radius=radius)
195 seq.append(ptp2, blend_radius=radius)
196 seq.append(lin3, blend_radius=radius)
197 seq.append(circ1_center_2, blend_radius=radius)
198 seq.append(lin2, blend_radius=radius)
199 seq.append(ptp3)
200
201 r.move(seq)
202
203
204if __name__ == "__main__":
205 # Init a ros node
206 rospy.init_node("robot_program_node")
207
208 import sys
209
210 robots = list(robot_configs.keys())
211
212 if len(sys.argv) < 2:
213 print(
214 "Please specify the robot you want to use."
215 + ", ".join('"{0}"'.format(r) for r in robots)
216 )
217 sys.exit()
218
219 if sys.argv[1] not in robots:
220 print(
221 "Robot "
222 + sys.argv[1]
223 + " not available. Use one of "
224 + ", ".join('"{0}"'.format(r) for r in robots)
225 )
226 sys.exit()
227
228 start_program(sys.argv[1])
start_program(robot_name)
Definition testpoints.py:67
test_sequence(initJointPose, L, M, planning_group, target_link, reference_frame, default_or, P1_position, P1_orientation)
Definition testpoints.py:83
void print(PropagationDistanceField &pdf, int numX, int numY, int numZ)