Beispiel #1
0
    def __init__(self, yaw_p, yaw_d, depth_p, depth_d):
        self.end = False
        self.final = False
        self.auv = mur.mur_init()
        self.yaw_pd = PD(yaw_p, yaw_d)
        self.depth_pd = PD(depth_p, depth_d)

        self.bottom_cam = CameraBottom()
        self.front_cam = CameraFront()

        self.state = 0
        self.yaw = 0
        self.depth = 2
        self.speed = 0

        self.hsv_mask_min_orange = (15, 50, 50)
        self.hsv_mask_max_orange = (30, 255, 255)

        self.hsv_mask_min_yellow = (20, 50, 50)
        self.hsv_mask_max_yellow = (30, 255, 255)

        self.hsv_mask_min_green = (40, 40, 20)
        self.hsv_mask_max_green = (80, 255, 255)

        self.hsv_mask_min_blue = (130, 40, 20)
        self.hsv_mask_max_blue = (150, 255, 255)

        self.hsv_mask_min_red = (0, 40, 0)
        self.hsv_mask_max_red = (15, 255, 255)
Beispiel #2
0
class Data(metaclass=Solide):
    __yaw = 0
    __depth = 0
    __mur = mur.mur_init()
    __filters = {}

    def get_yaw(self):
        return self.__yaw

    def get_depth(self):
        return self.__depth

    def set_yaw(self, i):
        self.__yaw = i

    def set_depth(self, i):
        self.__depth = i

    def get_img_bottom(self):
        return self.__mur.get_image_bottom()

    def get_img_front(self):
        return self.__mur.get_image_front()

    def get_filter(self, key):
        return self.__filters[key]

    def set_filters(self, key, val):
        self.__filters[key] = val
Beispiel #3
0
 def __init__(self, view):
     if view != "Bottom" and view != "Front":
         raise ValueError("Wrong camera view.")
     self.auv = mur.mur_init()
     self.img = np.array([])
     self.mask = np.array([])
     self.original = np.array([])
     self.box = None
     self.view = view
Beispiel #4
0
    def __init__(self, yaw_p, yaw_d, depth_p, depth_d):
        self.auv = mur.mur_init()
        self.yaw_pd = PD(yaw_p, yaw_d)
        self.depth_pd = PD(depth_p, depth_d)
        self.end = False

        self.bottom_cam = CameraBottom()

        self.state = 0
        self.yaw = 0
        self.depth = 2
        self.speed = 0
        self.circles = 0
        self.is_tr = False
Beispiel #5
0
import pymurapi as mur
import cv2
import numpy as np
import math
import time

auv = mur.mur_init()

def wait(t):
    ntt = time.time()
    while  time.time() - ntt < t/10:          
        auv.set_motor_power(0, 0)
        auv.set_motor_power(1, 0)
        auv.set_motor_power(2, 0)
        auv.set_motor_power(3, 0)
        auv.set_motor_power(4, 0) 
        if time.time() - ntt > t/1000:
           break 

# Перевод угла >< 360 в 0 <=> 360
def clamp_to_360(angle):
    if angle < 0.0:
        return angle + 360.0
    if angle > 360.0:
        return angle - 360.0
    return angle

# Перевод угла из 0 <=> 360 в -180 <=> 180
def to_180(angle):
    if angle > 180.0:
        return angle - 360.0
Beispiel #6
0
import cv2
import pymurapi as mur
import numpy as np
from Class.Classificate import ColorClassif
from time import time

mr = mur.mur_init()


def nothing(x):
    pass


def test(img):
    cv2.namedWindow("Tracking")
    cv2.createTrackbar("LowH", "Tracking", 0, 255, nothing)
    cv2.createTrackbar("LowS", "Tracking", 0, 255, nothing)
    cv2.createTrackbar("LowV", "Tracking", 0, 255, nothing)
    cv2.createTrackbar("UnH", "Tracking", 255, 255, nothing)
    cv2.createTrackbar("UnS", "Tracking", 255, 255, nothing)
    cv2.createTrackbar("UnV", "Tracking", 255, 255, nothing)
    while True:
        frame = mr.get_image_front()
        hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
        l_h = cv2.getTrackbarPos("LowH", "Tracking")
        l_s = cv2.getTrackbarPos("LowS", "Tracking")
        l_v = cv2.getTrackbarPos("LowV", "Tracking")

        h_h = cv2.getTrackbarPos("UnH", "Tracking")
        h_s = cv2.getTrackbarPos("UnS", "Tracking")
        h_v = cv2.getTrackbarPos("UnV", "Tracking")
Beispiel #7
0
        return yellow


if __name__ == '__main__':

    start_time = time.time()
    from time import sleep
    from sys import exit
    import numpy as np
    import time

    catch_time = 1  #delay to catch obj
    ret_time = 9  #delay to move without detecting
    a_height = -3
    t_speed = 55  #travel speed
    mur = pymurapi.mur_init()
    f = function(mur)
    v = vision(cv)
    ang = 0

    #track(mur,f)
    #while True:
    #    v.detect_object(mur.get_image_bottom(), green)
    while True:
        timer = time.time()
        while time.time() - timer <= 0.5:
            f.keep_depth(a_height)
        while f.set_arrow(v, a_height, orange) == -1:
            continue
        ang = mur.get_yaw()
        timer = time.time()
Beispiel #8
0
 def __init__(self, koof):
     self.__avi = mur.mur_init()
     self.__pd_list = koof
     self.__timestemp = Run(7, 50)
Beispiel #9
0
from Class.Motor import Motor
from Class.Math import PD
import pymurapi as mur
from Class.Data import Data
from Class.Classificate import ColorClassif
from time import sleep

avi = mur.mur_init()
motor = Motor({"depth": PD(30, 5), "yaw": PD(0.5, 0.8), "x_y": PD(0.1, 0.6)})

Data().set_filters("red", ColorClassif((0, 139, 0), (16, 255, 255)))
Data().set_filters("green", ColorClassif((62, 229, 93), (98, 255, 255)))
Data().set_filters("blue", ColorClassif((30, 185, 211), (255, 255, 255)))
Data().set_filters("yellow", ColorClassif((19, 193, 95), (33, 255, 255)))
Data().set_filters("white", ColorClassif((0, 0, 0), (255, 4, 255)))
Data().set_filters("black", ColorClassif((0, 0, 0), (123, 255, 36)))

motor.depth_to_time(14, 2.3)
motor.keep_front_cycle()