Hi Arnaud,arnaud wrote:@pedro.lucas: Your messages kind of hijacked this thread so I have created a new thread to continue the discussion: viewtopic.php?f=6&t=2342.
@twh
I am currently looking at autonomous flight with a raspberry-pi camera V2 and opencv. I have that as a side-project and hopefully I can get something working soon .
First of all you need to push meters in the kalman filter. Choose an origin and calculate the position of the Crazyflie in regards to this origin, in meters. Once that is done you will be able to push X and Y in the kalman filter, one way is to use the existing external position port. If you only get X and Y (and not Z) you can modify the part of the firmware that gets position update to only push X and Y in the EKF: https://github.com/bitcraze/crazyflie-f ... #L894-L901.
For Z with the barometer, it is not enabled yet in the EKF. So you will have to enable and test the pressure sensor.
Actually it would be easier if you could have X,Y and Z from your webcams, with 2 camera it should be possible, this way you do not have to rely on the pressure sensor for height.
Once you have the state estimator (the kalman filter) fixed, the controller will 'just work' no need to care about it. You can fly in "position hold" using a recent firmware and a recent client, we have added position hold to the client and it is activated with the same button as alt-hold.
I have finally rewritten my code for autonomous maneuvering inside the firmware. The designs are as follows,
1. 1 USB camera: 30fps I set the resolution to 1280 by 720. The distance between the Crazyflie and the camera is around 1 meter, so the x-axis is 1.2m for 1280pixel and y-axis is 0.6m for 720pixel. and the actual meters are fed into the firmware. (is this range too small?)
2. The origin (0,0) is always where the Crazyflie is located at the beginning, moving left increases x, moving right decreases x and moving up increases y
3. to track the Crazyflie using a coloured ball and send its x-axis and y-axis values based on its view via zmq to the client.
4. The client treats the received values as the y-axis and z-axis of the Crazyflie and send this value via port 6 to the firmware. Whenever the data is available, it will receive it and send it to firmware. (less than milliseconds)
5. Kalman filter is enabled to process the position values.
6. The pre-defined set point replaces the commandersetpoint so that it will take off for 1 second and do hovering for 2 seconds.
7. the antenna (in-between M1 and M4) of the Crazyflie is facing the camera and do the 2-axis control.
I have tested it these few days and did a couple of experiments. However, it couldn't work as it always drift to one side.
I am not sure whether I positioned the Crazyflie correctly? (which part of the Crazyflie should face towards the camera, e.g. xyz of the Crazyflie)
I have also tried to let the Crazyflie's antenna (in-between M1 and M4) facing away the camera and this seemed working but I still don't get it.
How do I know the Kalman filter with camera inputs works as expected? (is it checking the log of attitude.roll and pitch?)
Do you have any references that implement the system? It seems like I lack of relevant knowledge and have no very good understanding of the Crazyflie, especially the control and stabilisation system.
Sorry for the long question...
Hope you could help me clarify my doubts.
Thank you very much