send_periodic_cmd_srv.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 PKG = "pr2_mechanism_controllers"
4 
5 import roslib; roslib.load_manifest(PKG)
6 
7 import sys
8 import os
9 import string
10 
11 import rospy
12 from std_msgs import *
13 
14 from pr2_msgs.msg import PeriodicCmd
15 from pr2_msgs.srv import *
16 from time import sleep
17 
18 def print_usage(exit_code = 0):
19  print '''Usage:
20  send_periodic_cmd.py [controller] [profile] [period] [amplitude] [offset]
21  - [profile] - Possible options are linear or linear_blended
22  - [period] - Time for one entire cycle to execute (in seconds)
23  - [amplitude] - Distance max value to min value of profile (In radians for laser_tilt controller)
24  - [offset] - Constant cmd to add to profile (offset=0 results in profile centered around 0)
25 '''
26  sys.exit(exit_code)
27 
28 if __name__ == '__main__':
29  if len(sys.argv) < 6:
30  print_usage()
31 
32  cmd = PeriodicCmd()
33  controller = sys.argv[1]
34  cmd.header = rospy.Header(None, None, None)
35  cmd.profile = sys.argv[2]
36  cmd.period = float (sys.argv[3])
37  cmd.amplitude = float (sys.argv[4])
38  cmd.offset = float (sys.argv[5])
39 
40  print 'Sending Command to %s: ' % controller
41  print ' Profile Type: %s' % cmd.profile
42  print ' Period: %f Seconds' % cmd.period
43  print ' Amplitude: %f Radians' % cmd.amplitude
44  print ' Offset: %f Radians' % cmd.offset
45 
46  rospy.wait_for_service(controller + '/set_periodic_cmd')
47  s = rospy.ServiceProxy(controller + '/set_periodic_cmd', SetPeriodicCmd)
48  resp = s.call(SetPeriodicCmdRequest(cmd))
49 
50  #rospy.init_node('periodic_cmd_commander', anonymous=True)
51  #sleep(1)
52  #command_publisher.publish( cmd )
53 
54  #sleep(1)
55 
56  print 'Command sent!'
57  print ' Response: %f' % resp.start_time.to_sec()
def print_usage(exit_code=0)


pr2_mechanism_controllers
Author(s): Sachin Chita, John Hsu, Melonee Wise
autogenerated on Mon Jun 10 2019 14:26:33