Ejemplo n.º 1
0
 def __init__(self, auto_loop=False):
     self.configuration = parse_config("post-it")
     
     self.cap = cv2.VideoCapture(-1)
     self.cap.set(cv2.cv.CV_CAP_PROP_BRIGHTNESS, self.configuration['brightness'])
     self.cap.set(cv2.cv.CV_CAP_PROP_CONTRAST, self.configuration['contrast'])
     self.cap.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH, self.configuration['width'])
     self.cap.set(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT, self.configuration['height'])
     
     if auto_loop:
         self.track_show_loop()
Ejemplo n.º 2
0
    def __init__(self, auto_loop=False):
        self.configuration = parse_config("post-it")

        self.cap = cv2.VideoCapture(-1)
        self.cap.set(cv2.cv.CV_CAP_PROP_BRIGHTNESS,
                     self.configuration['brightness'])
        self.cap.set(cv2.cv.CV_CAP_PROP_CONTRAST,
                     self.configuration['contrast'])
        self.cap.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH,
                     self.configuration['width'])
        self.cap.set(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT,
                     self.configuration['height'])

        if auto_loop:
            self.track_show_loop()
Ejemplo n.º 3
0
def main(config):
    graph, alpha, beta, rho, num_ants_per_city, num_iterations = \
                                                    parse_config(config)

    path, pheremones = get_optimal_path(graph, alpha, beta, rho,
                                        num_ants_per_city, num_iterations)

    # print final results
    print("Results:")
    print("--------\n")
    print("Best Path:")
    print_tour(path)
    print("\n", end='')
    print("Length:")
    print(path.length)
    print("\n", end='')
    print_pheremone_map(pheremones)

    # return path for testing purposes
    return path
Ejemplo n.º 4
0
import vision
import robotusb
from collections import OrderedDict
import cv2
from parseconfig import parse_config

configuration = parse_config("arm")

tracker = vision.TrackSquare(False)

while True:
    processed, square = tracker.track_show()
    robotusb.StopArm()
    if square['w'] is not 0:
        if abs(square['x']) > configuration['base_thresh']:
            if square['x'] < 0:
                robotusb.MoveArm("BASE_CL")
            else:
                robotusb.MoveArm("BASE_AC")
        elif abs(square['y']) > configuration['wrist_thresh']:
            up = False
            if square['y'] < 0:
                up = True
            if abs(square['y']) > configuration['shoulder_thresh']:
                if up:
                    robotusb.MoveArm("SLDR_UP")
                else:
                    robotusb.MoveArm("SLDR_DN")
            elif abs(square['y']) > configuration['elbow_thresh']:
                if up:
                    robotusb.MoveArm("ELBW_UP")
Ejemplo n.º 5
0
 def __init__(self, colour='blue'):
     self.colour = colour
     self.configuration = parse_config(colour)
Ejemplo n.º 6
0
 def __init__(self):
     self.configuration = parse_config('track-depth')
Ejemplo n.º 7
0
import vision
import cv2
import gopigo
from parseconfig import parse_config

tracker = vision.TrackSquare(False)

configuration = parse_config('follow')

while True:
    processed, square = tracker.track_show()
    
    if square['w'] != 0:
        area = square['u_width'] * square['u_height']
        if abs(square['x']) > configuration['rotate_tol']:
            if square['x'] > configuration['rotate_tol']:
                gopigo.right()
                print "right"
            else:
                gopigo.left()
                print "left"
        elif configuration['target_area']*(1-configuration['area_tol']) > area or configuration['target_area']*(1+configuration['area_tol']) < area:
            if configuration['target_area']*(1+configuration['area_tol']) < area:
                gopigo.bwd()
                print "bwd"
            else:
                gopigo.fwd()
                print "fwd"
        else:
            gopigo.stop()
    print str(square)