Example #1
0
###############
## Libraries ##
###############

import RPi.GPIO as GPIO
import time

try:
    import mc_communication as mc
except:
    import helpers.mc_communication as mc
#Logging
import log_helper
logger = log_helper.create_Logger(False, "ultraschallsensor_check")

###############
## Variables ##
###############

#GPIO Modus (BOARD / BCM)
GPIO.setmode(GPIO.BCM)

#GPIO Pins zuweisen
GPIO_TRIGGER = 18
GPIO_ECHO = 24

#Richtung der GPIO-Pins festlegen (IN / OUT)
GPIO.setup(GPIO_TRIGGER, GPIO.OUT)
GPIO.setup(GPIO_ECHO, GPIO.IN)

###############
Example #2
0
"""[Runden Erkennung Klasse]

Diese Klasse kümmert sich um die Erkennung der Runden.
"""

###############
## Libraries ##
###############

import log_helper

logger = log_helper.create_Logger(False, "Rundenerkennung")

#import MC Com
import helpers.mc_communication as mc_communication

###############
## Functions ##
###############


#Main callable Function
def get_track(rundenerkennung_ticks_per_round=3000):
    logger.info("Get Track called (not implemented yet)")
    distance = get_ticks()
    #calulate track
    track = __translate_dist_to_track(distance,
                                      rundenerkennung_ticks_per_round)

    return track
Example #3
0
"""[Transportgutsuche Klasse]

Diese Klasse kümmert sich um die Transportgutsuche.
"""

###############
## Libraries ##
###############

from helpers import ultraschallsensor_check as ultraschallsensor_check
#import MC Com
import helpers.mc_communication as mc_communication

#Logging
import log_helper
logger = log_helper.create_Logger(False, "transportgutsuche")

###############
## Functions ##
###############


def run_transportgutsuche(sonic_threshold_max_distance_cm,
                          sonic_threshold_min_distance_cm, sonic_abtastrate,
                          sonic_measurement_timeout_count):
    """[Transportgutsuche starten]

    Arguments:
        threshold_max_distance {int} -- Max Distanz zur Transportguterkennung (default: {10})

    Returns:
Example #4
0
# [Variante 1] Kommunikation via USB:
# arduino_serial = serial.Serial('/dev/ttyACM0', 115200, timeout = 1)   #Open port with baud rate

# [Variante 2] Kommunikation via USB wenn V1 nicht funktioniert

#arduino_serial = serial.Serial('/dev/ttyUSB0', 115200, timeout = 1)   #Open port with baud rate
arduino_serial = serial.Serial('/dev/serial0', 115200,
                               timeout=1)  #Open port with baud rate

# [Variante 3] Kommunikation via Serial Port über GPIOs (mit lvl shifter)
# arduino_serial = serial.Serial('/dev/serial0', 9600, timeout=3)

#Logger (muss im selben Ordner sein)
import log_helper
logger = log_helper.create_Logger(False, "mc_communication")

###############
## Functions ##
###############


# listens, gets and strips data
def uart_listener():
    response = arduino_serial.readline()
    response = response.rstrip().decode("utf-8")
    print("[RPI-Com]: Arduino response: ")
    print(response)  # print received data

    # Parsing: Daten verarbeiten/parsen
    parsed_data = parse_received_data(response)
Example #5
0
"""[Healthcheck Klasse]

Diese Klasse kümmert sich um einen sauberen Healthcheck des Systems
"""
###############
## Libraries ##
###############

#General
import os
import log_helper
logger = log_helper.create_Logger(False, "healthcheck")
import nice_headers
#Used for Camera Check
import subprocess
#HC04 Sonic
import time
import RPi.GPIO as GPIO
import multiprocessing
#TOF I2C
import board
import busio
import adafruit_vl6180x
#MC Com
import serial

#add adafruit multiplexer library
import adafruit_tca9548a

#install pip3 install adafruit-circuitpython-tca9548a
Example #6
0
"""[Praezises Halten Klasse]

Diese Klasse kümmert sich um das Präzise halten des Zuges zum Haltesignal.
"""

###############
## Libraries ##
###############

import log_helper
logger = log_helper.create_Logger(False, "Praezises halten")

import helpers.Double_TOF_check as Double_TOF_check

#import MC Com
import helpers.mc_communication as mc_communication

###############
## Functions ##
###############


def run_haltesignal_precise_stop(tof_measurement_timeout_millis, tof1_port,
                                 tof1_threshold_max_distance_mm,
                                 tof1_treshold_min_distance_mm, tof2_port,
                                 tof2_threshold_max_distance_mm,
                                 tof2_treshold_min_distance_mm):
    """[Praezises halten starten]

    TOF1 = Schaut Gerade
    TOF2 = Schaut Schräg
Example #7
0
###############
## Libraries ##
###############

import time
import board
import busio

#Logging
import log_helper

logger = log_helper.create_Logger(False, "Double_TOF_check")

#install beforehand with sudo pip3 install adafruit-circuitpython-vl6180x
import adafruit_vl6180x

#add adafruit multiplexer library
import adafruit_tca9548a
#install pip3 install adafruit-circuitpython-tca9548a

#MC Com
try:
    import mc_communication as mc
except:
    import helpers.mc_communication as mc

###############
## Variables ##
###############

# Create I2C bus. (careful with 2 TOFs)
Example #8
0
"""[Auflademodus Klasse]

Diese Klasse kümmert sich um die Lastgut Aufladung.
"""

###############
## Libraries ##
###############

#Logging
import log_helper
import time

logger = log_helper.create_Logger(False, "auflademodus")

#import MC Com
import helpers.mc_communication as mc_communication

###############
## Functions ##
###############


def run_auflademodus(cargo="undefined"):
    """[Auflademodus starten]

    Arguments:
        cargo {String} -- Cargo Parameter (default: {undefined})

    Returns:
        Boolean --  True, falls Lastgut aufgeladen
Example #9
0
#####################
## Library Imports ##
#####################

#Import System Libraries
import sys
import time

#Import StateMachine Base
from StateMachine import StateMachine

#Logger
import log_helper
logger = log_helper.create_Logger(False, "MainTrain")

#Import Zug-Module / Aufgaben Klassen
import transportgutsuche
import healthcheck
import praezises_halten
#import haltesignal_erkennung
#import infosignal_erkennung
import runden_erkennung
import auflademodus
import helpers.mc_communication as mc_communication

#Import Threading classes
import threading
from multiprocessing.pool import ThreadPool
pool = ThreadPool(processes=4)

# Import Voice Out