Autonomous ANAFI Piloting Using OpenCV and ArUco

I am trying to control a Parrot ANAFI using a simple control algorithm. The goal is for the ANAFI to

1. Start a stream
2. Take off
3. Pan the gimbal downward
4. Identify an ArUco marker via image OpenCV library
5. Align itself to that marker using commands like PCMD() or moveBy()
6. Land

Each of these steps works until PCMD() or moveBy() is called. I know this is because these are blocking functions and so they interrupt the threads’ abilities to update global variables even if they are locked. Once the motion commands are called, the variables stop being updated and cannot be again. Below is the link to the repo containing the current iteration for the file. The file being used is a heavily edited version of the streaming example on the Olympe github. If anyone has advice, I would be greatly appreciative! The idea I had was more of a procedural while loop that employs a P-controller but it seems that will not work with the blocking commands I am using.

Here is an updated version:

If anyone could provide insight into how to use the PCMD piloting commands in the same kind of loop structure, it would be greatly appreciated.

Hi @levi.vandek,

Sorry for the delay. You can simply remove the .wait() of the self.drone(move.extended_move_by(…)) function. You can check the result of the moveby() with the expectation object returned by self.drone(move.extended_move_by(…)).

There is the documentation about the Olympe expectation objects and an example of an adanced Olympe expectation usage.

Regards.

Thank you for your recommendation! I have tried that in the past and the position and orientation of the drone does not change. The .wait() is required for creating any changes in the drone’s state. Do you know why this could be?

Hi @levi.vandek,

You need to manage the asynchronous expectation to move the drone. Take a look at the documentation about the Olympe expectation objects and an example of an adanced Olympe expectation usage.

Regards,
Axel

This topic was automatically closed after 30 days. New replies are no longer allowed.