Packet loss while logging at high frequencies

Post Reply
Posts: 3
Joined: Wed Sep 05, 2018 6:49 am
Location: Stockholm/Eindhoven

Packet loss while logging at high frequencies

Post by maarten »

Hi everyone,

I am a student and for my internship I am trying to estimate the pose of a Crazyflie using Visual Inertial Odometry as one of the methods. Right now I am trying to increase the logging frequency of the Crazyflie 2.0 from the default 100Hz to a frequency of 1kHz. The reason for increasing this frequency is that I want to have as much IMU data as possible to supply to a VIO algorithm running on a separate PC. The estimate pose will then be send to the Crazyflie and used in its internal estimator. The camera signal will be sent over another receiver and there are no plans to incorporated in the Crazyflie. I am using the Crazyflie ROS package of Whoenig to receive and process the packets. The data is send over a connection with a data rate of 2MBps using the Crazyradio PA.

As discussed in a previous discussion this is quite easy to achieve. However, the packet loss at a sample rate of 1 ms in my setup is around 60% (see the figure below which displays the factor of packet received over packets send). The packet loss at a sample rate of 2 ms is around 20%. That the packet loss increase while logging at higher frequencies is not surprising, but for my application these numbers are far from ideal. So my question is, is there a way to decrease the packet loss at a sample rate of 1 or 2 ms?

While testing the packet losses I also discovered that for sample rate of 4 ms and above the average packet loss in my setup is around 5%. However, at a sample rate of 3 ms the packet loss is less then 1%. Is there an explanation for this low number of packet loss at 3 ms? And why is this not observed while sampling slower (especially 6 and 9 ms since they are multiples of 3 ms)?

Screenshot from 2018-09-05 09-26-41.png

Feel free to comment on anything regarding this project.

Thank you,

EDIT: I maybe should add that I'm only logging the IMU data, I have turned the logging of the temperature, barometer, etc. off.
Posts: 379
Joined: Mon Oct 27, 2014 2:55 am

Re: Packet loss while logging at high frequencies

Post by whoenig »

Hi Maarten,

I do not have a good explanation, but a few comments.
  • crazyflie_ros polls the data from USB, which is not ideal for streaming (as arnaud pointed out in the referenced forum thread). One thing you should check is how often it is actually able to call sendPing() here: ... #L552-L567. This should get up to ~ 1000 Hz, if you remove the sleep in there. The frequency gives you an upper bound on how many packets you might be able to receive, assuming the physical layer works perfectly well.
  • Depending on the outcome of the first experiment, you might want to send packets with unique (for example incrementing) numbers from the CF to identify "which" packets get lost. We found that for broadcasting there are sometimes long periods of consecutive packet losses due to interference with other 2.4 Ghz devices.
  • If your VIO algorithm supports delays, you might want to package multiple measurements into one CRTP packet. Such delay modeling will also allow you to deal with varying latencies (you can timestamp the on-board data with the usec timer before sending it out).
  • If you cannot compensate for delays, I recommend switching to crazyflie_cpp instead of crazyflie_ros, if your VIO algorithm allows that. The ROS1 pub/sub system does add additional non-deterministic delays. This also allows you to avoid any other overhead the ROS integration might come with.
Posts: 2475
Joined: Tue Feb 06, 2007 12:36 pm

Re: Packet loss while logging at high frequencies

Post by arnaud »

One added comment: By default Crazyflie 2.0 has bluetooth low energy enabled and this is stealing some time from the radio to send BLE advertisement, this is limiting the max bandwidth you can achieve. You can disable bluetooth by building the crazyflie2-nrf-firmware project with the flag BLE=0. Once you clone the project you can build and flash it with "make BLE=0 && make BLE=0 cload".
Post Reply