Access robot's network tables using Electron (javascript)

Yo wassup guys,
I’m looking to create a desktop application that can interact with the robot network tables using Electron. I know how to do it with javascript, without Electron, using pynetworktables2js. Does anyone know of a way of integrating the two, or better yet, of a simple way to do this without pynetworktables2js? thx in advance.

2 Likes

This should be possible by running pynetworktables2js as a child of the JavaScript process using child_process.spawn.

1 Like

Using child_process.spawn is definitely the easier way to do this, assuming you setup the server script to listen on a known port. Then you may be able to just use the JS side in your Electron app as is.

Your other option would be to implement the NetworkTables protocol directly in Node.js and build some simple connectivity on top of that. Seems like quite a bit more work than using the above solution, but definitely possible given time.

1 Like

One thing to be aware of is there’s a new version of NT in the works for 2023 that uses WebSockets for transport. Details on the protocol can be found here. This will make it much easier to do client implementations without the need for pynetworktables2js.

3 Likes

This is exciting news. Is there JavaScript/TypeScript work to be done on implementations there that I could get involved in that you know of?

2 Likes

could you write out an example for how you’d do that, with child process spawn and pynetworktables2js?

If you want to go the full Python route, Beeware is a Electron-but-in-Python package I know of that would let you use the library for a desktop app.

1 Like

Something like this will start pynetworktables2js as a child process of your electron app. You can see more options and examples for child processes at nodejs.org

const { spawn } = require("node:child_process");
spawn('python3', ["-m", "pynetworktables2js"]);
1 Like

Back-in-the-day we (my group at work) created an electron app that included native libraries.

You could skip the python and do it that way with ntcore.

It’s sort of a packaging nightmare though with different platforms

1 Like

My team (2539) uses pynetworktables2js and electron for our current custom dashboard. See public/electron.js for how we use it. We do use networktables.js as well to connect to the local server via websockets.

FRC2539/Cougar-Dashboard: A custom FRC dashboard made by team 2539, Krypton Cougars! (github.com)

I don’t doubt that there are many potential improvements to our system, and that there will be changes forthcoming with the new NT system, but for now this is how we roll.

This is an unfinished WIP one I’m aware of.

This is another one.

And a third:

For NT3, this is what we use on the Romi:

1 Like

Hello to anyone who entered this thread to find the answer, I have discovered it. All you need to do is clone this repo https://github.com/FRCDashboard/FRCDashboard (FRCDashboard). And rewrite everything but the network tables stuff and it should work like a charm. Cheers.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.