def fly(self): print("Takeoff if necessary...") self.drone( FlyingStateChanged(state="hovering", _policy="check") | FlyingStateChanged(state="flying", _policy="check") | ( GPSFixStateChanged(fixed=1, _timeout=10, _policy="check_wait") >> ( TakeOff(_no_expect=True) & FlyingStateChanged( state="hovering", _timeout=10, _policy="check_wait") ) ) ).wait() self.drone(MaxTilt(40)).wait().success() for i in range(3): print("Moving by ({}/3)...".format(i + 1)) self.drone(moveBy(0.1, 0, 0, math.pi, _timeout=20)).wait().success() print("Landing...") self.drone( Landing() >> FlyingStateChanged(state="landed", _timeout=5) ).wait() print("Landed\n")
def test_maxtilt(): drone = olympe.Drone(DRONE_IP) drone.connect() maxTiltAction = drone(MaxTilt(10)).wait() if maxTiltAction.success(): print("MaxTilt(10) success") elif maxTiltAction.timedout(): print("MaxTilt(10) timedout") else: # If ".wait()" is called on the ``maxTiltAction`` this shouldn't happen print("MaxTilt(10) is still in progress") maxTiltAction = drone(MaxTilt(0)).wait() if maxTiltAction.success(): print("MaxTilt(0) success") elif maxTiltAction.timedout(): print("MaxTilt(0) timedout") else: # If ".wait()" is called on the ``maxTiltAction`` this shouldn't happen print("MaxTilt(0) is still in progress") drone.disconnect()
def takeOff(self): print("Takeoff if necessary...") self.drone( FlyingStateChanged(state="hovering", _policy="check") | FlyingStateChanged(state="flying", _policy="check") | ( GPSFixStateChanged(fixed=1, _timeout=10, _policy="check_wait") >> ( TakeOff(_no_expect=True) & FlyingStateChanged( state="hovering", _timeout=10, _policy="check_wait") ) ) ).wait() self.drone(MaxTilt(40)).wait().success()
def start(self): self.drone.connect() # Setup your callback functions to do some live video processing self.drone.set_streaming_callbacks( raw_cb=self.yuv_frame_cb, start_cb=self.start_cb, end_cb=self.end_cb, flush_raw_cb=self.flush_cb, ) # Start video streaming self.drone.start_video_streaming() # set maximum speeds print("rotation", self.drone(MaxRotationSpeed(1)).wait().success()) print("vertical", self.drone(MaxVerticalSpeed(0.1)).wait().success()) print("tilt", self.drone(MaxTilt(5)).wait().success())
def reconfigure_callback(self, config, level): if level == -1 or level == 1: self.drone(MaxTilt(config['max_tilt'])).wait( ) # https://developer.parrot.com/docs/olympe/arsdkng_ardrone3_piloting.html?#olympe.messages.ardrone3.PilotingSettings.MaxTilt self.drone(MaxVerticalSpeed(config['max_vertical_speed'])).wait( ) # https://developer.parrot.com/docs/olympe/arsdkng_ardrone3_piloting.html#olympe.messages.ardrone3.SpeedSettings.MaxVerticalSpeed self.drone( MaxRotationSpeed(config['max_yaw_rotation_speed']) ).wait( ) # https://developer.parrot.com/docs/olympe/arsdkng_ardrone3_piloting.html#olympe.messages.ardrone3.SpeedSettings.MaxRotationSpeed self.drone( MaxPitchRollRotationSpeed( config['max_pitch_roll_rotation_speed']) ).wait( ) # https://developer.parrot.com/docs/olympe/arsdkng_ardrone3_piloting.html#olympe.messages.ardrone3.SpeedSettings.MaxPitchRollRotationSpeed self.drone(MaxDistance(config['max_distance'])).wait( ) # https://developer.parrot.com/docs/olympe/arsdkng_ardrone3_piloting.html#olympe.messages.ardrone3.PilotingSettings.MaxDistance self.drone(MaxAltitude(config['max_altitude'])).wait( ) # https://developer.parrot.com/docs/olympe/arsdkng_ardrone3_piloting.html#olympe.messages.ardrone3.PilotingSettings.MaxAltitude self.drone(NoFlyOverMaxDistance(1)).wait( ) # https://developer.parrot.com/docs/olympe/arsdkng_ardrone3_piloting.html#olympe.messages.ardrone3.PilotingSettings.NoFlyOverMaxDistance self.drone(BankedTurn(int(config['banked_turn']))).wait( ) # https://developer.parrot.com/docs/olympe/arsdkng_ardrone3_piloting.html#olympe.messages.ardrone3.PilotingSettings.BankedTurn self.max_tilt = config['max_tilt'] self.max_vertical_speed = config['max_vertical_speed'] self.max_rotation_speed = config['max_yaw_rotation_speed'] if level == -1 or level == 2: self.gimbal_frame = 'absolute' if config[ 'gimbal_compensation'] else 'relative' self.drone( gimbal.set_max_speed( gimbal_id=0, yaw=0, pitch=config['max_gimbal_speed'], # [1 180] (deg/s) roll=config['max_gimbal_speed'] # [1 180] (deg/s) )).wait() return config
# -*- coding: UTF-8 -*- from __future__ import print_function # python2/3 compatibility for the print function import olympe from olympe.messages.ardrone3.PilotingSettings import MaxTilt drone = olympe.Drone("10.202.0.1") drone.connection() maxTiltAction = drone(MaxTilt(10)).wait() if maxTiltAction.success(): print("MaxTilt(10) success") elif maxTiltAction.timedout(): print("MaxTilt(10) timedout") else: # If ".wait()" is called on the ``maxTiltAction`` this shouldn't happen print("MaxTilt(10) is still in progress") maxTiltAction = drone(MaxTilt(0)).wait() if maxTiltAction.success(): print("MaxTilt(0) success") elif maxTiltAction.timedout(): print("MaxTilt(0) timedout") else: # If ".wait()" is called on the ``maxTiltAction`` this shouldn't happen print("MaxTilt(0) is still in progress") drone.disconnection()
# -*- coding: UTF-8 -*- from __future__ import print_function # python2/3 compatibility for the print function import olympe from olympe.messages.ardrone3.PilotingSettings import MaxTilt drone = olympe.Drone("10.202.0.1") drone.connection() print("==================================\n\n\n") maxTiltAction = drone(MaxTilt(10, _timeout=1)).wait() if maxTiltAction.success(): print("MaxTilt(10) success") elif maxTiltAction.timedout(): print("MaxTilt(10) timedout") else: # If ".wait()" is called on the ``maxTiltAction`` this shouldn't happen print("MaxTilt(10) is still in progress") maxTiltAction = drone(MaxTilt(0, _timeout=1)).wait() if maxTiltAction.success(): print("MaxTilt(0) success") elif maxTiltAction.timedout(): print("MaxTilt(0) timedout") else: # If ".wait()" is called on the ``maxTiltAction`` this shouldn't happen print("MaxTilt(0) is still in progress") print("\n\n\n==================================") drone.disconnection()
def customShadowCallback_Delta(payload, responseStatus, token): # payload is a JSON string ready to be parsed using json.loads(...) # in both Py2.x and Py3.x print(responseStatus) payloadDict = json.loads(payload) print("++++++++DELTA++++++++++") print("state: " + str(payloadDict["state"])) print("version: " + str(payloadDict["version"])) print("+++++++++++++++++++++++\n\n") if 'gimbal_pitch' in payloadDict['state'].keys(): droneThing.drone( gimbal.set_target( gimbal_id=0, control_mode="position", yaw_frame_of_reference="none", # None instead of absolute yaw=0.0, pitch_frame_of_reference="absolute", pitch=payloadDict['state']['gimbal_pitch'], roll_frame_of_reference="none", # None instead of absolute roll=0.0, )).wait() print('updated gimbal_pitch') if 'gimbal_speed' in payloadDict['state'].keys(): droneThing.drone( gimbal.set_max_speed( gimbal_id=0, yaw=0.0, pitch=payloadDict['state']['gimbal_speed'], roll=0.0, )).wait() print('updated gimbal_speed') if 'max_vertical_speed' in payloadDict['state'].keys(): droneThing.drone( MaxVerticalSpeed( payloadDict['state']['max_vertical_speed'])).wait() print('updated max_vertical_speed') if 'max_rotation_speed' in payloadDict['state'].keys(): droneThing.drone( MaxRotationSpeed( payloadDict['state']['max_rotation_speed'])).wait() print('updated max_rotation_speed') if 'max_tilt' in payloadDict['state'].keys(): droneThing.drone(MaxTilt(payloadDict['state']['max_tilt'])).wait() print('updated max_tilt') if 'flight_altitude' in payloadDict['state'].keys(): droneThing.flight_altitude = payloadDict['state']['flight_altitude'] print('updated flight_altitude') if 'detection_enabled' in payloadDict['state'].keys(): droneThing.detection_enabled = payloadDict['state'][ 'detection_enabled'] print('updated detection_enabled') if 'detection_mode' in payloadDict['state'].keys(): droneThing.detection_mode = payloadDict['state']['detection_mode'] print('updated detection_mode') if 'targeted_car' in payloadDict['state'].keys(): droneThing.targeted_car = payloadDict['state']['targeted_car'] droneThing.initBB = None droneThing.trackerInitialized = False print('updated targeted_car')