Exemplo n.º 1
0
def main():
    #intialize the components of the project
    setupComponents()

    # This loop keeps checking for chips. If one is near it will get the UID and authenticate
    nfc = TwoRfid.Nfc522()  #create object to read from 2 different rfid
    while continue_reading:

        #read RFID of people entry and car entry
        gid1, gid2 = nfc.obtem_nfc_rfid()

        #handle car gate
        if not gid1 == 0:
            print("rfid reader of car gate read: ", gid1)
            buzzer.beep(1)

            name, slot, state = UserDB.AllowAccess(str(gid1), 0)
            if (state == 0):  #this person has a reservation
                lcd.message("WELCOME ", name)

                time.sleep(2)
                lcd.message("Go To Slot", str(slot))
                ServoMotor.OpenGate()  #open the gate

                #wait till the car pass the gate
                if (UltraSonicSensor.IsPassed()):

                    UserDB.changeState(gid1)
                    time.sleep(3)
                    ServoMotor.CloseGate()  #close the gate

                    #make microController open specific slot
                    openSlot(str(gid1), slot)
                    lcd.message("WELCOME IN", "SMART PARKING")

            elif (state == -2):  #this person not has a reservation
                lcd.message("Please ", "Reserve First")
                time.sleep(5)
                lcd.message("WELCOME IN", "SMART PARKING")

        #handle person gate
        if not gid2 == 0:
            print("rfid reader of person gate read: ", gid2)
            buzzer.beep(1)

            name, slot, state = UserDB.IsReserve(str(gid2), 1)
            if state == 1:  #this person has a car inside the garage
                #open the gate
                lcd.message("Here you are", "The Gate is open")
                GPIO.output(PERSON_GATE, True)
                time.sleep(6)
                GPIO.output(PERSON_GATE, False)

            else:
                lcd.message("Sorry You don't ", "Have car inside")
                time.sleep(5)

            lcd.message("WELCOME IN", "SMART PARKING")
Exemplo n.º 2
0
def loop():
    GPIO.setup(11, GPIO.IN)
    light.setup()
    opend = 0
    closedd = 1
    holdon = 0
    while (True):
        distance = getSonar()
        print("The distance is : %.2f cm" % (distance))
        if ((distance != 0) and (distance > 30)):
            if (opend == 1):
                ServoMotor.rotate(-1)
                I2CLCD1602.display(' Goodbye Buddy ', ' Door Opened ')
                fan.fanOFF()
                light.lightOFF()
                opend = 0
                closedd = 1
                time.sleep(5)
                ServoMotor.rotate(1)
                I2CLCD1602.display(' Goodbye Buddy ',
                                   (' Door Closed ' + str(distance)))
        elif ((distance != 0) and (distance < 10)):
            if (closedd == 1):
                I2CLCD1602.display(' Welcome Buddy ', ' Door Opened ')
                ServoMotor.rotate(-1)
                fan.fanON()
                light.lightON()
                opend = 1
                closedd = 0
                time.sleep(5)
                ServoMotor.rotate(1)
                I2CLCD1602.display(' Welcome Buddy ',
                                   (' Door Closed' + str(distance)))
        time.sleep(1)
Exemplo n.º 3
0
def performAction():
  reward = 0
  targetAngle = state[stateTo] - state[stateFrom]
  
  motor.run_to_abs_pos(position_sp=targetAngle, speed_sp=700)
  time.sleep(0.4)
  ts.motorPosition = motor.position

  if ts.is_pressed:
      Sound.beep()
      reward = 1

  records.pop()
  records.insert(0, reward)
  precision = records.count(1) / numRecords
  print("Precision: " + str(precision))

  return reward
Exemplo n.º 4
0
def main():
    #intialize the components of the project
    setupComponents()

    nfc = TwoRfid.Nfc522()  #create object to read from 2 different rfid

    # This loop keeps checking for chips. If one is near it will get the UID and authenticate

    while continue_reading:
        #read RFID
        gid1, gid2 = nfc.obtem_nfc_rfid()
        Uid = str(gid1)

        if not Uid == '0':
            person = False
            # Print UID
            print("Card read UID: " + Uid)

            #alter the user that the card is read
            buzzer.beep(1)

            ok = UserDB.allowExit(Uid)

            if ok:
                ServoMotor.OpenGate()  #open the gate

                #wait till the car pass the gate
                if (UltraSonicSensor.IsPassed()):
                    time.sleep(2)
                    ServoMotor.CloseGate()  #close the gate

                    #remove this user from the db of slots
                    #and also from the db of car entrance
                    UserDB.freeSlot(Uid)

            else:
                print("this tag doesn't have car inside the garage")
                print("enter the correct one")
Exemplo n.º 5
0
#!/usr/bin/env python3
import ServoMotor as motor
import TouchSensor as ts
import Sound

from time import sleep
import random

motor.reset()

ROTATION_STEP_SIZE = -12
ROTATION_SPEED = 20
LEARNING_RATE_ALPHA = 0.5
DISCOUNT_FACTOR_GAMMA = 0.5

stateFrom = 0
stateTo = 1
numEpochs = 200
numRecords = 20
records = [0] * numRecords

state = [
  -ROTATION_STEP_SIZE,
  0 * ROTATION_STEP_SIZE,
  1 * ROTATION_STEP_SIZE,
  2 * ROTATION_STEP_SIZE,
  3 * ROTATION_STEP_SIZE,
  4 * ROTATION_STEP_SIZE,
  5 * ROTATION_STEP_SIZE,
  6 * ROTATION_STEP_SIZE,
  7 * ROTATION_STEP_SIZE
Exemplo n.º 6
0
from Robot import *
from ServoMotor import *
from TempHumSensor import *
from UltrasoundSensor import *
from View import *
from Interface import *
from DummyObject import *
from WebCam import *

# Initialize the interface #
interface = Interface(300, 300, 100, 600, "F.I.R.E. -TempHumSensor TEST-", 100)
interface.build()
pygame.init()
############################
# Initialize the ServoMot. #
servoMotor = ServoMotor(11)  #FALTA poner el pin!
############################

#-#-#    MAIN  LOOP    #-#-#
text = " "
run = True
servoMotor.initialize()
#while(run):
#	pygame.time.delay(interface.delay)

#	for event in pygame.event.get():
#		if event.type == pygame.QUIT:
#			run = False

#	keys = pygame.key.get_pressed()
#	if keys[pygame.K_LEFT]:
# coding=utf-8

import time
import ScanQR
import TelegramMessage
from subprocess import call
import ServoMotor
import RPi.GPIO as GPIO
import Orders

#Inizilizzo Pin e ServoMotore
GPIO.setmode(GPIO.BCM)
ServoMotor.ServoClose()

'''
In un while 1 la piCamera continua a cercare Qr Code da scannerizzare,
decriptandoli usando come chiave di cifratura il seriale della SDB,
Fintanto che il seriale dell'ordine non matcha la lista degli ordini in arrivo presenti sulla SDB (orders.txt)
(Si presume che il sudetto file venga aggiornato da Amazon e si refreshi all'avvio della SDB)
Infine vengono restituiti i dati dell'ordine in fase di consegna
'''
b = ScanQR.scanqr() #Avvio Processo di ScanQR

'''
b==1 -> QR Speciale
b not none -> QR Letto correttamente dal postino
b is none -> QR NON Letto, NO apertura
'''
#Caso lettura QR in maniera corretta da Postino
if b is not None and b!=1:
    #Eliminazione ordine da "Orders.txt"
Exemplo n.º 8
0
 def __init__(self, LRServo, UDServo):
     self.servoLR = ServoMotor(LRServo)
     self.servoUD = ServoMotor(UDServo)
Exemplo n.º 9
0
class View:
    def __init__(self, LRServo, UDServo):
        self.servoLR = ServoMotor(LRServo)
        self.servoUD = ServoMotor(UDServo)

    def initialize(self):
        self.servoLR.initialize()
        self.servoUD.initialize()

    def up(self):
        tempPos = self.servoUD.pos
        if (tempPos < 4):
            tempPos = tempPos + 1
            self.servoUD.setPos(tempPos)

    def down(self):
        tempPos = self.servoUD.pos
        if (tempPos > 0):
            tempPos = tempPos - 1
            self.servoUD.setPos(tempPos)

    def left(self):
        tempPos = self.servoLR.pos
        if (tempPos > 0):
            tempPos = tempPos - 1
            self.servoLR.setPos(tempPos)

    def right(self):
        tempPos = self.servoLR.pos
        if (tempPos < 4):
            tempPos = tempPos + 1
            self.servoLR.setPos(tempPos)
Exemplo n.º 10
0
                ServoMotor.rotate(1)
                I2CLCD1602.display(' Goodbye Buddy ',
                                   (' Door Closed ' + str(distance)))
        elif ((distance != 0) and (distance < 10)):
            if (closedd == 1):
                I2CLCD1602.display(' Welcome Buddy ', ' Door Opened ')
                ServoMotor.rotate(-1)
                fan.fanON()
                light.lightON()
                opend = 1
                closedd = 0
                time.sleep(5)
                ServoMotor.rotate(1)
                I2CLCD1602.display(' Welcome Buddy ',
                                   (' Door Closed' + str(distance)))
        time.sleep(1)


if __name__ == '__main__':  #program start from here
    setup()
    ServoMotor.setup()
    light.setup()
    #fan.fanON()
    try:
        loop()
    except KeyboardInterrupt:  #when 'Ctrl+C' is pressed, the program will exit
        GPIO.cleanup()  #release resource
        ServoMotor.destroy()
        fan.destroy()
        light.destroy()