Hi. I recently got into the Olympe API and I’m trying to understand how it works by writing some programs, since I’m working with a Parrot drone for a project. However, I need to process a image taken with the drone but I can’t make it work in the simulation to try it later with the physical drone. I’ve tried several things but none of them worked, I always get AssertionError
when using the set_camera_mode
event. This is the latest code I’ve tried:
import olympe
import os
import time
from olympe.messages.ardrone3.Piloting import TakeOff, Landing, moveBy
from olympe.messages.ardrone3.PilotingState import FlyingStateChanged
from olympe.messages.camera import set_photo_mode, take_photo, photo_state, set_camera_mode, photo_progress, camera_mode
DRONE_IP = os.environ.get("DRONE_IP", "10.202.0.1")
def photoTest():
drone = olympe.Drone(DRONE_IP)
drone.connect()
assert drone(TakeOff()).wait().success()
assert drone(set_camera_mode(cam_id=0, value='photo'))
print('-------------------------------------------------')
print('Camera mode is ', drone.get_state(camera_mode)['mode'])
print('-------------------------------------------------')
assert drone(set_photo_mode(cam_id=0,
mode='single',
format='full_frame',
file_format='jpeg',
burst='burst_14_over_4s',
bracketing='preset_1ev',
capture_interval=0.0)
).wait()
if drone.get_state(photo_state()) == 'active':
print('Photo mode is active. Taking Photo.')
assert drone(take_photo(cam_id=0, _timeout=500)).wait()
else:
print('Error in photo. Status is: ', drone.get_state(photo_state))
assert drone(Landing()).wait().success()
drone.disconnect()
if __name__ == '__main__':
photoTest()
I’ve also tried adding >> FlyingStateChanged(state="hovering", _timeout=100)
thinking that the problem could be that the drone can only change the camera status when hovering but I get the same result. Changing the timeout to a huge number to prevent any delays, since the simulation really never works on real time, doesn’t work.