00001
00002
00003 PKG = "pr2_mechanism_controllers"
00004
00005 import roslib; roslib.load_manifest(PKG)
00006
00007 import sys
00008 import os
00009 import string
00010
00011 import rospy
00012 from std_msgs import *
00013
00014 from pr2_msgs.msg import PeriodicCmd
00015 from time import sleep
00016
00017 def print_usage(exit_code = 0):
00018 print '''Usage:
00019 send_periodic_cmd.py [controller] [profile] [period] [amplitude] [offset]
00020 - [profile] - Possible options are linear or linear_blended
00021 - [period] - Time for one entire cycle to execute (in seconds)
00022 - [amplitude] - Distance max value to min value of profile (In radians for laser_tilt controller)
00023 - [offset] - Constant cmd to add to profile (offset=0 results in profile centered around 0)
00024 '''
00025 sys.exit(exit_code)
00026
00027 if __name__ == '__main__':
00028
00029 cmd = PeriodicCmd()
00030 controller = 'laser_tilt_controller'
00031 cmd.header = rospy.Header(None, None, None)
00032 cmd.profile = 'linear'
00033 cmd.period = 4
00034 cmd.amplitude = 2
00035 cmd.offset = 0
00036
00037 print 'Sending Command to %s: ' % controller
00038 print ' Profile Type: %s' % cmd.profile
00039 print ' Period: %f Seconds' % cmd.period
00040 print ' Amplitude: %f Radians' % cmd.amplitude
00041 print ' Offset: %f Radians' % cmd.offset
00042
00043 command_publisher = rospy.Publisher(controller + '/set_periodic_cmd', PeriodicCmd)
00044 rospy.init_node('periodic_cmd_commander', anonymous=True)
00045 sleep(1)
00046 command_publisher.publish( cmd )
00047
00048 sleep(1)
00049
00050 print 'Command sent!'