Today I was trying to test the Latency in our system, and I set up a loopback test between the CRIO and our DS/Beaglebone. Using NetworkTables, I was seeing anywhere between 100-200ms of latency between sending and receiving. This seems really high. When I try pinging, it says it responds in less the 1ms, so its not the connection. Has anybody else tested this, or have any documentation on what the latency for NetworkTables is?
Also, I was trying to set up this test with UDP, but I could not get it to ever work. Has anybody else tried testing the latency of UDP, and if so how’d you actually get it to work.
So I got UDP working, and using the same algorithm, it was anywhere between 2-10 ms. I am surprised the difference is THAT large between raw UDP and NetworkTables. We were gonna use pynetworktables and OpenCV on a beaglebone black to try camera targeting, but we might have to replace networktables with udp if the difference is that big.
The values written in SmartDashboard are marked as dirty. Dirty elements are sent to the other subscribers based on a clock. The default value for this clock is 100ms in LV. I’m not sure what it is on other implementations. The LV implementation lets you specify the update time value when the client or server are started.
Why is it done this way?
Making every write send a message over the network wouldn’t work very well if/when someone writes to a SD variable a million times per second. So this amortization of updates is a pretty common approach for how you make a super fast thing link to a relatively slow thing, the last value is the most important, and you want to keep up to date.
The LV implementation also contains a VI called flush. This is there so that you can leave the update clock set to a relatively slow value, but when you have an image to process or something else that is timely, you can flush the update immediately after writing.
To tack onto what Greg said, chances are you aren’t going to require response times much faster than 100ms anyways – physical things can only move so fast. I don’t recall if the C++ implementation (which is what pynetworktables wraps) has a flush function or not, I don’t recall seeing it.
We used networktables to do automated targeting, and it worked out fine.