# http://forum.piborg.org/zeroborg/examples/users # http://forum.piborg.org/node/2476 #!/usr/bin/env python # coding: Latin-1 # Load the ZeroBorg library import ZeroBorg3 as ZeroBorg # Load the standard time library import time # Setup the ZeroBorg so it is ready to use ZB = ZeroBorg.ZeroBorg() ZB.Init() #ZB.SetEpoIgnore(True) ZB.SetCommsFailsafe(False) # Reset the EPO flag to enable motors ZB.ResetEpo() # Determine the maximum power output # In this case 6V motors from a "9V" rechargeable maxPower = 6.0 / 9 # Bug: can just move forwards at the moment def move(left, right): print("movement:" + str(left) + "/" + str(right)) """ ZB.SetMotor1(left * maxPower) ZB.SetMotor4(left * maxPower) ZB.SetMotor2(right * maxPower) ZB.SetMotor3(right * maxPower) """ ZB.SetMotor1(-right * maxPower) ZB.SetMotor2(-right * maxPower) ZB.SetMotor3(-left * maxPower) ZB.SetMotor4(-left * maxPower) def move_forward(): move(-1.0, -1.0) def move_backward(): move(+1.0, +1.0) def spin_left(): move(-1.0, +1.0) def spin_right(): move(+1.0, -1.0) def stop(): move(0.0, 0.0) move_forward() time.sleep(2) spin_left() time.sleep(2) spin_right() time.sleep(2) move_backward() time.sleep(2) # stop() ZB.MotorsOff() exit()