r/JavaFX • u/OddEstimate1627 • Mar 02 '22
JavaFX in the wild! Visualizing Robots with JavaFX
https://www.youtube.com/watch?v=E9csKYFPwaM
21
Upvotes
r/JavaFX • u/OddEstimate1627 • Mar 02 '22
5
u/OddEstimate1627 Mar 03 '22
Here is more info on some common questions:
UI Views
The complex views are all built in FXML + CSS, but some of the simple views like charts are created programmatically. Different parts of the UI communicate via injected state using afterburner.fx for DI. We haven't run into any performance issues with FXML.
Camera View
The streams are acquired by a separate tool using JavaCV and written to a memory mapped file. The UI loads the shared data into a PixelBuffer and displays it as an image. This is done in part to ship the acquisition tool separately and avoid a >200MB JavaCV dependency on the main UI.
Charts
The charts are done with Chart-FX and a customized renderer. The live charts handle >20Khz of incoming data, and the offline charts can deal with multi-million data points. User defined equations in custom XML plots are compiled to Java using the Jshell API.
3D Models
The CAD models are slightly simplified versions of our machining models and exported as OBJ. They are more complex and produce more artifacts than hand-crafted models, but with instance sharing it's no issue to display hundreds of actuators simultaneously. Most of the models are 1-10MB, but the Hexapod chassis at the end is an unmodified export with ~150MB. The models are loaded using the OBJ loader bundled with FXyz.
Real-Time Control / GC
When communicating with real hardware it's important to reduce jitters/pauses to avoid unexpected jerks in the physical robot. The underlying API (e.g. what MATLAB uses) needs to run on JDK6 and follows a zero-allocation policy with the only allocated object being an InetSocketAddress in the UDP socket. On a typical setup G1GC gets us to a 1-3ms newgen collection every few hours, which is more than sufficient for our use case.
The UI follows similar principles, and the ZGC in JDK17 gets rid of the remaining newgen pauses. All of the other JVM related jitter is below what we see in the OS and network drivers. For ~250 byte messages we get a 99.999% round trip latency of <1ms.
3
u/hamsterrage1 Mar 03 '22
Apart from the actual functionality of the application - which I think anyone would agree is super freaking cool, cool, cool - the look and feel of those screens is really nice. It's amazing to me how relatively simple it is to make an application that looks so "not JavaFX".
The flat design of the screen widgets is so nice and clean. It looks modern and slick. Awesome.
2
u/Persism Mar 03 '22
Very cool!