TestClient.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import roslib; roslib.load_manifest('PhidgetMotor')
00004 
00005 import sys
00006 import rospy
00007 from PhidgetMotor.srv import *
00008 
00009 def phidgetMotorClient(
00010         leftSpeed,
00011         rightSpeed,
00012         secondsDuration,
00013         acceleration
00014         ):
00015 
00016     print "Waiting for service"
00017     rospy.wait_for_service('PhidgetMotor')
00018 
00019     try:
00020         print "Establishing connection to Service"
00021         phidgetMotor = rospy.ServiceProxy('PhidgetMotor', Move, persistent=True)
00022         response = phidgetMotor(
00023                 leftSpeed,
00024                 rightSpeed,
00025                 secondsDuration,
00026                 acceleration
00027                 )
00028         return response.succeeded
00029 
00030     except rospy.ServiceException, e:
00031         print "Call to service PhidgetMotor failed: %s" % e
00032 
00033     return False
00034 
00035 if __name__ == "__main__":
00036     if len(sys.argv) == 5:
00037         leftSpeed = int(sys.argv[1])
00038         rightSpeed = int(sys.argv[2])
00039         secondsDuration = int(sys.argv[3])
00040         acceleration = int(sys.argv[4])
00041     else:
00042         sys.exit(1)
00043 
00044     print "Requesting: Left %d, Right %d, Duration %d, Acceleration %d" % (leftSpeed, rightSpeed, secondsDuration, acceleration)
00045 
00046     print "Calling the Service"
00047     if phidgetMotorClient(
00048             leftSpeed,
00049             rightSpeed,
00050             secondsDuration,
00051             acceleration
00052             ):
00053         print "Success"
00054         sys.exit(0)
00055     else:
00056         print "Failure"
00057         sys.exit(2)
00058 


phidget_motor
Author(s): Bill Mania/bmania@coroware.com, Morgan Cormier/mcormier@coroware.com
autogenerated on Wed Aug 26 2015 11:09:55