Page 1 of 1

Issuing position change commands

Posted: Fri Sep 29, 2017 4:58 pm
by berenger81
Dear all,

this being my first post I would like to thank everyone for the valuable information in this forum!

That being said, I would like to first state my goals:

Setup: Crazyflie with flow deck

1. Detect the flie position using an external camera (opencv based, similar to your aruco detector) and send it to the flie.
2. Send positioning commands to the flie (x, y, z) using the python cflib and have it fly to the specified position.

Here is my current status:

For goal (1), I have written an application that detects the flie position and sends it using

Code: Select all[x, y, z])
I have set-up a log block to print the current estimator state and the ext_pos values and can confirm that the external positioning values sent by my application reach the flie and (somehow erratically) update the internal estimator state. Erratically in the following sense:
If I issue a hover setpoint with

Code: Select all, vy, yawrate, height)
the flie takes off, hovers in place and judging from the log information, the external position and the kalman state stay up-to-date.
Updating the external position while holding the flie in my hand shows that the external position is updated only once at the beginning and remains at that value (although it is being updated periodically), while the kalman estimator updates its state from the flow deck observing its movement.

For goal (2), if instead of using a hover setpoint, I send a position setpoint using

Code: Select all'flightmode.posSet', '1')
cf.commander.send_setpoint(y, x, yaw, int(z * 1000))   
That call seems to have no effect. That code is inspired by this example.

My concrete questions are:
a. Is it true that the external position (and the kalman estimator) only update when receiving external position information while in flight?
b. what is the correct sequence (and lib calls) to achieve goal (2), i,.e., takeoff and go to a set position

Any help will be greatly appreciated.


-- Sergio

Re: Issuing position change commands

Posted: Mon Oct 02, 2017 11:57 am
by arnaud

Thanks for the detailed question.

1. When you send an external position packet, the kalman filter (EKF) will be updated with it. When no external position is received the EKF will still use accelerometer and gyroscope to estimate a position. The EKF is running at 100Hz and so will calculate and output a position estimate 100 times per seconds.
2. The example you are followind is the good one. I do not think we have a proper position setpoint packet yet (like the velocity packet), so we are packing the position in the roll/pitch/yaw setpoint packet. One thing I have seen in my experiment is that the external position can make the EKF diverge and output NaN, in that case position control will not work. You can try to reset the EKF after starting to send position update, this way the EKF will converge to the external position. We do reset the EKF in the example you are linking: ... y#L99-L103.

As a side note, in my latest experiment with opencv and the ledring detector, I made an expos tab for the client that allows to send the position as ZMQ message to the client which then send an expos packet to a connected Crazyflie. This allows to experiment with position hold and to be able to log and display the position estimate more easily: ...

Re: Issuing position change commands

Posted: Thu Oct 05, 2017 8:03 pm
by berenger81
Thanks a lot for your answer! We haven't succeeded yet at getting the flies to accept positioning commands via the Python library, we tried resetting the estimator after sending positions, and we can confirm through logging blocks that the estimator is converging to a position different from NaN.

We'll surely try your suggestion of going the ZMQ way and will update this thread as soon as we gain some better insights. Thanks again for your presence in this forum, it's truly invaluable!

Curiosity questions (mostly off-topic):
- Does the EKF also update its position based on the flow deck values?
- In a flow deck equipped flie, does the position controller work by commanding linear velocities or by commanding roll/pitch/yaw/thrust as usual?

Re: Issuing position change commands

Posted: Mon Oct 16, 2017 12:46 pm
by arnaud
Hi, thanks and keep us updated of your progress.

About your questions:
- Yes, the flow readings are fed in the EKF and used for position estimation. Though if you have only the flow and no other mean of absolute positioning, you will have no good absolute position and the position output of the ekf is capped to +/- 10m.
- The EKF provides velocity, position and attitude estimates whatever sensors are connected (in case on only inertial sensor both velocity and position estimates will very quickly diverge though). So you can use attitude, velocity and even position setpoint with the flow deck. Though the position setpoint might not make so much sense since the absolute position is not known.