示例#1
0
def initialize_RPi_Stuff():
    #    note: global variables start with a little "g"
    global g_getter
    global g_camera
    global g_steerstats
    global g_graph
    global g_image_data
    global g_stop_event
    global g_lock

    g_getter = DataGetter()
    g_camera = picamera.PiCamera()
    g_camera.resolution = (128, 96)  #final image size
    g_camera.framerate = 10  #<---- framerate (fps) determines speed of data recording

    g_steerstats = np.load(g_pi_training_steerstats_file)['arr_0']
    model.load_weights(g_pi_training_weights_file)
    model._make_predict_function()
    g_graph = tf.get_default_graph()
    g_image_data = np.zeros((36, 128, 3), dtype=np.uint8)
    g_stop_event = threading.Event()
    g_lock = threading.Lock()

    # dazzle them with Night Rider LED show...
    for x in range(0, 3):
        for i in range(0, 6):
            displayBinaryOnLEDs(2**i)
            time.sleep(.125)

        for i in range(5, -1, -1):
            displayBinaryOnLEDs(2**i)
            time.sleep(.125)  # dazzle them with Night Rider LED show...

    # turn off all LEDs for initialization
    turn_OFF_all_LEDs()
示例#2
0
def initialize_service():
    #initialize the serial port: if the first port fails, we try the other one
    global g_serial
    g_serial = 0
    try:
        g_serial = serial.Serial('/dev/ttyACM1')
    except serial.SerialException:
        try:
            g_serial = serial.Serial('/dev/ttyACM0')
        except serial.SerialException:
            print('Cannot connect to serial port')

    #initialize the camera
    global g_camera
    g_camera = picamera.PiCamera()
    g_camera.resolution = (128, 96)
    g_camera.framerate = 10
    #initialize the data collector object
    global g_collector
    g_collector = DataCollector(g_serial, "/home/pi/autonomous/data")
    #initialize the image frame to be shared in autonomous mode
    global g_image_data
    g_image_data = np.zeros((36, 128, 3), dtype=np.uint8)
    #initialize some stuff needed for network thread
    global g_stop_event
    g_stop_event = threading.Event()
    global g_lock
    g_lock = threading.Lock()
    #this is the object the camera writes to in autonomous mode
    global g_getter
    g_getter = DataGetter()
    #this stuff sets up the network
    global g_graph
    g_graph = tf.get_default_graph()
    #model.load_weights('weights_2018-02-24_14-00-35_epoch_40.h5')
    model.load_weights('weights_2018-04-05_02-43-30_epoch_66.h5')
    model._make_predict_function()
    global g_steerstats
    g_steerstats = np.load('steerstats.npz')['arr_0']
    global g_ip_thread
    g_ip_thread = 0
示例#3
0
def initialize_service():
    #initialize the serial port: if the first port fails, we try the other one
    global g_serial
    try:
        g_serial = serial.Serial('/dev/ttyACM1')
    except serial.SerialException:
        try:
            g_serial = serial.Serial('/dev/ttyACM0')
        except serial.SerialException:
            logging.debug("error: cannot connect to serial port")
    #initialize the camera
    global g_camera
    g_camera = picamera.PiCamera()
    g_camera.resolution = (128, 96)
    g_camera.framerate = FRAME_RATE
    #initialize the data collector object
    global g_collector
    g_collector = DataCollector(g_serial, COLLECT_DIR)
    #initialize the image frame to be shared in autonomous mode
    global g_image_data
    g_image_data = np.zeros((36, 128, 3), dtype=np.uint8)
    #initialize some stuff needed for network thread
    global g_stop_event
    g_stop_event = threading.Event()
    global g_lock
    g_lock = threading.Lock()
    #this is the object the camera writes to in autonomous mode
    global g_getter
    g_getter = DataGetter()
    #this stuff sets up the network
    global g_graph
    g_graph = tf.get_default_graph()
    #model.load_weights('weights_2018-02-24_14-00-35_epoch_40.h5')
    model.load_weights(WEIGHTS_FILE)
    model._make_predict_function()
    global g_steerstats
    g_steerstats = np.load(STEERSTATS_FILE)['arr_0']
    global g_ip_thread
    g_ip_thread = 0