def __init__(self): super().__init__() # Dronen skal være en tråd, så de ikke hænger i beregninger til reporter self.bebop = Bebop() self.yaw_altitude_damper = 0.30 self._movement_vector = Vector() self.voice = Voice() self.flight = Flight(self.bebop) self.threads = [ self.voice, self.flight ] try: self.device = Devices().get_device() except ControllerNotFound: self.voice.force_pronounce('Unable to connect to controller.') exit(0) self.device.method_listener(self.take_off_landing, 'START') self.device.method_listener(self.pitch, 'LEFT_STICK') self.device.method_listener(self.roll, 'LEFT_STICK') self.device.method_listener(self.yaw, 'RIGHT_STICK') self.device.method_listener(self.altitude, 'RIGHT_STICK') self.device.method_listener(self.left_bumper, 'LEFT_BUMPER') self.device.method_listener(self.right_bumper, 'RIGHT_BUMPER') self.device.method_listener(self.change_profile, 'SELECT', self.device.Handler.single) self.device.method_listener(self.do_flat_trim, 'A', self.device.Handler.single) self.device.method_listener(self.change_geofence, 'Y', self.device.Handler.single) self.device.abort_function(self.abort) self.default_profile = 'Default' self.profiles = [] self.profile_idx = 0 self.load_profiles() self.profile_idx = self.get_default_profile() self.running = True self.debug = False self.debug_count = 0 self.debug_button = False self.block_print()
#!/usr/bin/env python from bebop import Bebop if __name__ == '__main__': drone = Bebop(debug=False) while True: drone.takeoff() while not drone.done: drone.move() drone.land() raw_input("Press enter to race again")
def video_end(): print("Ending video...") cv2.destroyWindow("Drone") # Have to send waitKey several times on Unix to make window disappear for i in range(1, 5): cv2.waitKey(1) matcher = Matcher([("fau-logo", "../opencv/templates/fau-logo.png"), ("first-logo", "../opencv/templates/first-logo.jpg"), ("nextera-logo", "../opencv/templates/nextera-energy-logo.jpg"), ("techgarage-logo", "../opencv/templates/techgarage-logo.png") ], min_keypoints_pct_match=10) print("Connecting to drone..") drone = Bebop() drone.video_callbacks(video_start, video_end, video_frame) drone.videoEnable() print("Connected.") for i in xrange(10000): if command is None: drone.update( ); elif command == "TAKEOFF": print("Taking offf.........................") drone.takeoff() command = None elif command == "LAND": print("Landing ...........................") drone.land() command = None
drone.trim() drone.takeoff() # drone.flyToAltitude( 1.5 ) # for i in xrange(1000): # print i, # drone.update( cmd=None ) drone.land() except ManualControlException, e: print print "ManualControlException" if drone.flyingState is None or drone.flyingState == 1: # taking off drone.emergency() drone.land() if __name__ == "__main__": if len(sys.argv) < 2: print __doc__ sys.exit(2) metalog = None if len(sys.argv) > 2: metalog = MetaLog(filename=sys.argv[2]) if len(sys.argv) > 3 and sys.argv[3] == 'F': disableAsserts() drone = Bebop(metalog=metalog) demo(drone) print "Battery:", drone.battery # vim: expandtab sw=4 ts=4
g_queueOut = Queue() g_processor = Process(target=processMain, args=(g_queueOut, )) g_processor.daemon = True g_processor.start() g_queueOut.put_nowait(frame) # H264 compressed video frame def testCVideo(drone): drone.videoCbk = videoCallback drone.videoEnable() for i in xrange(400): drone.update() if g_queueOut is not None: g_queueOut.put_nowait(None) g_processor.join() if __name__ == "__main__": if len(sys.argv) < 2: print __doc__ sys.exit(2) metalog = None if len(sys.argv) > 2: metalog = MetaLog(filename=sys.argv[2]) if len(sys.argv) > 3 and sys.argv[3] == 'F': disableAsserts() drone = Bebop(metalog=metalog, onlyIFrames=False) testCVideo(drone) # vim: expandtab sw=4 ts=4
ret, image = cap.read() index += 1 else: key = cv2.waitKey(0) if __name__ == "__main__": if len(sys.argv) < 2: print __doc__ sys.exit(2) if sys.argv[1] == "--test": filename = sys.argv[2] stopAt = None if len(sys.argv) > 3: stopAt = int(sys.argv[3]) replayVideoStream(filename=filename, stopAt=stopAt) sys.exit(0) metalog = None if len(sys.argv) > 2: metalog = MetaLog(filename=sys.argv[2]) if len(sys.argv) > 3 and sys.argv[3] == 'F': disableAsserts() drone = Bebop(metalog=metalog, onlyIFrames=True) # testCamera( drone ) testAutomaticLanding(drone) print "Battery:", drone.battery, "(%.2f, %.2f, %.2f)" % drone.position # vim: expandtab sw=4 ts=4
from bebop import Bebop import logging logging.basicConfig() print("Connecting to drone...") drone = Bebop(loggingLevel=logging.DEBUG) print("Connected.") drone.wait(5)
def video2stdout(): drone = Bebop(metalog=None, onlyIFrames=False) drone.videoCbk = videoCallback drone.videoEnable() while True: drone.update()