Page 1 of 1

Latency measurement between PC and Crazyflie

Posted: Thu Feb 11, 2021 3:24 pm
by Baoasi
Hi,
i want to send the control commanders from PC (roll,pitch,yaw and thrust) to Crazyflie, because of the long solution time of nmpc in PC. So is the latency measurement and compensation very necessary. I have seen that someone in forum have done this task, but still dont know how to make it. Can anyone give me some advices?

Thanks a lot in advance for any help :)
Baosai

Re: Latency measurement between PC and Crazyflie

Posted: Mon Feb 15, 2021 12:31 pm
by whoenig
We have added this in an experimental branch here: https://github.com/bitcraze/crazyflie-l ... y#L82-L113. The measured (roundtrip) latency is around 4ms on our systems, so for your control system you can expect about 2ms of latency.
The idea of the test is to send packets to the CRTP Echo port and measure the time between sending a packet and receiving its echo (roundtrip time). Note that there is a large variance in this latency, because packets can get dropped, scheduler variance (on the Crazyflie and PC side), etc.

Re: Latency measurement between PC and Crazyflie

Posted: Mon May 17, 2021 10:07 pm
by Baoasi
Thanks a lot for your help.
After testing, my latency is very high, I don't know which factors lead to the high latency. I use the virtual system, maybe it is the reason. Do you know what other reasons can als cause a high latency?

Here are my results:
15:3 ()
Latency for radio://0/80/2M/E7E7E7E7E7 (packet size 28 B): 40.20 ms
F15:3 ()
Latency for radio://0/80/2M/E7E7E7E7E7 (packet size 4 B): 40.38 ms
FF
======================================================================
FAIL: test_latency_radio_s28 (__main__.TestLink)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/wang/projects/crazyflie-lib-python/sys_test/single_cf_grounded/test_link.py", line 54, in test_latency_radio_s28
self.assertLess(result, 8)
AssertionError: 40.199995040893555 not less than 8

======================================================================
FAIL: test_latency_radio_s4 (__main__.TestLink)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/wang/projects/crazyflie-lib-python/sys_test/single_cf_grounded/test_link.py", line 50, in test_latency_radio_s4
self.assertLess(result, 8)
AssertionError: 40.37642478942871 not less than 8

======================================================================
FAIL: test_scan (__main__.TestLink)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/wang/projects/crazyflie-lib-python/sys_test/single_cf_grounded/test_link.py", line 43, in test_scan
self.assertEqual(len(uris), 2)
AssertionError: 3 != 2

----------------------------------------------------------------------
Ran 3 tests in 71.958s

FAILED (failures=3)

Re: Latency measurement between PC and Crazyflie

Posted: Tue May 18, 2021 9:22 am
by jonasdn
The VM will add some latency. I tried using the latest VM in GNOME Boxes (https://wiki.gnome.org/Apps/Boxes) and it made me fail the tests.

Locally on my machine I get 4.77 ms for test_latency_radio_s28 and 2.99 ms for test_latency_radio_s4.
On the VM I get 15.14 ms for s28 and 14.98 ms for s4.

Which software are you using to run the VM?

Regards
Jonas

Re: Latency measurement between PC and Crazyflie

Posted: Tue May 18, 2021 9:29 am
by jonasdn
I tested in Virtualbox as well and got around 25 ms latency for both tests.

Re: Latency measurement between PC and Crazyflie

Posted: Tue May 18, 2021 9:57 am
by Baoasi
thank you for your feedback!
I use Virtualbox, perhaps as you said, virtual machine cause more latency. I will try it with a new local machine and give a feedback after that.

Regards
Baosai

Re: Latency measurement between PC and Crazyflie

Posted: Tue Jun 15, 2021 1:49 pm
by bidenpriece
Thanks a lot for your help. today gold rate in hyderabad