Network Tables on Non-FRC project

Hello. We are currently dreaming up some ideas to work on this season, and one we decided to look into is a GUI that we can click on an area of the game field, and it will translate the x,y coords into trajectory commands and the robot will drive there. Pretty much a Path Planner that can be used in real-time.

I am struggling on finding a way to get the values to the robot. It was suggested to try to integrate network tables, but I am completely lost on how to setup Network tables on something that isn’t based entirely off of the wpi vscode.

I found some code snippets off of the wpi API docs but without a library to do so, not much I can do on that front. Unless I can use something else to network my way into the robot bypassing Network Tables entirely. I have been meaning to learn some networking with Java, so good place to start I suppose.

Take a look at GitHub - wpilibsuite/StandaloneAppSamples: App Samples for running apps standalone for how to integrate the WPILib implementation of NetworkTables into a standalone Java application.

1 Like

Thank you for the link. After going back through the Creating a Client-side Program docs I realize it actually links to there and that the build.gradle has all the libraries setup in it.

When I run the program it gives the following error message.

PS C:\Users\Joshua\Desktop\openCV Test Apps\NT-TEST\StandaloneAppSamples>  & 'C:\Users\Public\wpilib\2023\jdk\bin\java.exe' '@C:\Users\Joshua\AppData\Local\Temp\cp_f4piwsahk5ugj8k3ns129rih5.argfile' 'Program'
java.io.IOException: ntcorejni could not be loaded from path or an embedded resource.
        attempted to load for platform /windows/x86-64/
Last Load Error: 
no ntcorejni in java.library.path: C:\Users\Public\wpilib\2023\jdk\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Users\Public\wpilib\2023\jdk\bin;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files\Microsoft\jdk-11.0.12.7-hotspot\bin;C:\Program Files\Eclipse Adoptium\jdk-11.0.14.101-hotspot\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Program Files\dotnet\;C:\Program Files\Java\jdk-19\bin;C:\Program Files\GitHub CLI\;C:\Users\Joshua\AppData\Local\Programs\Python\Python311\Scripts\;C:\Users\Joshua\AppData\Local\Programs\Python\Python311\;C:\Users\Joshua\AppData\Local\Programs\Python\Python39\Scripts\;C:\Users\Joshua\AppData\Local\Programs\Python\Python39\;C:\Users\Joshua\AppData\Local\Microsoft\WindowsApps;C:\Users\Joshua\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Joshua\AppData\Roaming\npm;C:\Users\Joshua\AppData\Local\GitHubDesktop\bin;C:\Users\Joshua\.dotnet\tools;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2022.3\bin;;.
A common cause of this error is missing the C++ runtime.
Download the latest at https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads

        at edu.wpi.first.util.RuntimeLoader.loadLibrary(RuntimeLoader.java:93)
        at edu.wpi.first.networktables.NetworkTablesJNI.<clinit>(NetworkTablesJNI.java:36)
        at edu.wpi.first.networktables.NetworkTableInstance.create(NetworkTableInstance.java:125)
        at Program.<clinit>(Program.java:18)

I did the only thing I understood from this and updated my C++ Runtime, but to no avail.

IIRC (alas, recently a poor assumption) I had to be connected to the Internet for the first run to download the WPILib DLLs.

How are you running the program? ./gradlew run?

The run button in vscode very much does not work for this style of build. You either have to run from gradle directly, or run ./gradlew shadowJar and then you can run the created jar in build/libs directly.

1 Like

Ah that may be it. I’ve been using the run button this whole time.

How would i go about running it through gradle? And could I create what i belive is a bash file to automate the process for the drivers?

gradlew run

Building the shadowJar is likely preferable for the drivers. You don’t want it rebuilding the code each time.

When I try doing gradlew run from the terminal in vscode, it produces this error

PS C:\Users\Joshua\Desktop\openCV Test Apps\NT-TEST\StandaloneAppSamples> gradlew run
gradlew : The term 'gradlew' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path  
is correct and try again.
At line:1 char:1
+ gradlew run      
+ ~~~~~~~       
    + CategoryInfo          : ObjectNotFound: (gradlew:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

I am thinking that since I cloned the repo to get the base project, it hasn’t been configured for my system and that is why the path isn’t setup.

You’re in power shell. ./gradlew run (need the ./ in front) and you need to do that inside the java folder.

What does it mean to get into the Java folder? I am not familiar with command line stuff so I am not too sure what to do.
If it helps at all, it as a repo so that all the build files can be seen.

I tried to right click gradlew file and open in interactive terminal. It shows Java instead of powershell and when I ran the command it returned this.

PS C:\Users\Joshua\Documents\GitHub\MapChooser> ./gradlew run

> Task :run FAILED
java.io.IOException: ntcorejni could not be loaded from path or an embedded resource.
        attempted to load for platform /windows/x86-64/
Last Load Error: 
no ntcorejni in java.library.path: C:\Users\Public\wpilib\2023\jdk\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Users\Public\wpilib\2023\jdk\bin;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files\Microsoft\jdk-11.0.12.7-hotspot\bin;C:\Program Files\Eclipse Adoptium\jdk-11.0.14.101-hotspot\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Program Files\dotnet\;C:\Program Files\Java\jdk-19\bin;C:\Program Files\GitHub CLI\;C:\Users\Joshua\AppData\Local\Programs\Python\Python311\Scripts\;C:\Users\Joshua\AppData\Local\Programs\Python\Python311\;C:\Users\Joshua\AppData\Local\Programs\Python\Python39\Scripts\;C:\Users\Joshua\AppData\Local\Programs\Python\Python39\;C:\Users\Joshua\AppData\Local\Microsoft\WindowsApps;C:\Users\Joshua\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Joshua\AppData\Roaming\npm;C:\Users\Joshua\AppData\Local\GitHubDesktop\bin;C:\Users\Joshua\.dotnet\tools;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2022.3\bin;;.
A common cause of this error is missing the C++ runtime.
Download the latest at https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads

        at edu.wpi.first.util.RuntimeLoader.loadLibrary(RuntimeLoader.java:93)
        at edu.wpi.first.networktables.NetworkTablesJNI.<clinit>(NetworkTablesJNI.java:36)
        at edu.wpi.first.networktables.NetworkTableInstance.create(NetworkTableInstance.java:125)
        at Program.<clinit>(Program.java:18)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Process 'command 'C:\Users\Public\wpilib\2023\jdk\bin\java.exe'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
7 actionable tasks: 1 executed, 6 up-to-date

I see now that the PS at the start probably means it was still a PowerShell terminal.

Ah. In your main(), you need to move new Window() to below the CombinedRuntimeLoader function. That and the JNI functions need to run first before anything else In your code

After moving the new Window() and creating the table below Runtimeloader, it no longer gives errors when running. That is for when I just press the run button. Still not sure on the gradlew run part of things.

Thank you,

Now I gotta figure out how to setup a local network to send to the tables.

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