Issuing position change commands

Discussions related to positioning systems where the position is calculated outside the Crazyflie and sent to the device using radio, including MoCap systems
Post Reply
berenger81
Beginner
Posts: 2
Joined: Thu Sep 21, 2017 12:57 pm

Issuing position change commands

Post 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

scf.cf.loc.send_extpos([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

 scf.cf.commander.send_hover_setpoint(vx, 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

scf.cf.param.set_value('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.

Thanks!

-- Sergio
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Issuing position change commands

Post by arnaud »

Hi,

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: https://github.com/bitcraze/crazyflie-l ... 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: https://github.com/ataffanel/crazyflie- ... tposTab.py
berenger81
Beginner
Posts: 2
Joined: Thu Sep 21, 2017 12:57 pm

Re: Issuing position change commands

Post 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?
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Issuing position change commands

Post 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.
Post Reply