3 PKG =
"pr2_mechanism_controllers"
5 import roslib; roslib.load_manifest(PKG)
12 from std_msgs
import *
14 from pr2_msgs.msg
import PeriodicCmd
16 from time
import sleep
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)
28 if __name__ ==
'__main__':
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])
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)
46 rospy.wait_for_service(controller +
'/set_periodic_cmd')
47 s = rospy.ServiceProxy(controller +
'/set_periodic_cmd', SetPeriodicCmd)
48 resp = s.call(SetPeriodicCmdRequest(cmd))
56 print(
'Command sent!')
57 print(
' Response: %f' % resp.start_time.to_sec())