36 usage: tuck_arms.py [-l ACTION] [-r ACTION] [-q] 38 -l or --left Action for left arm 39 -r or --right Action for right arm 40 -q or --quit Shut down the action client after completing action 47 from pr2_common_action_msgs.msg
import TuckArmsAction, TuckArmsGoal
54 print __doc__ % vars()
55 rospy.signal_shutdown(
"Help requested")
59 action_name =
'tuck_arms' 60 quit_when_finished =
False 64 myargs = rospy.myargv()[1:]
68 goal.tuck_right =
True 69 opts, args = getopt.getopt(myargs,
'hql:r:', [
'quit',
'left',
'right'])
70 for arm, action
in opts:
71 if arm
in (
'-l',
'--left'):
72 if action
in (
'tuck',
't'):
74 elif action
in (
'untuck',
'u'): 75 goal.tuck_left = False 77 rospy.logerr(
'Invalid action for right arm: %s' % action)
78 rospy.signal_shutdown(
"ERROR")
80 if arm
in (
'-r',
'--right'):
81 if action
in (
'tuck',
't'):
82 goal.tuck_right =
True 83 elif action
in (
'untuck',
'u'): 84 goal.tuck_right = False 86 rospy.logerr(
'Invalid action for left arm: %s' % action)
87 rospy.signal_shutdown(
"ERROR")
89 if arm
in (
'--quit',
'-q'):
90 quit_when_finished =
True 92 if arm
in (
'--help',
'-h'):
97 rospy.logdebug(
'Waiting for action server to start')
98 tuck_arm_client.wait_for_server(rospy.Duration())
99 rospy.logdebug(
'Sending goal to action server')
100 tuck_arm_client.send_goal_and_wait(goal, rospy.Duration(30.0),
103 if quit_when_finished:
104 rospy.signal_shutdown(
"Quitting")
107 if __name__ ==
'__main__':
108 rospy.init_node(
'tuck_arms_client')