Beispiel #1
0
def initialise():
    # Setup
    pz.init()
    pz.setOutputConfig(0, 2)  # set output 0 to Servo
    pz.setOutputConfig(1, 1)  # set output 1 to PWM
    pz.setOutputConfig(2, 1)  # set output 2 to PWM
    pz.setOutputConfig(3, 1)  # set output 3 to PWM
    pz.setInputConfig(0, 0)  # set input 1 to digital

    # Setup Action queues
    global qLED
    qLED = Queue(maxsize=0)
    global qServo
    qServo = Queue(maxsize=0)

    workerLED = Thread(target=processq, args=(qLED, ))
    workerLED.setDaemon(True)
    workerLED.start()

    workerServo = Thread(target=processq, args=(qServo, ))
    workerServo.setDaemon(True)
    workerServo.start()

    # Initialise dropbox
    global dbx
    dbx = dropbox.Dropbox(get_dropboxkey())
Beispiel #2
0
 def __init__(self):
     pz.init()
     GPIO.setwarnings(False)
     GPIO.setmode(GPIO.BOARD)
     # 24, 25 is BCM 18, 22
     self.sensor_right = DistanceSensor(echo=18, trigger=22)
     # 22, 23 is BCM 15, 16
     self.sensor_left = DistanceSensor(echo=15, trigger=16)
Beispiel #3
0
 def init():
     print('=======   App init    =====')
     pz.init()
     GPIO.setwarnings(False)
     LineSensor.setup()
     ServGrap.setup()
     UltrasonicSensor.setup()
     print('=======App initialized=====')
Beispiel #4
0
 def __init__(self):
     pz.init()
     self._pan = 0
     self._tilt = 1
     pz.setOutputConfig(self._pan, 2)
     pz.setOutputConfig(self._tilt, 2)
     self.tilt(90)
     self.pan(90)
Beispiel #5
0
 def __init__(self):
     pz.init()
     # 1= 2 place, 1 = PWM output channel
     pz.setOutputConfig(1, 1)
     # 2= 3 place, 1 = PWM output channel
     pz.setOutputConfig(2, 1)
     # Set initial state as off
     pz.setOutput(1, 0)
     pz.setOutput(2, 0)
     # Create a lock to syncronize access to hardware from multiple threads.
     self._lock = threading.Lock()
def init():

    print("Simple obstacle avoider")
    print("Press Ctrl-C to end")
    print()

    pz.init()
    pz.setOutputConfig(5, 3)  # set output 5 to WS2812
    rev = pz.getRevision()
    print(rev[0], rev[1])
    hcsr04.init()
Beispiel #7
0
def initPZ():
    pz.init()

    # Set output mode to Servo
    pz.setOutputConfig(pan, 2)
    pz.setOutputConfig(tilt, 2)
    # set output 5 to WS2812
    pz.setOutputConfig(pixel, 3)
    hcsr04.init()

    # Centre all servos
    panVal = 90
    tiltVal = 90
    pz.setOutput(pan, panVal)
    pz.setOutput(tilt, tiltVal)
Beispiel #8
0
        self.epoll = select.epoll()
        self.fdmap = {}

    def register(self, obj, flags):
        fd = obj.fileno()
        self.epoll.register(fd, flags)
        self.fdmap[fd] = obj

    def unregister(self, obj):
        fd = obj.fileno()
        del self.fdmap[fd]
        self.epoll.unregister(fd)

    def poll(self):
        evt = self.epoll.poll()
        for fd, flags in evt:
            yield self.fdmap[fd], flags


if __name__ == "__main__":
    pollster = EPoll()
    pollster.register(Server(("", 54321), pollster), select.EPOLLIN)
    pz.init()
    pz.setOutputConfig(5, 3)  # set output 5 to WS2812
    hcsr04.init()

    while True:
        evt = pollster.poll()
        for obj, flags in evt:
            readwrite(obj, flags)
Beispiel #9
0
 def __init__(self):
     pz.init()
Beispiel #10
0
#! /usr/bin/env python

# GNU GPL V3
# Test code for 4tronix Picon Zero

import piconzero as pz, time

pz.init()
pz.setInputConfig(0, 2)     # set input 0 to DS18B20
pz.setInputConfig(2, 2)     # set input 2 to DS18B20

try:
    while True:
        ana0 = pz.readInput(0)
        if (ana0>32767):
            ana0 -= 65536
        ana2 = pz.readInput(2)
        if (ana2>32767):
            ana2 -= 65536
        print ana0*0.0625, ana2*0.0625
        time.sleep(1)
except KeyboardInterrupt:
    print
finally:
    pz.cleanup()

Beispiel #11
0
import piconzero as pz
import time
from gpiozero import Button
import sys
from inputs import get_key
import os
import hcsr04
import I2C_LCD_driver
#I2C LCD driver from http://www.circuitbasics.com/raspberry-pi-i2c-lcd-set-up-and-programming/

#____________________________________________________________________________________
#hardware setup

mylcd = I2C_LCD_driver.lcd()  #assign LCD to variable for ease of use

pz.init()  #initiate hardware

pz.setInputConfig(0, 0)  #right IR sensor is input 0 and digital
pz.setInputConfig(1, 0)  #left IR sensor is input 1 and digital
pz.setInputConfig(2, 0)  #right line sensor is input 2 and digital
pz.setInputConfig(3, 0)  #left line is input 3 and digital

RIGHTIR = pz.readInput(0)  #assign right IR to a variable
LEFTIR = pz.readInput(1)  #assign left IR to a variable
RIGHTLINE = pz.readInput(2)  #assign right line sensor to a variable
LEFTLINE = pz.readInput(3)  #assign left line sensor to a variable

hcsr04.init()  #initiate hardware
RANGE = hcsr04.getDistance()  #assign HC-SR04 range to variable

button = Button(22)
Beispiel #12
0
    finally:
        print "Arret du mode labyrinthe"
        ControleRobot(action="arrete")
        camera(action=1)
        time.sleep(5)
        os.system('clear')
        tuto()
        logger.info('L utilisateur a quitte le mode labyrinthe')

#MAIN
logger.info('L utilisateur est passe en mode manuel')
camera(action=1)
tuto()
speed=65

pz.init() #Initialise l utilisation des fonctions PZ contenue dans la librairie PICONZERO

# Boucle principale
try:
    while True:
        keyp = readkey()

        #Permet de faire avancer le robot tout droit a l aide la manette et les touches.
        if keyp == 'z' or ord(keyp) == 16:
            pz.reverse(speed)
            logger.info('Le robot va tout droit.')
            print 'Avance a une vitesse de ' + str(mru()) + 'cm/s.', speed

        #Permet de faire reculer le robot a l aide de la manette et les touches.
        elif keyp == 's' or ord(keyp) == 17:
            pz.forward(speed)
Beispiel #13
0
 def __init__(self):
     pz.init()
     # Create a lock to syncronize access to hardware from multiple threads.
     self._lock = threading.Lock()
Beispiel #14
0
# Use G and H to open and close the Gripper arm
# Press Ctrl-C to stop
#

import piconzero as pz, time  # get the servo module

import hcsr04  # get the ultrasonic module

from init import limMin, limMax, positions

from operationModes import *

#======================================================
# Initialization
print("Initialization started")
pz.init()  # load servo operation library

# Set output mode to Servo
pz.setOutputConfig(rot, 2)
pz.setOutputConfig(tilt, 2)
pz.setOutputConfig(lift, 2)
pz.setOutputConfig(grip, 2)

# Sets the robot to the initial position.
# Possible issue: rapid movement from the previous operation stop point.
for i in channels:
    smoothMotion(i, positions[i])

# End of initialization of operation
#======================================================
 def ensure_piconzero_is_initialized(self):
     if not self.piconzero_initialized:
         pz.init()
         self.piconzero_initialized = True