예제 #1
0
 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()
예제 #2
0
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
예제 #3
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()
예제 #4
0
    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]))
예제 #5
0
# 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]))
# declare golbal variables
global driveLeft, driveRight
global toys_collected

# define variables
Known_Distance = 100  #100cm
Known_Width = 5  #5cm
image_width = 640
image_height = 480
toys = ["blue", "green", "red"]
target_toy = None  # allocates a none value
toys_collected = []  # allocates a null value to the list
#debugging = False #set to False to run in normal mode

# Setup the ThunderBorg Motor Driver board
TB = ThunderBorg3.ThunderBorg()
TB.Init()
if not TB.foundChip:
    boards = ThunderBorg3.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]))
    sys.exit()
예제 #7
0
	def __init__(self):
		self.ZB = ThunderBorg3.ThunderBorg()
		self.ZB.Init()
		self.LeftSpeed = 0
		self.RightSpeed = 0
예제 #8
0
]
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.'
        )
예제 #9
0
 def __init__(self,robot):
     self.robot=robot
     self.ZB=ThunderBorg3.ThunderBorg()
     self.initiate()
예제 #10
0
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()
예제 #11
0
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]))