Пример #1
0
 def __init__(self, speed = 50):
     '''
     Well, initialize
     '''
     #Class variables
     self.emergency_land_activated = False
     self.take_off_activated = False
     self.battery_log_delay = 2
     self.speed = speed
     #Initialize the drone and stream
     print("INIT: Connecting to Ryze Tello @192.168.10.1")
     print("Intructions: \t'Esc': Emergency Land")
     self.drone = Tello()
     time.sleep(1)
     print("LOG: Tello set up!")
     self.drone.send_command("streamon")
     time.sleep(1)
     self.cap = cv2.VideoCapture("udp://192.168.10.1:11111")
     # self.cap.set(cv2.CAP_PROP_BUFFERSIZE, 3)
     print("LOG: Stream service on")
     #Set up battery and emergency land threads
     self.battery_thread = Thread(target=self._battery_thread)
     self.battery_thread.daemon = True
     self.battery_thread.start()
     print("LOG: Battery thread started")
     #Set up ArUco detection
     self.aruco_dict = aruco.Dictionary_get(aruco.DICT_6X6_250)
     self.params = aruco.DetectorParameters_create()
     print("LOG: ArUco set up")
     #Set up camera matrix and distortion coeffs
     self.cv_file = cv2.FileStorage("tello_params.yaml", cv2.FILE_STORAGE_READ)
     self.cam_mtx = self.cv_file.getNode("camera_matrix").mat()
     self.dist_coeff = self.cv_file.getNode("dist_coeff").mat()[0]
     self.cv_file.release()
Пример #2
0
    def deploy(self):
        """
        Deploys commands built up for drone object to real drone via easyTello.
        Note: computer must be connected to the drone's WiFi network.

        Examples
        ----------
        drone.deploy() # deploy commands to drone

        """
        print('Deploying your commands to a real Tello drone!')

        if (self.driver_instance is None):
            # Since the driver binds to a socket on instantiation, we can only
            # keep a single driver instance open per session
            self.driver_instance = Tello()

        for command in self.command_log:
            self.driver_instance.send_command(self.serialize_command(command))
Пример #3
0
def main():
    print("Setting up Tello")
    drone = Tello()
    time.sleep(1)
    print("Tello set up!")
    print("Starting stream service")
    drone.send_command("streamon")
    time.sleep(2)
    cap = cv2.VideoCapture("udp://" + drone.tello_ip + ":11111")
    print("Started")
    while 1:
        _, frame = cap.read()
        cv2.imshow("DJI Tello", frame)
        k = cv2.waitKey(1) & 0xFF
        if k == 27:
            break
    cap.release()
    cv2.destroyAllWindows()
    drone.send_command("streamoff")
Пример #4
0
if __name__ == '__main__':
    # logging.basicConfig(level=logging.INFO)
    # logger = logging.getLogger('track_demo')

    PATH_TO_LABELS = 'export/label_map.pbtxt'
    category_index = label_map_util.create_category_index_from_labelmap(
        PATH_TO_LABELS, use_display_name=True)

    detection_model = load_model()
    print('---warming up detection model---')
    run_inference_for_single_image(
        detection_model, cv2.imread('./test_images/IMG_20200428_144451.jpg'))

    detection_model = DetectionModel(detection_model, category_index)

    tello = Tello()
    tello.command()
    tello.streamon()
    # tello.get_battery()
    # a = dumy_tello()
    # a.frame = np.random.randn(300, 300)
    tello_tracker = TelloTracker(detection_model,
                                 tello,
                                 output_video='out.mp4')
    try:
        tello_tracker.track(verbose=True)
        tello.land()
        time.sleep(0.75)
        tello.emergency()
    except Exception as e:
        tello.emergency()