22 from moveit_commander
import RobotCommander, PlanningSceneInterface, MoveGroupCommander
23 from moveit_msgs.msg
import RobotState
24 import geometry_msgs.msg
34 rospy.init_node(
'moveit_test_planners', anonymous=
True)
38 self.
scene = PlanningSceneInterface()
40 self.
group = MoveGroupCommander(group_id)
43 self.group.set_planner_id(self.
planner)
57 p = geometry_msgs.msg.PoseStamped()
58 p.header.frame_id = self.robot.get_planning_frame()
64 p.pose.position.z = -0.11
65 p.pose.orientation.x = 0
66 p.pose.orientation.y = 0
67 p.pose.orientation.z = 0
68 p.pose.orientation.w = 1
69 self.scene.add_box(
"ground", p, (3, 3, 0.1))
71 p.pose.position.x = 0.4
72 p.pose.position.y = 0.85
73 p.pose.position.z = 0.4
74 p.pose.orientation.x = 0.5
75 p.pose.orientation.y = -0.5
76 p.pose.orientation.z = 0.5
77 p.pose.orientation.w = 0.5
78 self.scene.add_box(
"wall_front", p, (0.8, 2, 0.01))
80 p.pose.position.x = 1.33
81 p.pose.position.y = 0.4
82 p.pose.position.z = 0.4
83 p.pose.orientation.x = 0.0
84 p.pose.orientation.y = -0.707388
85 p.pose.orientation.z = 0.0
86 p.pose.orientation.w = 0.706825
87 self.scene.add_box(
"wall_right", p, (0.8, 2, 0.01))
89 p.pose.position.x = -0.5
90 p.pose.position.y = 0.4
91 p.pose.position.z = 0.4
92 p.pose.orientation.x = 0.0
93 p.pose.orientation.y = -0.707107
94 p.pose.orientation.z = 0.0
95 p.pose.orientation.w = 0.707107
96 self.scene.add_box(
"wall_left", p, (0.8, 2, 0.01))
101 if len(plan.joint_trajectory.points) > 0:
107 self.group.clear_pose_targets()
108 group_variable_values = self.group.get_current_joint_values()
109 group_variable_values[0:6] = joints[0:6]
110 self.group.set_joint_value_target(group_variable_values)
112 plan = self.group.plan()
117 test_joint_values = [numpy.pi/2.0]
118 joints = [0.0, 0.0, 0.0, -numpy.pi / 2.0, 0.0, 0.0]
121 for joint
in [0, 1, 2, 3, 5]:
122 for value
in test_joint_values:
123 joints[joint] = value
125 self.fail_list.append(
"Failed: test_trajectories_rotating_each_joint, " + self.
planner +
126 ", joints:" + str(joints))
128 self.pass_list.append(
"Passed: test_trajectories_rotating_each_joint, " + self.
planner +
129 ", joints:" + str(joints))
134 0.0, -1.99, 2.19, 0.58, 0.0, -0.79, 0.0, 0.0]
136 self.fail_list.append(
"Failed: test_trajectories_empty_environment, " + self.
planner +
137 ", joints:" + str(joints))
139 self.pass_list.append(
"Passed: test_trajectories_empty_environment, " + self.
planner +
140 ", joints:" + str(joints))
143 joints = [-1.67232, -2.39104, 0.264862,
144 0.43346, 2.44148, 2.48026, 0.0, 0.0]
146 self.fail_list.append(
"Failed: test_trajectories_empty_environment, " + self.
planner +
147 ", joints:" + str(joints))
149 self.pass_list.append(
"Passed: test_trajectories_empty_environment, " + self.
planner +
150 ", joints:" + str(joints))
154 -0.000348431194526, 0.397651011661, 0.0766181197394, -
155 0.600353691727, -0.000441966540076,
156 0.12612019707, 0.0, 0.0]
158 self.fail_list.append(
"Failed: test_trajectories_empty_environment, " + self.
planner +
159 ", joints:" + str(joints))
161 self.pass_list.append(
"Passed: test_trajectories_empty_environment, " + self.
planner +
162 ", joints:" + str(joints))
166 0.146182953165, -2.6791929848, -
167 0.602721109682, -3.00575848765, 0.146075718452,
168 0.00420656698366, 0.0, 0.0]
170 self.fail_list.append(
"Failed: test_trajectories_empty_environment, " + self.
planner +
171 ", joints:" + str(joints))
173 self.pass_list.append(
"Passed: test_trajectories_empty_environment, " + self.
planner +
174 ", joints:" + str(joints))
178 1.425279839, -0.110370375874, -
179 1.52548746261, -1.50659865247, -1.42700242769,
180 3.1415450794, 0.0, 0.0]
182 self.fail_list.append(
"Failed: test_trajectories_empty_environment, " + self.
planner +
183 ", joints:" + str(joints))
185 self.pass_list.append(
"Passed: test_trajectories_empty_environment, " + self.
planner +
186 ", joints:" + str(joints))
190 1.57542451065, 3.01734161219, 2.01043257686, -
191 1.14647092839, 0.694689321451,
192 -0.390769365032, 0.0, 0.0]
194 self.fail_list.append(
"Failed: test_trajectories_empty_environment, " + self.
planner +
195 ", joints:" + str(joints))
197 self.pass_list.append(
"Passed: test_trajectories_empty_environment, " + self.
planner +
198 ", joints:" + str(joints))
202 -0.289797803762, 2.37263860495, 2.69118483159, 1.65486712181, 1.04235601797,
203 -1.69730925867, 0.0, 0.0]
205 self.fail_list.append(
"Failed: test_trajectories_empty_environment, " + self.
planner +
206 ", joints:" + str(joints))
208 self.pass_list.append(
"Passed: test_trajectories_empty_environment, " + self.
planner +
209 ", joints:" + str(joints))
214 -0.324590029242, -1.42602359749, -
215 1.02523472017, -0.754761892979, 0.344227622185,
216 -3.03250264451, 0.0, 0.0]
217 current = RobotState()
218 current.joint_state.name = self.robot.get_current_state(
220 current_joints = list(
221 self.robot.get_current_state().joint_state.position)
222 current_joints[0:8] = joints
223 current.joint_state.position = current_joints
225 self.group.set_start_state(current)
229 initial_pose = self.group.get_current_pose().pose
231 initial_pose.position.x = -0.301185959729
232 initial_pose.position.y = 0.517069787724
233 initial_pose.position.z = 1.20681710541
234 initial_pose.orientation.x = 0.0207499700474
235 initial_pose.orientation.y = -0.723943002716
236 initial_pose.orientation.z = -0.689528413407
237 initial_pose.orientation.w = 0.00515118111221
240 waypoints.append(initial_pose)
243 wpose = geometry_msgs.msg.Pose()
244 wpose.orientation = waypoints[0].orientation
245 wpose.position.x = waypoints[0].position.x
246 wpose.position.y = waypoints[0].position.y
247 wpose.position.z = waypoints[0].position.z - 0.20
248 waypoints.append(copy.deepcopy(wpose))
251 wpose.position.y += 0.20
252 waypoints.append(copy.deepcopy(wpose))
255 wpose.position.x -= 0.20
256 waypoints.append(copy.deepcopy(wpose))
260 waypoints.append(copy.deepcopy(wpose))
262 (plan3, fraction) = self.group.compute_cartesian_path(
263 waypoints, 0.01, 0.0)
265 self.fail_list.append(
"Failed: test_waypoints, " + self.
planner)
267 self.pass_list.append(
"Passed: test_waypoints, " + self.
planner)
274 0.302173213174, 0.192487443763, -
275 1.94298265002, 1.74920382275, 0.302143499777, 0.00130280337897,
278 self.fail_list.append(
"Failed: test_trajectories_with_walls_and_ground, " + self.
planner +
279 ", joints:" + str(joints))
281 self.pass_list.append(
"Passed: test_trajectories_with_walls_and_ground, " + self.
planner +
282 ", joints:" + str(joints))
286 3.84825722288e-05, 0.643694953509, -
287 1.14391175311, 1.09463824437, 0.000133883149666, -
291 self.fail_list.append(
"Failed: test_trajectories_with_walls_and_ground, " + self.
planner +
292 ", joints:" + str(joints))
294 self.pass_list.append(
"Passed: test_trajectories_with_walls_and_ground, " + self.
planner +
295 ", joints:" + str(joints))
299 0.354696232081, -0.982224980654, 0.908055961723, -
300 1.92328051116, -1.3516255551, 2.8225061435,
303 self.fail_list.append(
"Failed: test_trajectories_with_walls_and_ground, " + self.
planner +
304 ", joints:" + str(joints))
306 self.pass_list.append(
"Passed, test_trajectories_with_walls_and_ground, " + self.
planner +
307 ", joints:" + str(joints))
309 self.scene.remove_world_object(
"ground")
310 self.scene.remove_world_object(
"wall_left")
311 self.scene.remove_world_object(
"wall_right")
312 self.scene.remove_world_object(
"wall_front")
316 parser = argparse.ArgumentParser(description=
'A script to test moveit planners. ' 317 'Should be run after launching the UR10 arm and shadow hand: \n ' 318 'roslaunch sr_robot_launch sr_right_ur10arm_hand.launch OR \n ' 319 'roslaunch sr_robot_launch sr_left_ur10arm_hand.launch',
320 add_help=
True, usage=
'%(prog)s [group_id]',
321 formatter_class=argparse.RawTextHelpFormatter)
323 parser.add_argument(dest=
'group_id', help=
"Should be either right_arm or left_arm")
326 group_id = str(sys.argv[1])
329 rospy.get_master().getPid()
331 print(
"Please launch robot.")
335 while not rospy.search_param(
'robot_description_semantic')
and not rospy.is_shutdown():
336 print(
"Waiting for robot description, has robot been launched?")
339 planner_list = [
"BKPIECEkConfigDefault",
"ESTkConfigDefault",
"KPIECEkConfigDefault",
"LBKPIECEkConfigDefault",
340 "PRMkConfigDefault",
"RRTkConfigDefault",
"SBLkConfigDefault",
"PRMstarkConfigDefault",
341 "RRTstarkConfigDefault"]
342 for planner
in planner_list:
345 if __name__ ==
"__main__":
def _add_walls_and_ground(self)
def test_trajectories_empty_environment(self)
def _check_plan(self, plan)
def _plan_joints(self, joints)
def test_trajectories_rotating_each_joint(self)
def test_trajectories_with_walls_and_ground(self)
def __init__(self, group_id, planner)