def __init__(self): # Init pygame pygame.init() # Creat pygame window pygame.display.set_caption("Tello video stream") self.screen = pygame.display.set_mode([960, 720]) # Init Tello object that interacts with the Tello drone self.tello = Tello() # Drone velocities between -100~100 self.for_back_velocity = 0 self.left_right_velocity = 0 self.up_down_velocity = 0 self.yaw_velocity = 0 self.speed = 10 ################################################################### ##Drone Project Defined variables self.hasTakenOff = False self.specifiedTarget = known_face_names[0] self.targetSeen = False self.targetLeftSide = 320 # set to default self.targetRightSide = 640 ################################################################### self.send_rc_control = False # create update timer pygame.time.set_timer(USEREVENT + 1, 50)
def __init__(self): self.me = Tello() self.me.connect() self.me.front_back_velocity = 0 self.me.left_right_velocity = 0 self.me.up_down_velocity = 0 self.face_cascade = cv2.CascadeClassifier("haarcascade_frontalface_default.xml") self.eyes_cascade = cv2.CascadeClassifier("haarcascade_eye.xml") self.me.yaw_velocity = 0 self.me.speed = 0 print(self.me.get_battery()) self.me.streamoff() self.me.streamon() self.me.takeoff() #self.me.move_up(50) self.width = 500 self.height = 500 self.hei_hf = int(self.height / 9) self.state = None self.maxspeed = 40 cv2.waitKey(1) print('initialized') self.steps_beyond_done = None self.observation_space = box.Box(0, 1, shape=(3,), dtype=np.float32) self.action_space = box.Box(-1, +1, (3,), dtype=np.float32)
def __init__(self): # Init pygame pygame.init() # Creat pygame window pygame.display.set_caption("control stream") self.screen = pygame.display.set_mode([960, 720]) # self.screen = pygame.display.set_mode([416, 416]) # Init Tello object that interacts with the Tello drone self.tello = Tello() self.actor = Actor(30.0) self.actor.load_state_dict(torch.load("agents/actor.pth")) # Drone velocities between -100~100 self.for_back_velocity = 0 self.left_right_velocity = 0 self.up_down_velocity = 0 self.yaw_velocity = 0 self.speed = 60 self.send_rc_control = False # create update timer pygame.time.set_timer(USEREVENT + 1, 50)
def __init__(self): # Init pygame pygame.init() # Creat pygame window pygame.display.set_caption("Tello video stream") self.screen = pygame.display.set_mode([960, 720]) # Init Tello object that interacts with the Tello drone self.tello = Tello() # Drone velocities between -100~100 self.for_back_velocity = 0 self.left_right_velocity = 0 self.up_down_velocity = 0 self.yaw_velocity = 0 self.speed = 60 self.send_rc_control = False # create update timer pygame.time.set_timer(USEREVENT + 1, 50) pygame.time.set_timer(USEREVENT + 2, 250) # Run thread to find box in frame print('init done')
def __init__(self): # Init pygame pygame.init() # Init joystick self.j = pygame.joystick.Joystick(0) self.j.init() # Creat pygame window pygame.display.set_caption("Tello video stream") self.screen = pygame.display.set_mode([960, 720]) # Init Tello object that interacts with the Tello drone self.tello = Tello() # Drone velocities between -100~100 self.for_back_velocity = 0 self.left_right_velocity = 0 self.up_down_velocity = 0 self.yaw_velocity = 0 self.speed = 10 self.send_rc_control = False # create update timer pygame.time.set_timer(pygame.USEREVENT + 1, 50)
def connect(self, ip, timeout=5): # 必须实现 # 用户在 scratch 界面点击连接时,会触发该函数 if not self.thing: self.thing = Tello() is_connected = self.thing.connect() # 幂等操作 ,udp self.is_connected = is_connected return True
def __init__(self): self.drone = Tello() # Instantiate a Tello Object self.drone.connect() # Connect to the drone self.drone.streamoff() # In case stream never exited before self.drone.streamon() # Turn on drone camera stream time.sleep(5) # Give the stream time to start up self.timer = 0 # Timing for printing statements self.move()
def __init__(self): self.tello = Tello() self.tello.connect() self.forBack = 0 self.turn = 0 self.upDown = 0 self.leftRight = 0 self.speed = 20 self.airborne = False
def __init__(self, window_width, window_height): # Init pygame pygame.init() # Creat pygame window self.screen = pygame.display.set_mode([window_width, window_height]) # [960, 720] # Init Tello object that interacts with the Tello drone self.tello = Tello()
def run(self): "避免插件结束退出" try: self.tello = Tello() except Exception as e: self.logger.error(e) self.pub_notification(str(e), type="ERROR") return while self._running: time.sleep(0.5)
class DroneActions: def __init__(self): self.tello = Tello() self.tello.connect() sleep(2) def takeoff(self): self.tello.takeoff() while self.tello.get_h() < 30: sleep(0.5) def land(self): self.tello.land() def execute(self, command): self.send_control_command(*command) def set_velocity(self, values): self.tello.send_rc_control(*values) def find_pink(self): self.set_velocity([0, 0, 0, 100]) sleep(2) self.set_velocity([0, 0, 0, 0]) def choreo(self): self.takeoff() self.find_pink() self.land()
def __init__(self): self.drone = Tello() # Instantiate a Tello Object self.drone.connect() # Connect to the drone self.drone.streamoff() # In case stream never exited before self.drone.streamon() # Turn on drone camera stream self.timer = 0 # Timing for printing statements self.flying = False # Keep track of flying state # How many video frames have been requested self.frame_count = 0 self.init_frames = 50 # Begin flying only after init_frames self.myThread = threading.Thread(target=self.fly)
class Drone(object): def __init__(self): self.drone = None self.drone_speed = 25 self.connect_drone() def __del__(self): global tello_conn print("tello destroyed") self.disconnect_drone() tello_conn.close() def begin_scan(self): i = 18 sleep(1) while i != 0: self.drone.rotate_clockwise(21) sleep(2) self.drone.move_up(23) sleep(3) self.drone.move_down(23) i -= 1 sleep(3) def stream_image_to_pipe(self): camera = picamera.PiCamera() camera.resolution = (640, 480) output_path = vars(ap.parse_args())['output'] filename = os.path.join(output_path, 'outpy.h264') print('Save video to: ', filename) camera.start_recording(filename) while True: camera.wait_recording(1) camera.stop_recording() print("Created video file") def connect_drone(self): self.drone = Tello() if not self.drone.connect(): raise RuntimeError("drone not connected") self.drone.streamon() def disconnect_drone(self): self.drone.streamoff() self.drone = None def scan(self, triangulation_type): self.drone.takeoff() sleep(3) Thread(target=self.stream_image_to_pipe, daemon=True).start() self.begin_scan(triangulation_type) print("battery after scan:" + self.drone.get_battery()) self.drone.land() sleep(3)
def __init__(self): # Init Tello object that interacts with the Tello drone self.tello = Tello() # Drone velocities between -100~100 self.for_back_velocity = 0 self.left_right_velocity = 0 self.up_down_velocity = 0 self.yaw_velocity = 0 self.speed = 10 self.safe_zone = args.SafeZone self.oSpeed = args.override_speed self.send_rc_control = False
def __init__(self): self.tello = Tello() self.yaw_velocity = 0 self.for_back_velocity = 0 self.left_right_velocity = 0 self.up_down_velocity = 0 self.speed = 10 self.mode = None self.send_rc_control = False self.height_limit = 200 # Default Speed of droone self.S = 60
def main(): print("now i am gonna start the mission") tello = Tello() tello.offset = 60 tello.connect() tello.streamoff() tello.streamon() start = hoohah(tello) start.run()
def __init__(self): # Init Tello object that interacts with the Tello drone self.tello = Tello() # Drone velocities between -100~100 self.for_back_velocity = 0 self.left_right_velocity = 0 self.up_down_velocity = 0 self.yaw_velocity = 0 self.speed = 10 # Autonomous mode: Navigate autonomously self.autonomous = True # Enroll mode: Try to find new faces self.enroll_mode = False # Create arrays of known face encodings and their names self.known_face_encodings = [] self.known_face_names = [] # Logic used for navigation self.face_locations = None self.face_encodings = None self.target_name = "" self.has_face = False self.detect_faces = True self.wait = 0 self.load_all_faces() # Video frame for Streaming self.frame_available = None if not self.tello.connect(): print("Tello not connected") raise Exception("Tello not connected") if not self.tello.set_speed(self.speed): print("Not set speed to lowest possible") raise Exception("Not set speed to lowest possible") # In case streaming is on. This happens when we quit this program without the escape key. if not self.tello.streamoff(): print("Could not stop video stream") raise Exception("Could not stop video stream") if not self.tello.streamon(): print("Could not start video stream") raise Exception("Could not start video stream") self.loop()
def __init__(self): # Init pygame pygame.init() # Creat pygame window pygame.display.set_caption("Tello video stream") self.screen = pygame.display.set_mode([960, 720]) # Init Tello object that interacts with the Tello drone self.tello = Tello() # Drone velocities between -100~100 self.for_back_velocity = 0 self.left_right_velocity = 0 self.up_down_velocity = 0 self.yaw_velocity = 0 self.speed = 10 # Object varaiables self.x = 0 self.y = 0 self.h = 0 self.w = 0 self.area = 0.0 self.auto_follow = False # Status self.takeoff_status = False self.land_status = False self.send_rc_control = False self.should_stop = False self.image_publisher = rospy.Publisher('/tello/image', Image, queue_size=1) self.takeoff_msg = rospy.Subscriber('/tello/takeoff', Bool, self.takeoff_callback, queue_size=1) self.land_msg = rospy.Subscriber('/tello/land', Bool, self.land_callback, queue_size=1) self.detector_msg = rospy.Subscriber('/darknet_ros/bounding_boxes', BoundingBoxes, self.boxes_callback, queue_size=1) self.bridge = CvBridge() # create update timer pygame.time.set_timer(USEREVENT + 1, 50) self.thread = threading.Thread(target=self.run) self.thread.start()
def __init__(self): # Init Tello object that interacts with the Tello drone self.tello = Tello() # Drone velocities between -100~100 self.for_back_velocity = 0 self.left_right_velocity = 0 self.up_down_velocity = 0 self.yaw_velocity = 0 self.speed = 10 self.mode = PMode.NONE # Can be '', 'FIND', 'OVERRIDE' or 'FOLLOW' self.send_rc_control = False
def __init__(self): # Init Tello object that interacts with the Tello drone self.tello = Tello() # Drone velocities between -100~100 self.for_back_velocity = 0 self.left_right_velocity = 0 self.up_down_velocity = 0 self.yaw_velocity = 0 self.speed = 20 self.theta = 0 self.send_rc_control = False
def __init__(self): # Init pygame pygame.init() # Creat pygame window pygame.display.set_caption("Tello video stream") self.screen = pygame.display.set_mode([960, 360]) # create object detector coco_frozen_graph_path = './ssd_mobilenet_v2_coco_2018_03_29/frozen_inference_graph.pb' coco_labels_path = './ssd_mobilenet_v2_coco_2018_03_29/mscoco_label_map.pbtxt' self.coco_obj_detector = Object_Detector(coco_frozen_graph_path, coco_labels_path, debug_mode=True) # create object detector face_frozen_graph_path = './ssd_face_detection/frozen_inference_graph_face.pb' face_labels_path = './ssd_face_detection/face_label_map.pbtxt' self.face_obj_detector = Object_Detector(face_frozen_graph_path, face_labels_path, debug_mode=True) #create tracker object self.tracker = Object_Tracker(class_id=1) # create depth detector self.depth_detector = Depth_Detector() self.object_depth_detector = Object_Depth_Detector() #create planner self.planner = Planner() self.face_bounding_box = [ 0.3, 0.4, 0.5, 0.6, 0.1, 0.2 ] #[min_y, min_x, max_y, max_x, min_size, max_size] self.person_bounding_box = [ 0.45, 0.45, 0.55, 0.55, 0.3, 0.5 ] #[min_y, min_x, max_y, max_x, min_size, max_size] # Init Tello object that interacts with the Tello drone self.tello = Tello() # Drone velocities between -100~100 self.for_back_velocity = 0 self.left_right_velocity = 0 self.up_down_velocity = 0 self.yaw_velocity = 0 self.speed = 10 self.follow_human = False self.send_rc_control = False # create update timer pygame.time.set_timer(USEREVENT + 1, 50)
def __init__(self): # 드론과 상호작용하는 Tello 객체 self.tello = Tello() # 드론의 속도 (-100~100) #수직, 수평 속도 self.for_back_velocity = 0 self.left_right_velocity = 0 self.up_down_velocity = 0 self.yaw_velocity = 0 self.speed = 10 self.send_rc_control = False
def fromIps(ips, enable_exceptions=True): if len(ips) == 0: raise Exception("No ips provided") firstTello = Tello(ips[0]) tellos = [firstTello] for ip in ips[1:]: tellos.append( Tello(ip, client_socket=firstTello.clientSocket, enable_exceptions=enable_exceptions)) return TelloSwarm(tellos)
def list(self, timeout=5) -> list: # 必须实现 # scratch scan 会触发这个函数,返回值将进入 Scratch 扫描到的设备列表中。 if not self.thing: self.thing = Tello() self.thing.RESPONSE_TIMEOUT = timeout logger.debug(f"self.thing: {self.thing}") try: self.thing.connect() # 返回True有问题,如果没有飞机,就会except return ["192.168.10.1"] except Exception as e: logger.debug(f'error: {str(e)}') self.node_instance.pub_notification(str(e), type="ERROR") return []
def cameraCalibration(filename): CALI_IMG_NUM = 50 # termination criteria for cv2.cornerSubPix criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.1) # prepare object points, like (0,0,0), (1,0,0), (2,0,0) ....,(8,5,0) // (x, y, 0) objp = np.zeros((9 * 6, 3), np.float32) objp[:, :2] = np.mgrid[0:9, 0:6].T.reshape(-1, 2) # Arrays to store object points and image points from all the images. objpoints = [] # 3d point in real world space imgpoints = [] # 2d points in image plane. drone = Tello() drone.connect() drone.streamon() drone.get_frame_read() # cap = cv2.VideoCapture(0, cv2.CAP_DSHOW) # capturing img for calibration print('Capturing...') cnt = 0 while (True): frame = drone.background_frame_read.frame gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) ret, corners = cv2.findChessboardCorners(gray, (9, 6), None) if ret == True: print(f'chessboard_{cnt}') cnt += 1 if cnt > CALI_IMG_NUM: break objpoints.append(objp) corners2 = cv2.cornerSubPix(gray, corners, (11, 11), (-1, -1), criteria) imgpoints.append(corners2) # Draw and display the corners frame = cv2.drawChessboardCorners(frame, (9, 6), corners2, ret) cv2.imshow('chessboard', frame) key = cv2.waitKey(200) cv2.destroyAllWindows() # calibration print('calibrating...') ret, cameraMatrix, distCoeffs, rvecs, tvecs = cv2.calibrateCamera( objpoints, imgpoints, gray.shape[::-1], None, None) # shape[::-1] : reversed slicing # refine parameters h, w = 720, 960 # telloCam shape newcameramtx, roi = cv2.getOptimalNewCameraMatrix(cameraMatrix, distCoeffs, (w, h), 0, (w, h)) f = cv2.FileStorage(filename, cv2.FILE_STORAGE_WRITE) f.write("intrinsic", cameraMatrix) f.write("distortion", distCoeffs) f.write("newcameramtx", newcameramtx) f.release() print('calibration finished!!') exit()
def __init__(self): self.tello = Tello() # Drone velocities between -100~100 self.for_back_velocity = 0 self.left_right_velocity = 0 self.up_down_velocity = 0 self.yaw_velocity = 0 self.speed = 10 self.h_pid = PID(0.1, 0.00001, 0.01) self.v_pid = PID(0.5, 0.00001, 0.01) self.dist_pid = PID(0.1, 0.00001, 0.01) self.send_rc_control = False
def main(): print("now i am gonna start the mission") tello = Tello() tello.connect() tello.streamoff() tello.streamon() start = starting(tello) start.run(0)
def initializeTello(): myDrone = Tello() myDrone.connect() # myDrone.for_back_velocity = 0 # myDrone. left_right_velocity = 0 # myDrone.up_down_velocity = 0 # myDrone.yaw_velocity = 0 # myDrone.speed = 0 print(myDrone.get_battery()) myDrone.streamoff() myDrone.streamon() return myDrone
def main(): print("ahahah") tello = Tello() tello.connect() tello.streamoff() tello.streamon() frontend = FrontEnd(tello) print("noooo") frontend.run(1, 0, tello.get_yaw()) #left,up print("found the end of the code")
def main(): tello = Tello() frontend = FrontEnd(tello) frontend.run() print("found the end of the code")