send_periodic_cmd.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 time import sleep
16 
17 def print_usage(exit_code = 0):
18  print '''Usage:
19  send_periodic_cmd.py [controller] [profile] [period] [amplitude] [offset]
20  - [profile] - Possible options are linear or linear_blended
21  - [period] - Time for one entire cycle to execute (in seconds)
22  - [amplitude] - Distance max value to min value of profile (In radians for laser_tilt controller)
23  - [offset] - Constant cmd to add to profile (offset=0 results in profile centered around 0)
24 '''
25  sys.exit(exit_code)
26 
27 if __name__ == '__main__':
28  rospy.init_node('periodic_cmd_commander', sys.argv, anonymous=True)
29 
30  if len(sys.argv) != 6:
31  print_usage()
32 
33  cmd = PeriodicCmd()
34  controller = sys.argv[1]
35  cmd.header = rospy.Header(None, None, None)
36  cmd.profile = sys.argv[2]
37  cmd.period = float (sys.argv[3])
38  cmd.amplitude = float (sys.argv[4])
39  cmd.offset = float (sys.argv[5])
40 
41  print 'Sending Command to %s: ' % controller
42  print ' Profile Type: %s' % cmd.profile
43  print ' Period: %f Seconds' % cmd.period
44  print ' Amplitude: %f Radians' % cmd.amplitude
45  print ' Offset: %f Radians' % cmd.offset
46 
47  command_publisher = rospy.Publisher(controller + '/set_periodic_cmd', PeriodicCmd)
48  sleep(1)
49  command_publisher.publish( cmd )
50 
51  sleep(1)
52 
53  print 'Command sent!'
def print_usage(exit_code=0)


pr2_mechanism_controllers
Author(s): Sachin Chita, John Hsu, Melonee Wise
autogenerated on Wed Jun 5 2019 19:34:08