WPILIBPI runCamera set environment variable or System property or argument

We want to pass information to our WPILIBPI uploaded Java jar file at runtime. Environmental variables or system properties would be easiest or program arguments if need be.

The runCamera script is refreshed automatically and any user changes we make are wiped out. We’ve added environmental variables to systemd and profiles and that works for user logins but not the vision program system. How can we pass information to our vision program and retain all the features of uploaded jar file and automatic restart?

There’s a couple different ways to do this:

Option 1: Instead of using “Uploaded Java jar” as the application type, select “custom” and upload your .jar via the “File Upload” section. This will copy the file to the pi without overwriting the runCamera script. Then you can change the runCamera script to whatever you want; if you remove the ### TYPE: line from runCamera, the webserver will know it’s a custom script and leave it as “custom”.

Option 2: Edit /service/camera/run to run a different script than runCamera. This will allow you to completely bypass runCamera. The webserver will still overwrite runCamera but you can put your own custom script under a different filename.

Thanks. Perfect. Option 2 is so easy to use. This also allows changing the camera config file name from frc.json through the program’s first argument as the example shows. One could put more stuff in the frc.json file but that is a little latter in the process than we wanted.