BigQuad deck and target tracking with an on-board camera

Post here to get support
Post Reply
M3DJ0
Beginner
Posts: 2
Joined: Thu Sep 12, 2019 6:46 pm

BigQuad deck and target tracking with an on-board camera

Post by M3DJ0 » Thu Sep 12, 2019 7:19 pm

Hi. I new to Crazyflie but a bit experienced with engineering and I am planning a project before I actually begin experimenting properly with the Crazyflie.

I am using the Crazyflie 2.1 board and BigQuad deck and I am planning on trying to implementing target tracking with an on-board camera. For the target tracking, I will be using OpenCV and a Raspberry Pi Zero with a Pi Camera mounted facing vertically downwards on a slightly larger quadcopter frame, motors, and battery. I am not using a Flow deck (since it is not compatible with the BigQuad deck without modifications) or any other sensors besides the on-board camera facing vertically downwards. The plan is for the quadcopter to maintain the same altitude directly above the target as the target moves on the ground (the target is a simple Arduino robot with wheels).

Using OpenCV, I realize I can calculate the approximate altitude of the quadcopter based on the size of the target (this doesn't actually have to be a specific altitude, but it just needs to be a constant altitude) and I can calculate the position of the quadcopter relative to the centroid of the target (X and Y coordinates with the target seen as the origin and is desired to be at the center of the video stream). Once I have these positional values from OpenCV, I was just wondering if it is possible for me to pass these values to the Crazyflie to keep the quadcopter at the same altitude and directly above the target? In other words (for the altitude), how do I tell the Crazyflie that it is currently Z meters above the ground so that I can still use the built-in hover functions for the Motion Commander class (or Commander class, but it seems that the Motion Commander class is easier to use)?

I am using the Python library by the way and I would prefer not to modify the actual firmware or hardware if possible. I hope I have been clear and I will gladly try to explain the situation better if I have been unclear. I basically want to know if there is a way for me to pass inputs for position to the Crazyflie so I can use the existing functions. I specifically need this for hovering to maintain a constant altitude without major fluctuations and if there are no existing functions I can use, I am a bit lost on how to maintain the altitude (if I can at least hover reliably, I could probably just move the quadcopter to change the X and Y coordinates with a basic controller based on the target location in the video stream).

Thank you very much for any help - it is greatly appreciated!



tobias
Bitcraze
Posts: 1891
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: BigQuad deck and target tracking with an on-board camera

Post by tobias » Mon Sep 16, 2019 12:26 pm

I can't think of a way to do this without modifying the firmware. It requires updating some files but not impossible to do. First of you should run the kalman filter. Then into this you can inject height measurement. See the zranger as an example. To get the values from the PC to the crazyflie use the location service. However there is no implementation for height only so you would have to implement that, similar to the extPosition which sets the full position. You should create a new typee in the generic type section which sets the height as the zranger does it. However it does not stop there, you will also have to update the python cflib with functions so you can push the height.

M3DJ0
Beginner
Posts: 2
Joined: Thu Sep 12, 2019 6:46 pm

Re: BigQuad deck and target tracking with an on-board camera

Post by M3DJ0 » Thu Sep 19, 2019 8:26 am

Thank you very much for the reply, Tobias.

If I am able to get the current the complete position of the quadcopter every few milliseconds from an external sensor (in this case it will be a camera, but that is not important), can I just pass the position with

Code: Select all

send_extpos(x, y, z)
and then use the Commander class to control the quadcopter - where a new setpoint is sent, the position is updated, a new setpoint is sent, the position is updated, and so on. (or the Motion Commander class but I don't know how this would work with the position commands which wait for the commands to finish executing before continuing so the position will not be updated - if I am understanding them correctly).

To also confirm, the position that I pass with

Code: Select all

send_extpos(x, y, z)
will not be override by a position measurement from one of the on-board sensors like the baraometer or something? (The function is from https://github.com/bitcraze/crazyflie-l ... /extpos.py by the way).

Thank you again for your time.

Post Reply