-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnectedphone_state_machine
621 lines (534 loc) · 28.2 KB
/
connectedphone_state_machine
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
#!/usr/bin/env python
import rospy
import rospkg
from math import pow, atan2, sqrt
from tf.transformations import *
import smach
import smach_ros
from smach_ros import SimpleActionState
from smach_ros import ServiceState
from std_msgs.msg import Int8
from std_msgs.msg import String
import threading
# Manipulator
from open_manipulator_msgs.msg import JointPosition
from open_manipulator_msgs.msg import KinematicsPose
from open_manipulator_msgs.srv import SetJointPosition
from open_manipulator_msgs.srv import SetKinematicsPose
from open_manipulator_msgs.srv import GetJointPosition
from open_manipulator_msgs.srv import GetKinematicsPose
import time
#from darknet_ros_msgs.msg import BoundingBoxes
#from darknet_ros_msgs.msg import BoundingBox
from sensor_msgs.msg import JointState
import tty, sys
import os
class waitCommand(smach.State):
def __init__(self):
smach.State.__init__(self, outcomes=['succeeded','preempted' ,'aborted','option0','option1','option2'])
self.command_Key_sub = rospy.Subscriber('command_Key', String, self.commandKeyCallback)
self.mode = 9
def commandKeyCallback(self, msg):
#print '0. Start\n1. Stop 1\n2. Release Phone\n'
#rospy.logwarn('1commandKeyCallback %d', msg.data)
if msg.data == "0" :
self.mode = 0
else :
pass
def execute(self, userdata):
self.mode = 9
#print '0. Start\n1. Stop 1\n2. Release Phone\n'
while 1 :
#rospy.sleep(0.5)
if self.mode == 0 :
break
return 'succeeded'
class trackingAction(smach.State):
def __init__(self):
smach.State.__init__(self, outcomes=['succeeded', 'aborted'],
input_keys=['input_planning_group','input_motionfile_file'])
self.object_pose_sub = rospy.Subscriber('/facedetectdataset', String, self.collect)
#self.cupboundingBox = BoundingBox()
# this is for Joint Control
self.set_joint_position = rospy.ServiceProxy('/open_manipulator/goal_joint_space_path', SetJointPosition)
# this is for IV Kinemetics Control
self.set_kinematics_position = rospy.ServiceProxy('/open_manipulator/goal_task_space_path_position_only', SetKinematicsPose)
# this is for Joint Control from Current Position
self.set_joint_position_from_present = rospy.ServiceProxy('/open_manipulator/goal_joint_space_path_from_present', SetJointPosition)
# to read current joint value
self.open_manipulator_joint_states_sub_ = rospy.Subscriber('/open_manipulator/joint_states', JointState, self.jointStatesCallback)
# to read current IN kinemetics value
self.open_manipulator_kinematics_pose_sub_ = rospy.Subscriber('/open_manipulator/gripper/kinematics_pose', KinematicsPose, self.kinematicsPoseCallback)
self.set_gripper_position = rospy.ServiceProxy('/open_manipulator/goal_tool_control', SetJointPosition)
self.command_Key_sub = rospy.Subscriber('command_Key', String, self.commandKeyCallback)
self.mode = 9
self.last_detect_time = rospy.get_rostime()
self.jointStates = [0.0, 0.0, 0.0, 0.0]
self.gripperStates = [0.0, 0.0]
self.kinematicsStates = [0.0, 0.0, 0.0]
self.facedata = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
self.face_center_x = 320
self.face_center_y = 240
self.last_detect_time = rospy.get_rostime()
self.use_platform = rospy.get_param("~use_platform")
self.face_width = 0
def kinematicsPoseCallback(self, msg):
self.kinematicsStates[0] = msg.pose.position.x
self.kinematicsStates[1] = msg.pose.position.y
self.kinematicsStates[2] = msg.pose.position.z
#rospy.logwarn(' kinematicsPoseCallback %.2f , %.2f, %.2f ', self.kinematicsStates[0], self.kinematicsStates[1], self.kinematicsStates[2] )
def jointStatesCallback(self, msg):
if self.use_platform :
self.jointStates[0] = msg.position[0]
self.jointStates[1] = msg.position[1]
self.jointStates[2] = msg.position[2]
self.jointStates[3] = msg.position[3]
else :
self.gripperStates[0] = msg.position[0]
self.gripperStates[1] = msg.position[1]
self.jointStates[0] = msg.position[2]
self.jointStates[1] = msg.position[3]
self.jointStates[2] = msg.position[4]
self.jointStates[3] = msg.position[5]
def collect(self, msg):
#face tracking data
#rospy.logwarn('camera data %s', msg.data )
self.facedata = [int (i) for i in msg.data.split(",")]
self.face_center_x = self.facedata[1]
self.face_center_y = self.facedata[2]
self.face_width = self.facedata[3]
self.last_detect_time = rospy.get_rostime()
#print "face_center_x: %d"%self.face_center_x
#print "face_center_x: %d"%self.face_center_x
'''rospy.logwarn('id %d,CX %d,CY %d,Width %d,Height %d,EulerY %d,EulerZ %d,LeftEyeOpen %d,RightEyeOpen %d,Smile %d ', \
self.facedata[0], self.facedata[1], self.facedata[2], self.facedata[3], self.facedata[4], self.facedata[5],\
self.facedata[6], self.facedata[7], self.facedata[8], self.facedata[9]) '''
def commandKeyCallback(self, msg):
#print '0. Start\n1. Stop 1\n2. Release Phone\n'
#rospy.logwarn('1commandKeyCallback %d', msg.data)
if msg.data == "0" :
self.mode = 0
elif msg.data == "1" :
self.mode = 1
elif msg.data == "2" :
self.mode = 2
elif msg.data == "3" :
self.mode = 3
elif msg.data == "4" :
self.mode = 4
elif msg.data == "5" :
self.mode = 5
elif msg.data == "8" :
self.mode = 8
else :
pass
def initAction(self,userdata):
try:
joint_position = JointPosition()
planning_group = userdata.input_planning_group
joint_position.joint_name = ['joint1','joint2','joint3','joint4']
joint_position.position = [0.0, -1.05, 0.35, 0.70]
path_time = 5
resp1 = self.set_joint_position(planning_group,joint_position, path_time)
#print 'resp1 {}'.format(resp1.is_planned)
rospy.sleep(5)
except rospy.ServiceException, e:
print "Service call failed: %s"%e
print 'init point\n'
def smileAction(self,userdata):
print 'smileAction point\n'
count = 0
inputfile = userdata.input_motionfile_file
while 1:
if count > ( len(inputfile) - 1 ):
break
if count == 0 :
position_path_time = 2
operating_time = 2
else :
#position_path_time = 0.2
#operating_time = 0.02
position_path_time = 1
operating_time = 0.02
try:
joint_position = JointPosition()
planning_group = userdata.input_planning_group
joint_position.joint_name = ['joint1','joint2','joint3','joint4']
joint_position.position = [inputfile[count][0], inputfile[count][1], \
inputfile[count][2], inputfile[count][3]]
path_time = position_path_time
resp1 = self.set_joint_position(planning_group,joint_position, path_time)
#print 'resp1 {}'.format(resp1.is_planned)
#rospy.sleep(position_path_time)
except rospy.ServiceException, e:
print "Service call failed: %s"%e
count = count + 1
rospy.sleep(operating_time)
print 'smileAction finish\n'
def winkAction(self,userdata):
print 'panoramaShot init point\n'
def panoramaShot(self,userdata):
print 'panoramaShot init point\n'
try:
joint_position = JointPosition()
planning_group = userdata.input_planning_group
joint_position.joint_name = ['joint1','joint2','joint3','joint4']
joint_position.position = [-1.57, -1.049, 0.354, 0.715]
path_time = 5
resp1 = self.set_joint_position(planning_group,joint_position, path_time)
#print 'resp1 {}'.format(resp1.is_planned)
rospy.sleep(5)
except rospy.ServiceException, e:
print "Service call failed: %s"%e
try:
joint_position = JointPosition()
planning_group = userdata.input_planning_group
joint_position.joint_name = ['joint1','joint2','joint3','joint4']
joint_position.position = [-3.14+0.03, -0.700, -0.249, 0.500]
path_time = 5
resp1 = self.set_joint_position(planning_group,joint_position, path_time)
#print 'resp1 {}'.format(resp1.is_planned)
rospy.sleep(5)
except rospy.ServiceException, e:
print "Service call failed: %s"%e
rospy.sleep(3)
print 'panoramaShot start\n'
try:
joint_position = JointPosition()
planning_group = userdata.input_planning_group
joint_position.joint_name = ['joint1','joint2','joint3','joint4']
joint_position.position = [3.14*2-0.06, 0, 0, 0]
path_time = 20
resp1 = self.set_joint_position_from_present(planning_group,joint_position, path_time)
rospy.sleep(21)
#print 'resp1 {}'.format(resp1.is_planned)
except rospy.ServiceException, e:
print "Service call failed: %s"%e
print 'panoramaShot end\n'
rospy.sleep(3)
print 'set init position for face tracking \n'
try:
joint_position = JointPosition()
planning_group = userdata.input_planning_group
joint_position.joint_name = ['joint1','joint2','joint3','joint4']
joint_position.position = [0.0, -1.05, 0.35, 0.70]
path_time = 5
resp1 = self.set_joint_position(planning_group,joint_position, path_time)
#print 'resp1 {}'.format(resp1.is_planned)
rospy.sleep(5)
except rospy.ServiceException, e:
print "Service call failed: %s"%e
def facetrackingActionByJoint(self,userdata):
center_x = 112 #320
center_y = 158 #240
x_diff = (center_x - self.face_center_x)
y_diff = (center_y - self.face_center_y)
#move_x = (x_diff*1000/320)*0.1/1000
#move_y = (y_diff*1000/320)*-0.05/1000
move_x = (x_diff*1000/320)*0.3/1000
move_y = (y_diff*1000/320)*-0.15/1000
#rospy.logwarn('C_XY %.3f,%.3f , XY_Diff %.3f,%.3f move_xy %.3f,%.3f)', self.face_center_x ,self.face_center_y , \
#x_diff, y_diff, move_x, move_y)
object_detect_duration = rospy.get_rostime().to_sec() - self.last_detect_time.to_sec()
#rospy.logwarn("duration %.2f",object_detect_duration )
#check last face detected time
if object_detect_duration > 1 :
rospy.logwarn(" no face.. ")
rospy.sleep(1)
return ;
center_range = 50
#center range set
if abs(x_diff) < center_range and abs(y_diff) < center_range/2 :
rospy.logwarn(" this range is center ")
rospy.sleep(1)
return ;
#operating range set _ x range (-90 degree ~ 90 degree) y range (-45 degree ~ 45 degree)
if (self.jointStates[0] > 1.57 and move_x > 0) or (self.jointStates[0] < -1.57 and move_x < 0 ) :
move_x = 0
#rospy.logwarn("set joint0 state %.3f , move_x %.3f",self.jointStates[0], move_x)
if (self.jointStates[3] > 1.57 and move_y > 0) or (self.jointStates[3] < 0 and move_y < 0 ) :
move_y = 0
#rospy.logwarn("set joint3 state %.3f , move_y %.3f",self.jointStates[3], move_y)
#tracking action
try:
joint_position = JointPosition()
planning_group = userdata.input_planning_group
joint_position.joint_name = ['joint1','joint2','joint3','joint4']
joint_position.position = [move_x, 0, 0, move_y]
#joint_position.position = [move_x, move_join2, move_join3, move_y]
#path_time = 0.1
path_time = 1
resp1 = self.set_joint_position_from_present(planning_group,joint_position, path_time)
rospy.sleep(0.3)
print 'resp1 {}'.format(resp1.is_planned)
except rospy.ServiceException, e:
print "Service call failed: %s"%e
#depth calculation by width
#200, 75
'''fmin = 75
fmax = 200
fcent = 100
if self.face_width < ( fcent - 20 ):
add_dist
if self.face_width < fmin :
self.face_width = fmin
elif self.face_width >fmax :
self.face_width = fmax
angle = math.atan(y/x)
dis_x = add_dist*math.cos(angle)
dis_y = add_dist*math.sin(angle)'''
def facetrackingActionByIVKinemetics(self,userdata):
print 'facetrackingAction\n'
#check last face detected time
if object_detect_duration > 1 :
rospy.logwarn(" no face.. ")
rospy.sleep(1)
return ;
try:
# center(absolute) : face_center = current_pose : kinematics_pose
#1) Comparison between screen center coordinates and tracking coordinates
center_x = 320
center_y = 240
differ_x = self.face_center_x - center_x
differ_y = self.face_center_y - center_y
move_ratio = 0.01
#print "face_center_x: %d"%self.face_center_x
#print "face_center_y: %d"%self.face_center_y
#print "center_x: %d"%center_x
#print "center_y: %d"%center_y
#2) 0.01% of the difference between x and y values is applied to the robot arm coordinates.
rospy.logwarn('position ( %d %d )( %d %d )', self.face_center_x , self.face_center_y ,differ_x, differ_y )
rospy.logwarn('position ............................( %.2f ,%.3f %.2f ) %.3f ', self.kinematicsStates[0],self.kinematicsStates[1],self.kinematicsStates[2],\
self.kinematicsStates[1] + move_ratio * differ_x)
planning_group = userdata.input_planning_group
end_effector_name = "gripper";
kinematics_pose = KinematicsPose()
kinematics_pose.pose.position.x = self.kinematicsStates[0]
kinematics_pose.pose.position.y = self.kinematicsStates[1] + move_ratio * differ_x
#kinematics_pose.pose.position.z = self.kinematicsStates[2] + 0.02 + move_ratio * differ_y
kinematics_pose.pose.position.z = self.kinematicsStates[2]
print "position.x: %f"%kinematics_pose.pose.position.x
print "pose.position.y: %f"%kinematics_pose.pose.position.y
print "pose.position: %f"%kinematics_pose.pose.position.z
path_time = 1
resp1 = self.set_kinematics_position(planning_group, end_effector_name, kinematics_pose, path_time)
print 'kinemetics resp1 {}'.format(resp1.is_planned)
rospy.sleep(1)
except rospy.ServiceException, e:
print "Service call failed: %s"%e
def execute(self, userdata):
rospy.sleep(3)
self.mode = 9
#example joint control
while 1:
if self.mode == 2 :
break
elif self.mode == 1 :
continue
elif self.mode == 3 :
self.panoramaShot(userdata)
self.mode = 0
continue
elif self.mode == 4 :
self.initAction(userdata)
self.mode = 1
continue
elif self.mode == 5 :
self.smileAction(userdata)
self.mode = 0
continue
elif self.mode == 8:
return 'aborted'
#self.facetrackingActionByIVKinemetics(userdata)
self.facetrackingActionByJoint(userdata)
#rospy.sleep(1)
# tracking code
return 'succeeded'
def myhook():
#print "shutdown time!........................................................."
pass
def main():
rospy.init_node('pick_and_place_state_machine2')
namespace = rospy.get_param("~robot_name")
planning_group = rospy.get_param("~planning_group")
pick_center = smach.StateMachine(outcomes=['succeeded','aborted','preempted','option0','option1','option2'])
rospy.on_shutdown(myhook)
rospack = rospkg.RosPack()
rospack.list()
package_path = rospack.get_path('open_manipulator_connectedphone')
with open(package_path+'/cfg/output.txt') as data:
inputfile = [[float(i) for i in line.split(",")] for line in data.readlines()]
with pick_center:
pick_center.userdata.planning_group = planning_group
def joint_position_request_cb(userdata, request):
request.joint_position.joint_name = ['joint1','joint2','joint3','joint4']
request.joint_position.position = userdata.input_position
request.path_time = 1.5
return request
def joint_position_response_cb(userdataz, response):
if response.is_planned == False:
rospy.sleep(1.5)
return 'aborted'
else:
rospy.sleep(1.5)
return 'succeeded'
def gripper_request_cb(userdata, request):
request.joint_position.joint_name = ['gripper']
request.joint_position.position = userdata.input_gripper
request.path_time = 1.5
return request
def gripper_response_cb(userdata, response):
if response.is_planned == False:
#return 'aborted'
rospy.sleep(2.0)
return 'succeeded'
else:
rospy.sleep(2.0)
return 'succeeded'
########### INITIAL STEP #################################################
pick_center.userdata.pick_first_position = [0.0, 0.041, -0.328, 1.55]
smach.StateMachine.add('INIT_FIRST_POSITION',
ServiceState('/open_manipulator/goal_joint_space_path',
SetJointPosition,
request_cb=joint_position_request_cb,
response_cb=joint_position_response_cb,
input_keys=['input_planning_group',
'input_position']),
transitions={'succeeded':'INIT_SECOND_POSITION'},
remapping={'input_planning_group':'planning_group',
'input_position':'pick_first_position'})
pick_center.userdata.pick_second_position = [0.0, 0.210, 0.032, 1.300]
#pick_center.userdata.pick_second_position = [0.0, 0.210, 0.032, 1.390]
smach.StateMachine.add('INIT_SECOND_POSITION',
ServiceState('/open_manipulator/goal_joint_space_path',
SetJointPosition,
request_cb=joint_position_request_cb,
response_cb=joint_position_response_cb,
input_keys=['input_planning_group',
'input_position']),
transitions={'succeeded':'INIT_OPEN_GRIPPER'},
#transitions={'succeeded':'succeeded'},
remapping={'input_planning_group':'planning_group',
'input_position':'pick_second_position'})
pick_center.userdata.open_gripper = [0.01]
smach.StateMachine.add('INIT_OPEN_GRIPPER',
ServiceState('/open_manipulator/goal_tool_control',
SetJointPosition,
request_cb=gripper_request_cb,
response_cb=gripper_response_cb,
input_keys=['input_planning_group',
'input_gripper']),
transitions={'succeeded':'INIT_THIRD_POSITION'},
remapping={'input_planning_group':'planning_group',
'input_gripper':'open_gripper'})
pick_center.userdata.init_position = [0.0, -1.05, 0.35, 0.70]
smach.StateMachine.add('INIT_THIRD_POSITION',
ServiceState('/open_manipulator/goal_joint_space_path',
SetJointPosition,
request_cb=joint_position_request_cb,
response_cb=joint_position_response_cb,
input_keys=['input_planning_group',
'input_position']),
transitions={'succeeded':'WAIT_COMMAND'},
remapping={'input_planning_group':'planning_group',
'input_position':'init_position'})
smach.StateMachine.add('WAIT_COMMAND', waitCommand(),
transitions={'succeeded':'PICK_FIRST_POSITION',
'aborted':'WAIT_COMMAND'})
########## PICKING PHONE STEP ##################################################
#pick_center.userdata.pick_first_position = [0.0, 0.041, -0.328, 1.743]
#pick_center.userdata.pick_first_position = [0.0, 0.041, -0.328, 1.55]
smach.StateMachine.add('PICK_FIRST_POSITION',
ServiceState('/open_manipulator/goal_joint_space_path',
SetJointPosition,
request_cb=joint_position_request_cb,
response_cb=joint_position_response_cb,
input_keys=['input_planning_group',
'input_position']),
transitions={'succeeded':'PICK_SECOND_POSITION'},
remapping={'input_planning_group':'planning_group',
'input_position':'pick_first_position'})
#pick_center.userdata.pick_second_position = [0.0, 0.210, 0.032, 1.330]
pick_center.userdata.pick_second_position = [0.0, 0.210, 0.032, 1.390]
smach.StateMachine.add('PICK_SECOND_POSITION',
ServiceState('/open_manipulator/goal_joint_space_path',
SetJointPosition,
request_cb=joint_position_request_cb,
response_cb=joint_position_response_cb,
input_keys=['input_planning_group',
'input_position']),
transitions={'succeeded':'PICK_GRIPPER_CLOSE'},
#transitions={'succeeded':'succeeded'},
remapping={'input_planning_group':'planning_group',
'input_position':'pick_second_position'})
pick_center.userdata.pick_close_gripper = [-0.01]
smach.StateMachine.add('PICK_GRIPPER_CLOSE',
ServiceState('/open_manipulator/goal_tool_control',
SetJointPosition,
request_cb=gripper_request_cb,
response_cb=gripper_response_cb,
input_keys=['input_planning_group',
'input_gripper']),
transitions={'succeeded':'PICK_THIRD_POSITION'},
remapping={'input_planning_group':'planning_group',
'input_gripper':'pick_close_gripper'})
pick_center.userdata.pick_third_position = [0.0, -1.05, 0.35, 0.70]
smach.StateMachine.add('PICK_THIRD_POSITION',
ServiceState('/open_manipulator/goal_joint_space_path',
SetJointPosition,
request_cb=joint_position_request_cb,
response_cb=joint_position_response_cb,
input_keys=['input_planning_group',
'input_position']),
transitions={'succeeded':'TRACKING_ACTION'},
#transitions={'succeeded':'succeeded'},
remapping={'input_planning_group':'planning_group',
'input_position':'pick_third_position'})
############# TRACKING STEP ###############################################
pick_center.userdata.motionfile = inputfile
smach.StateMachine.add('TRACKING_ACTION', trackingAction(),
transitions={'succeeded':'RELEASE_FIRST_POSITION',
'aborted':'aborted'},
remapping={'input_planning_group':'planning_group',
'input_motionfile_file':'motionfile'})
############# RELEASE PHONE STEP ###############################################
smach.StateMachine.add('RELEASE_FIRST_POSITION',
ServiceState('/open_manipulator/goal_joint_space_path',
SetJointPosition,
request_cb=joint_position_request_cb,
response_cb=joint_position_response_cb,
input_keys=['input_planning_group',
'input_position']),
transitions={'succeeded':'RELEASE_SECOND_POSITION'},
remapping={'input_planning_group':'planning_group',
'input_position':'pick_first_position'})
smach.StateMachine.add('RELEASE_SECOND_POSITION',
ServiceState('/open_manipulator/goal_joint_space_path',
SetJointPosition,
request_cb=joint_position_request_cb,
response_cb=joint_position_response_cb,
input_keys=['input_planning_group',
'input_position']),
transitions={'succeeded':'RELEASE_OPEN_GRIPPER'},
remapping={'input_planning_group':'planning_group',
'input_position':'pick_second_position'})
smach.StateMachine.add('RELEASE_OPEN_GRIPPER',
ServiceState('/open_manipulator/goal_tool_control',
SetJointPosition,
request_cb=gripper_request_cb,
response_cb=gripper_response_cb,
input_keys=['input_planning_group',
'input_gripper']),
transitions={'succeeded':'INIT_THIRD_POSITION'},
#transitions={'succeeded':'succeeded'},
remapping={'input_planning_group':'planning_group',
'input_gripper':'open_gripper'})
sis = smach_ros.IntrospectionServer('server_name', pick_center, '/PICK_CENTER')
sis.start()
# Execute SMACH plan
outcome = pick_center.execute()
# Wait for ctrl-c to stop the application
rospy.spin()
sis.stop()
if __name__ == '__main__':
main()