from Phidgets.Events.Events import AttachEventArgs, DetachEventArgs, ErrorEventArgs, CurrentChangeEventArgs, InputChangeEventArgs, VelocityChangeEventArgs from Phidgets.Devices.MotorControl import MotorControl #Create a motor control object try: mcL = MotorControl() # Left Motor mcR = MotorControl() # Right Motor except RuntimeError as e: print("Runtime Exception: %s" % e.details) print("Exiting....") exit(1) try: #mcL.openPhidget(serial=298857) #mcR.openPhidget(serial=298856) mcL.openRemote('odroid', serial=298857) mcR.openRemote('odroid', serial=298856) except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting....") exit(1) try: mcL.waitForAttach(10000) mcR.waitForAttach(10000) except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) try: mcL.closePhidget() mcR.closePhidget() except PhidgetException as e:
# motorControlR.setOnErrorhandler(motorControlError) # motorControlR.setOnCurrentChangeHandler(motorControlCurrentChanged) # motorControlR.setOnInputChangeHandler(motorControlInputChanged) # motorControlR.setOnVelocityChangeHandler(motorControlVelocityChanged) #except PhidgetException as e: # print("Phidget Exception %i: %s" % (e.code, e.details)) # print("Exiting....") # exit(1) print("Opening phidget object on Phidgets WebService 'odroid'...") try: #motorControlL.openPhidget(serial=298857) #motorControlR.openPhidget(serial=298856) motorControlL.openRemote('odroid',serial=298857) motorControlR.openRemote('odroid',serial=298856) except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting....") exit(1) if not motorControlL.isAttachedToServer(): sleep(2) print('motorControlL attached to server status: %s' % motorControlL.isAttachedToServer() ) print('motorControlR attached to server status: %s' % motorControlR.isAttachedToServer() ) print("Waiting for attach....") try:
# motorControlR.setOnErrorhandler(motorControlError) # motorControlR.setOnCurrentChangeHandler(motorControlCurrentChanged) # motorControlR.setOnInputChangeHandler(motorControlInputChanged) # motorControlR.setOnVelocityChangeHandler(motorControlVelocityChanged) #except PhidgetException as e: # print("Phidget Exception %i: %s" % (e.code, e.details)) # print("Exiting....") # exit(1) print("Opening phidget object on Phidgets WebService 'odroid'...") try: #motorControlL.openPhidget(serial=298857) #motorControlR.openPhidget(serial=298856) motorControlL.openRemote('odroid', serial=298857) motorControlR.openRemote('odroid', serial=298856) except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting....") exit(1) if not motorControlL.isAttachedToServer(): sleep(2) print('motorControlL attached to server status: %s' % motorControlL.isAttachedToServer()) print('motorControlR attached to server status: %s' % motorControlR.isAttachedToServer()) print("Waiting for attach....")