def __init__(self): self.m1 = 0.0 self.m2 = 0.0 self.m3 = 0.0 self.speed = 0.0 self.TB1 = ThunderBorg.ThunderBorg() self.TB1.i2cAddress = 10 self.TB1.Init() self.TB2 = ThunderBorg.ThunderBorg() self.TB2.i2cAddress = 11 self.TB2.Init()
def TBCheck(image): TB1 = ThunderBorg.ThunderBorg() TB1.printFunction = TB1.NoPrint TB1.i2cAddress = 10 TB1.Init() image = TB(TB1.foundChip, image, 1) TB2 = ThunderBorg.ThunderBorg() TB2.printFunction = TB2.NoPrint TB2.i2cAddress = 11 TB2.Init() image = TB(TB1.foundChip, image, 2) return image
def _init_thunderborg(self): import ThunderBorg3 as ThunderBorg # Init the Thunderborg connection: self.TB = ThunderBorg.ThunderBorg() self.TB.Init() self.TB.MotorsOff() self.TB.SetLedShowBattery(True) # Setup the ThunderBorg if not self.TB.foundChip: boards = ThunderBorg.ScanForThunderBorg() if len(boards) == 0: print("[CONTROLLER] No ThunderBorg found," " check you are attached :)") else: print("[CONTROLLER] No ThunderBorg at address" " %02X, but we did find boards:" % (self.TB.i2cAddress)) for board in boards: print(" %02X (%d)" % (board, board)) print("[CONTROLLER] If you need to change the I�C address" " change the setup line so it is correct, e.g.") print("[CONTROLLER] TB.i2cAddress = 0x%02X" % (boards[0]))
def __init__(self): self.NebSpeed = 1 self.ultraBackRightSide = Ultra(18, 27) self.ultraBackRight = Ultra(4, 17) self.ultraFrontRight = Ultra(22, 23) self.ultraFrontRightSide = Ultra(25, 5) self.ultraBackLeftSide = Ultra(26, 21) self.ultraBackLeft = Ultra(20, 19) self.ultraFrontLeft = Ultra(6, 16) self.ultraFrontLeftSide = Ultra(13, 12) self.ZB = ThunderBorg3.ThunderBorg() self.ZB.Init() self.reverse = 0 print(self.ZB.GetBatteryReading()) self.leftSpeed = 0 self.rightSpeed = 0 print("waiting for remote") while True: try: self.controller = xbox.Joystick() break #self.controller.startstart() except: time.sleep(0.5) # remove this just to not have to have remote self.camera = Camera() print("waiting for compass") self.compass = Compass() self.compass.Start() #remove if no compass print("blasting sensors") for i in range(1000): print(i) self.simRead([ self.ultraFrontRight, self.ultraFrontLeft, self.ultraBackRight, self.ultraBackLeft, self.ultraFrontRightSide, self.ultraFrontLeftSide, self.ultraBackRightSide, self.ultraBackLeftSide, ]) self.compass.Heading()
# Bill Harvey 16 Feb 2021 # Last update 18 May 2021 from time import sleep from approxeng.input.selectbinder import ControllerResource # Import Approx Eng Controller libraries import ThunderBorg3 as ThunderBorg import UltraBorg3 as UltraBorg #import os import sys global launcher global TB launcher = False # Setup the ThunderBorg TB = ThunderBorg.ThunderBorg() #TB.i2cAddress = 0x15 # Uncomment and change the value if you have changed the board address TB.Init() if not TB.foundChip: boards = ThunderBorg.ScanForThunderBorg() if len(boards) == 0: print("No ThunderBorg found, check you are attached :)") else: print("No ThunderBorg at address %02X, but we did find boards:" % (TB.i2cAddress)) for board in boards: print(" %02X (%d) " % (board, board)) print( "If you need to change the I2C address change the setup line so it is correct, e.g." ) print("TB.i2cAddress = 0x%02X" % (boards[0]))
import xbox import ThunderBorg3 joy = xbox.Joystick() ZB = ThunderBorg3.ThunderBorg() ZB.Init() #ZB.SetLedShowBattery(True) #ZB.SetBatteryMonitoringLimits(9, 12) print(ZB.GetBatteryReading()) ZB.SetLed1(0, 0, 0) while True: if joy.connected(): Turn = joy.leftX() Speed = joy.rightY() forwardPowerL = Speed forwardPowerR = Speed if Turn > 0.1: forwardPowerL -= forwardPowerL * 0.8 * Turn if Turn < -0.1: forwardPowerR += forwardPowerR * 0.8 * Turn if Speed > -0.1 and Speed < 0.1: if Turn > 0.2: forwardPowerL = -Turn * 0.7 forwardPowerR = Turn * 0.7 if Turn < 0.2: forwardPowerL = -Turn * 0.7 forwardPowerR = Turn * 0.7 ZB.SetMotor1(forwardPowerR) ZB.SetMotor2(-forwardPowerL) else:
def __init__(self): self.ZB = ThunderBorg3.ThunderBorg() self.ZB.Init() self.LeftSpeed = 0 self.RightSpeed = 0
'direct', default=False, messages='Record pwm applied to motor, Default=False') ph.add_boolean_argument(ap, 'calibration', default=False, messages='Enter Calibration Mode, Default=False') args = vars(ap.parse_args()) # open the output CSV file for writing csv = open(args["output"], "w") calibration_mode = args["calibration"] direct_re = args["direct"] TB = ThunderBorg.ThunderBorg() TB.Init() GPIO.setup(11, GPIO.IN) #SO1 GPIO.setup(9, GPIO.IN) #SO2 GPIO.setup(10, GPIO.IN) #S03 GPIO.setup(22, GPIO.IN) #SO4 GPIO.setup(27, GPIO.IN) #SO5 sleep(1) # speed=0.3 speed = args["maxspeed"] # dt = str(datetime.datetime.now()) listener = Listener(on_release=kh.on_release) listener.start()
] sequenceHold = [ # Order for stepping at holding power [+holdingPower, +holdingPower], [+holdingPower, -holdingPower], [-holdingPower, -holdingPower], [-holdingPower, +holdingPower] ] stepDelay = 0.002 # Delay between steps # Name the global variables global step global TB step_count = 10 #(Steps per rev) # Setup the ThunderBorg global TB TB = ThunderBorg.ThunderBorg() # Create a new ThunderBorg object TB.i2cAddress = 0x15 # Uncomment and change the value if you have changed the board address TB.Init() # Set the board up (checks the board is connected) if not TB.foundChip: boards = ThunderBorg.ScanForThunderBorg() if len(boards) == 0: print('No ThunderBorg found, check you are attached :)') else: print('No ThunderBorg at address %02X, but we did find boards:' % (TB.i2cAddress)) for board in boards: print(' %02X (%d)' % (board, board)) print( 'If you need to change the I²C address change the setup line so it is correct, e.g.' )
def __init__(self,robot): self.robot=robot self.ZB=ThunderBorg3.ThunderBorg() self.initiate()
import time import ThunderBorg3 as tb dev = tb.ThunderBorg() dev.Init() def move(motor, dir): if motor == 0: dev.SetMotor1(0.35 * dir) time.sleep(1.5) dev.SetMotor1(0) if motor == 1: dev.SetMotor2(0.45 * dir) time.sleep(1.5) dev.SetMotor2(0) def do(): for x in range(100): move(0, 1) move(0, -1) move(1, 1) move(1, -1) time.sleep(2.5) do()
print('Libraries loaded') # Global values global running global TB global camera global processor global debug global colour running = True debug = False colour = 'red' # Setup the ThunderBorg TB = ThunderBorg3.ThunderBorg( ) # Edited 01 Mar 2018 Bill Harvey - changed ThunderBorg to ThunderBorg3 # TB.i2cAddress = 0x15 # Uncomment and change the value if you have changed the board address TB.Init() if not TB.foundChip: boards = ThunderBorg.ScanForThunderBorg() if len(boards) == 0: print('No ThunderBorg found, check you are attached :)') else: print('No ThunderBorg at address %02X, but we did find boards:' % (TB.i2cAddress)) for board in boards: print(' %02X (%d)' % (board, board)) print( 'If you need to change the I²C address change the setup line so it is correct, e.g.' ) print('TB.i2cAddress = 0x%02X' % (boards[0]))
# motor controller board using Martin O'Hanlon's BlueDot app (Andoroid version used for testing) # Written using python 3 # To use the ThunderBorg you will need to download the Python 3 version of ThunderBorg3.py # Install on Raspberry Pi using the following command: # wget -O ThunderBorg3.py http://old.piborg.org/downloads/thunderborg/ThunderBorg3.py.txt import ThunderBorg3 from time import sleep import sys from bluedot import BlueDot from gpiozero import Robot from signal import pause # Setup the ThunderBorg global TB TB = ThunderBorg3.ThunderBorg() # Create a new ThunderBorg object #TB.i2cAddress = 0x15 # Uncomment and change the value if you have changed the board address TB.Init() # Set the board up (checks the board is connected) if not TB.foundChip: boards = ThunderBorg.ScanForThunderBorg() if len(boards) == 0: print("No ThunderBorg found, check you are attached :)") else: print("No ThunderBorg at address %02X, but we did find boards:" % (TB.i2cAddress)) for board in boards: print(" %02X (%d)" % (board, board)) print( "If you need to change the I²C address change the setup line so it is correct, e.g." ) print("TB.i2cAddress = 0x%02X" % (boards[0]))