Looking for how to share a variable out of the vision thread.
This might be really basic, but we’ve got the critical information being calculated within our vision pipeline and out putting to the variables tab. However we’re having a hard time exposing it to our driving code.
Also curious how this might differ if we are using the rPi for vision processing.
I figure it’s going to be relatively easy to get the Pi to execute the pipeline we create, but getting the result back to the rio may be a challenge.
Just flashed by rPi image this evening and I’m sick so trying to make something useful of this lost time…
Thanks for any help.
If you’re using the rPi for vision processing and you use the image that came with WPILib this year, you’ll be using NetworkTables to communicate with the RIO. Most of the work has been done for you, here, and there are example programs to help guide you: https://wpilib.screenstepslive.com/s/currentCS/m/85074
To communicate with a separate thread in your robot application, the easiest thing to do is pass messages into a queue that can be read from your robot application’s main loop. What’s nice about this approach is that only the access to the queue needs to be synchronized, rather than the access to the messages themselves. A natural place to do this is in the callback method that you pass into WPILib’s VisionRunner:
Agreed with Oblarg with network tables.
We’re running our vision output through a PID loop and sending the output to our drive, just like using your controller. Instead you use your vision output as your input to drive instead of a joystick input.
Does someone know what the fastest refresh rate NetworkTables has in 2019? When we used it during Stronghold we found that it only updated every 100 MS which affects real time tracking performance (the RIO runs at approximately 20 MS so every 5 frames we get data.) Has the refresh rate minimum changed this year to allow for 20 MS? Otherwise we are planning on using a custom UDP server to get the performance we desire.
That makes our lives much easier. Thanks!
The maximum refresh rate was changed to 100Hz (updates every 10 ms). The default rate is still 10Hz (updates every 100ms). You can change the update rate manually, or call NetworkTableInstance.flush()
to send data immediately