Esempio n. 1
0
import cv2
import os
import time
import json
import numpy as np

from suiron import SuironIO
from suiron import Clock
# Load image settings
with open('settings.json') as d:
    SETTINGS = json.load(d)

# Instantiatees our IO class
suironio = SuironIO(id=0,
                    width=SETTINGS['width'],
                    height=SETTINGS['height'],
                    depth=SETTINGS['depth'])
suironio.init_saving()

clck = Clock(suironio, 1)
clck.start()

# Allows time for the camerae to warm up
print('Warming up...')
print('Recording data...')

while True:
    try:
        s = {}
        s['motor'] = 1
        s['servo'] = 2
maxspeed = 0.17
minspeed = 0.13
#-------------------------------------------------------------

#Our attempt to speed up the process
nos = os.system
#buttonWasPressed = False

with open('/home/ubuntu/settings.json') as d:
    SETTINGS = json.load(d)
br = CvBridge()

# Instantiatees our IO class
print(SETTINGS['width'], SETTINGS['height'])
suironio = SuironIO(id=0,
                    width=SETTINGS['width'],
                    height=SETTINGS['height'],
                    depth=SETTINGS['depth'])
suironio.init_saving()
lock = Lock()
clck = Clock(suironio, 0.05)
clck.start()

if REV == 2.2:
    s0 = wiringport[settings.PINS['servo0']]
    s1 = wiringport[settings.PINS['servo1']]
    cmd = [
        "gpio mode {} pwm".format(s0),
        "gpio mode {} pwm".format(s1),
        "gpio pwm-ms",
        "gpio pwmc 1920",
        "gpio pwmr 100",