Exemplo n.º 1
0
def ZeroBorgInit():
    global ZB
    # Re-direct our output to standard error, we need to ignore standard out to hide some nasty print statements from pygame
    sys.stdout = sys.stderr

    # Setup the ZeroBorg
    ZB = ZeroBorg.ZeroBorg()
    #ZB.i2cAddress = 0x44                  # Uncomment and change the value if you have changed the board address
    ZB.Init()
    if not ZB.foundChip:
        boards = ZeroBorg.ScanForZeroBorg()
        if len(boards) == 0:
            print 'No ZeroBorg found, check you are attached :)'
        else:
            print 'No ZeroBorg at address %02X, but we did find boards:' % (
                ZB.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 'ZB.i2cAddress = 0x%02X' % (boards[0])
        sys.exit()
    #ZB.SetEpoIgnore(True)                 # Uncomment to disable EPO latch, needed if you do not have a switch / jumper
    # Ensure the communications failsafe has been enabled!
    failsafe = False
    for i in range(5):
        ZB.SetCommsFailsafe(True)
        failsafe = ZB.GetCommsFailsafe()
        if failsafe:
            break
    if not failsafe:

        print 'Board %02X failed to report in failsafe mode!' % (ZB.i2cAddress)
        sys.exit()
    ZB.ResetEpo()
Exemplo n.º 2
0
def init():
    camera = PiCamera()
    camera.resolution = (imw, imh)
    camera.framerate = 8
    rawCapture = PiRGBArray(camera, size=camera.resolution)

    cap = (camera, rawCapture)

    zb = ZeroBorg.ZeroBorg()
    zb.Init()
    debug("zb initialized")

    detector = cv.CascadeClassifier()
    detector.load('face_frontal.xml')
    debug("face detector initialized")

    return zb, detector, cap
Exemplo n.º 3
0
#!/usr/bin/env python
# coding: Latin-1

# Load library functions we want
import time
import os
import sys
import pygame
import ZeroBorg

# Re-direct our output to standard error, we need to ignore standard out to hide some nasty print statements from pygame
sys.stdout = sys.stderr

# Setup the ZeroBorg
ZB = ZeroBorg.ZeroBorg()
#ZB.i2cAddress = 0x44                  # Uncomment and change the value if you have changed the board address
ZB.Init()
if not ZB.foundChip:
    boards = ZeroBorg.ScanForZeroBorg()
    if len(boards) == 0:
        print 'No ZeroBorg found, check you are attached :)'
    else:
        print 'No ZeroBorg at address %02X, but we did find boards:' % (ZB.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 'ZB.i2cAddress = 0x%02X' % (boards[0])
    sys.exit()
#ZB.SetEpoIgnore(True)                 # Uncomment to disable EPO latch, needed if you do not have a switch / jumper
# Ensure the communications failsafe has been enabled!
failsafe = False
Exemplo n.º 4
0
#!/usr/bin/env python
# coding: latin-1

# Import library functions we need
import ZeroBorg
import zbIrButtonMap as Buttons
import Tkinter

# Setup the ZeroBorg
global ZB
ZB = ZeroBorg.ZeroBorg()  # Create a new ZeroBorg object
ZB.Init()  # Set the board up (checks the board is connected)
ZB.ResetEpo()  # Reset the stop switch (EPO) state
# if you do not have a switch across the two pin header then fit the jumper
ZB.SetLedIr(True)  # Set the LED to flash when an infrared signal is present

# Build a button to name mapping
buttonMap = {}
possibleButtons = Buttons.__dict__.keys()
possibleButtons.sort()
for buttonName in possibleButtons:
    if buttonName.startswith('IR_'):
        code = Buttons.__dict__[buttonName]
        name = buttonName[3:]
        buttonMap[code] = name


# Class representing the GUI dialog
class ZeroBorg_tk(Tkinter.Tk):
    # Constructor (called when the object is first created)
    def __init__(self, parent):
Exemplo n.º 5
0
import ZeroBorg
import time

from mpu6050 import MPU6050
import smbus

address = 0x68
bus = smbus.SMBus(1)
##bus = 1

sensor = MPU6050(bus, address, "MPU6050")
sensor.read_raw_data()

from pid import PID

ZB = ZeroBorg.ZeroBorg()
ZB.Init()

ZB.SetCommsFailsafe(False)
ZB.ResetEpo()

pid = PID(0.075, 0.0, 0.0)

maxPower = 0.75


def clamp(n, minn, maxn):
    return max(min(maxn, n), minn)


def Move(left, right):
Exemplo n.º 6
0
	def __init__(self):
		self.z = ZeroBorg.ZeroBorg()
		self.z.Init()
Exemplo n.º 7
0
#!/usr/bin/python

import sys
import ZeroBorg

zb = ZeroBorg.ZeroBorg()
zb.Init()
zb.SetMotor1(0)
zb.SetMotor2(0)
zb.SetMotor3(0)
zb.SetMotor4(0)
Exemplo n.º 8
0
# Using sonar circuit to detect object
# When Interrupt is called trun off motors for 3 seconds
# April 15th 2018
# Change to GPIO23 for pin interrupt
# Added new logic to prevent boucing of switch to dampen false detection 
import RPi.GPIO as GPIO     # import RPi.GPIO module
import sys                         # import sys for pathing
sys.path.append('/home/pi/zeroborg')    # path for zeroborg library
from time import sleep      # for a delay in the program
import ZeroBorg             # import motor controller library
GPIO.setmode(GPIO.BCM)      # choose BCM Borad
GPIO.setup(17, GPIO.OUT, initial = 0)  # set GPIO17 as an output to power sonar circuit
GPIO.setup(23, GPIO.IN)  # set GPIO23 for input from sonar circuit

# Setup ZeroBorg Motor
ZB = ZeroBorg.ZeroBorg()    # Create motor controller object
ZB.Init()                   # Setup the motor controller board
ZB.ResetEpo()               # Reset the safety latch

# Configure GPIO 18 to interrupt control flow when pin 23 goes high
GPIO.add_event_detect(23, GPIO.RISING)

GPIO.output(17, 1)  # set GPIO17 to 1/GPIO.HIGH/True to turn on circuit

print("Here we go! Press CTRL+C to exti")
sleep(2.0)
try:
    while True:
        ZB.SetMotors(.75)

Exemplo n.º 9
0
axisLeftRightInverted = False  # Set this to True if left and right appear to be swapped
buttonResetEpo = 7  # Joystick button number to perform an EPO reset (Start)
interval = 0.00  # Time between updates in seconds, smaller responds faster but uses more processor time
buttonA = 0
buttonB = 1
buttonX = 2
buttonY = 3
buttonSelect = 6
buttonHome = 8

# Re-direct our output to standard error, we need to ignore standard out to hide some nasty print statements from pygame
print("starting zerobot")

sys.stdout = sys.stderr
# zeroborg variables
ZB = ZeroBorg.ZeroBorg()  # make this global
# Setup the ZeroBorg
ZB.i2cAddress = 0x0a  # Uncomment and change the value if you have changed the board address
ZB.Init()
if not ZB.foundChip:
    boards = ZeroBorg.ScanForZeroBorg()
    if len(boards) == 0:
        print 'No ZeroBorg found, check you are attached :)'
    else:
        print 'No ZeroBorg at address %02X, but we did find boards:' % (
            ZB.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 'ZB.i2cAddress = 0x%02X' % (boards[0])
    sys.exit()