Reducing Latency in UDP Communications
3 次查看(过去 30 天)
显示 更早的评论
I am working on a project where we are flying a quadcopter with an onboard Raspberry Pi which communicates with a host PC. I am currently developing the communications between the two systems using UDP protocols. I am using two Simulink models, one on the PC and one built onto the Pi, that both use the Raspberry Pi UDP Send and Receive blocks. There is very little else in the models - just a clock to generate a signal to send back and forth, and byte pack and unpack blocks. While I have been able to successfully send information back and forth, the latency has been extremely high, ranging anywhere from 2-7 seconds. Obviously, this is not practical for real-time applications. This latency is approximately the same, independent of whether both computers are communicating over WiFi or connected to a router via Ethernet. In addition, ping times between the two systems are low (<5 ms), so I don't believe the hardware configuration to be a problem.
Would anyone be able to provide a few tips or pointers towards helping to reduce the messaging latency?
Thanks.
2 个评论
Walter Roberson
2015-8-13
Is the packet size variable? Did you specify the exact number of values expected for the packet?
Unfortunately I am having difficulty finding specific documentation on the Raspberry Pi UDP Receive block; I see it exists but the documentation basically says "Open the library and take a look"
回答(1 个)
Uladzimir
2015-8-14
Dear Michael, You should run your models in external mode. According to mathworks manual for real-time windows target, it provides efficiency up to 20 kHz. For this you need to set discrete fixed step solver, set up rtwin.tlc file in code generation options, then build model and run it in external mode. You could use Packet Input and Packet Output blocks, tuned as standard udp device. Our model worked with 1..3 ms delay.
5 个评论
Uladzimir
2015-8-18
I got your point. There is a lot to think about. What solver do you use? I used discrete, fixed-step. Also, you could try real-tyme sync block, it shows amount of missed ticks.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Run on Target Hardware 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!