示例#1
0
from pioneer_sdk import Pioneer
import sys

if __name__ == '__main__':
    pioneer_mini = Pioneer()
    pioneer_mini.lua_script_control('Start')
    while True:
        try:
            pass
        except KeyboardInterrupt:
            pioneer_mini.lua_script_control('Stop')
            sys.exit()

示例#2
0
counter = 1
# termination criteria
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)

# prepare object points, like (0,0,0), (1,0,0), (2,0,0) ....,(8,5,0)
obj_p = np.zeros((number_of_hor_corners * number_of_ver_corners, 3),
                 np.float32)
obj_p[:, :2] = np.mgrid[0:number_of_ver_corners,
                        0:number_of_hor_corners].T.reshape(-1, 2)

# Arrays to store object points and image points from all the images.
obj_points = []  # 3d point in real world space
img_points = []  # 2d points in image plane.

if __name__ == '__main__':
    pioneer_mini = Pioneer(logger=False)
    video_frame = bytes()
    if number_of_samples < 10:
        print('Algorithm need at least 10 samples')
        sys.exit(0)
    print('press p to take samples, or esc for exit')
    print(
        'by default they will be stored in ./camera_samples folder and the result file will appear in ./result folder'
    )
    print('Defined number of samples is %d' % number_of_samples)
    os.chdir(os.path.dirname(sys.argv[0]))  # script dir
    samples_folder = os.path.join(os.getcwd(), "camera_samples")
    yaml_folder = os.path.join(os.getcwd(), "result")
    if not os.path.isdir(samples_folder):
        os.mkdir(samples_folder)
    if not os.path.isdir(yaml_folder):
示例#3
0
# флаг отправки команды перемещения
new_command = False


#######################
"""Параметры экрана"""
#######################
FPS = 30
W = 640  # ширина экрана
H = 480  # высота экрана


###########################
"""Инициализация Пионера"""
###########################
pioneer_mini = Pioneer(logger= True) # инициализируем пионера
print('start')
pioneer_mini.arm() # запуск моторов
pioneer_mini.takeoff() # предстартовые проверки


pygame.init() # Иницилизация пугейм
pygame.key.set_repeat(1, 20) # Включение обработки зажатой клавиши

sc = pygame.display.set_mode((W, H))
clock = pygame.time.Clock()


##############################
"""Инициализация джойстиков"""
##############################
示例#4
0
increment_deg = math.radians(float(8))

# флаг отправки команды перемещения
new_command = False

#######################
"""Параметры экрана"""
#######################
FPS = 30
W = 640  # ширина экрана
H = 480  # высота экрана

###########################
"""Инициализация Пионера"""
###########################
pioneer_mini = Pioneer(logger=True)  # инициализируем пионера
print('start')
pioneer_mini.arm()  # запуск моторов
pioneer_mini.takeoff()  # предстартовые проверки

pygame.init()  # Иницилизация пугейм
pygame.key.set_repeat(1, 20)  # Включение обработки зажатой клавиши

sc = pygame.display.set_mode((W, H))
clock = pygame.time.Clock()

##############################
"""Инициализация джойстиков"""
##############################
joy = Joystick()
示例#5
0
    time.sleep(1)
    startFunction(table, "DFailsafe: ", "Проверка посадки при потере сигнала")

    pioneer.arm()
    pioneer.takeoff()
    time.sleep(1)
    print("Отключите wifi соединение с комптером, пока он в воздухе")
    time.sleep(3)
    result = check("Коптер совершил посадку?")
    table.append(str(result))


if __name__ == '__main__':

    print('Инициализация пионера\n')
    pioneer_mini = Pioneer(logger=False)  # инициализируем пионера

    table = []

    version = requests.get('http://192.168.4.1/info')

    print('Для положительного ответа нажмите введите "+" и нажмите enter')

    #led(pioneer_mini, table)
    #distSensor(pioneer_mini, table)
    #cam(pioneer_mini, table)
    arm(pioneer_mini, table)

    time.sleep(3)

    disarm(pioneer_mini, table)
示例#6
0
delta = 0.1
m_to_led = 1000

led_min = 0
led_max = 255

r = led_min
g = led_min
b = led_min

low = 0.25
mid = 0.5
high = 0.75

if __name__ == '__main__':
    pioneer_mini = Pioneer(logger=False)
    curr_time = time.time()
    while True:
        if time.time() - curr_time > delta:
            tof_data = pioneer_mini.get_dist_sensor_data()
            if tof_data is not None:
                if tof_data <= low:
                    r = tof_data * m_to_led
                    g = led_min
                    b = led_min
                elif low < tof_data <= mid:
                    r = (tof_data - low) * m_to_led
                    g = (tof_data - low) * m_to_led
                    b = led_min
                elif mid < tof_data <= high:
                    r = led_min
示例#7
0
import cv2
import math
import numpy as np

command_x = float(0)
command_y = float(0)
command_z = float(1)
command_yaw = math.radians(float(0))
increment_xy = float(0.2)
increment_z = float(0.1)
increment_deg = math.radians(float(90))
new_command = False

if __name__ == '__main__':
    print('start')
    pioneer_mini = Pioneer()
    pioneer_mini.arm()
    pioneer_mini.takeoff()
    while True:
        camera_frame = cv2.imdecode(
            np.frombuffer(pioneer_mini.get_raw_video_frame(), dtype=np.uint8),
            cv2.IMREAD_COLOR)
        cv2.imshow('pioneer_camera_stream', camera_frame)
        key = cv2.waitKey(1)
        if key == 27:  # esc
            print('esc pressed')
            cv2.destroyAllWindows()
            pioneer_mini.land()
            break
        elif key == ord('w'):
            print('w')
示例#8
0
number_of_points = 24
increment = float(360 / number_of_points)
radius = 0.6
flight_height = float(1)
last_point_reached = False

command_x = radius * math.cos(math.radians(angle))
command_y = radius * math.sin(math.radians(angle))
command_yaw = math.radians(angle)

new_point = True
p_r = False

if __name__ == '__main__':
    print('start')
    pioneer_mini = Pioneer()
    pioneer_mini.arm()
    pioneer_mini.takeoff()
    while True:
        camera_frame = cv2.imdecode(
            np.frombuffer(pioneer_mini.get_raw_video_frame(), dtype=np.uint8),
            cv2.IMREAD_COLOR)
        cv2.imshow('pioneer_camera_stream', camera_frame)

        if new_point:
            pioneer_mini.go_to_local_point(x=command_x,
                                           y=command_y,
                                           z=flight_height,
                                           yaw=command_yaw)
            new_point = False