This is Team 1777's offseason vision processing code for Destination: Deep Space. The code is written in Java and is intended to be run on a Jetson Nano. This project is heavily integrated with Visual Studio Code for ease of use.
Some cool features:
- TCP server to send data to the RoboRIO
- Much lower latency than NetworkTables
- Runs in a separate thread to keep blocking calls from stalling the main processing
- Proper build/deploy system using Gradle (build.gradle)
- Builds a fat .jar file that contains the OpenCV .jar
- Deploys to a Jetson Nano at
tegra-ubuntu.local
over SSH, stopping and starting a custom service along the way
- Unit testing of the processing pipeline
- Ensures changes to the pipeline don't break the detection or cause significant inaccuracy
-
Install Java JDK 11.
a. Download and run the Java 11 JDK installer for your system. OpenJDK should also work for Linux users. (Note: in Java 11, the JRE is included in the JDK installer.)
b. Find where the installer put the JDK. There should be a folder called
jdk-11.X.X
inC:\Program Files\Java\
if you used the 64-bit installer, or inC:\Program Files (x86)\Java
if you used the 32-bit installer. Either way, remember what the exact name of the JDK folder is (e.g.jdk-11.0.3
).c. Open Control Panel and enter "System and Security" -> "System" -> "Advanced system settings". In the "Advanced" tab, click "Environment Variables..."
d. Click on "Path" in "System variables" and click "Edit..."
e. Click "New". In the new field, type
C:\Program Files\Java\<FOLDER_NAME_FROM_STEP_B>\bin
.f. Click "OK" to exit the Path editing window. Under "System variables", click "New...". Set the variable name to
JAVA_HOME
and the variable value toC:\Program Files\Java\<FOLDER_NAME_FROM_STEP_B>
. Click "OK" to save it. -
Install OpenCV 4.1.0.
a. If you don' want to deal with compiling from source, you can download the Windows installer instead. A custom build isn't necessary for this use case.
b. After the installer extracts, move the
opencv
folder to your user root folder (probablyC:\Users\<YOUR_USERNAME_HERE>
).c. Open Control Panel and enter "System and Security" -> "System" -> "Advanced system settings". In the "Advanced" tab, click "Environment Variables..."
d. Click on "Path" in "System variables" and click "Edit..."
e. Click "New". In the new field, type
C:\Users\<YOUR_USERNAME_HERE>\opencv\build\java\x64
. If you use a 32-bit install of Windows 10, replacex64
at the end withx86
.f. Restart your computer.
-
Install Visual Studio Code. You can actually use whatever Java IDE you want, but this project is already well integrated with Code.
a. Install the Java Extension Pack to make use of all of that nice IDE integration.
-
Install Bonjour Print Services for Windows. It isn't strictly necessary, but it'll make life a lot easier.
This assumes that you have already done the basic setup for your Nano. If you haven't follow NVIDIA's guide to get the bare minimum setup done and this other guide to get it ready to build stuff. It is strongly recommended to use an SD card with at least 32 GB of space; a 16 GB one is enough to install Ubuntu, but you won't have enough space to make a swap file or download the OpenCV source files.
-
Install OpenJDK 11:
sudo apt-get install openjdk-11-jdk openjdk-11-jre
-
Build and install OpenCV 4.1.0.
a. Download this script:
wget https://raw.githubusercontent.com/AastaNV/JEP/master/script/install_opencv4.0.0_Nano.sh
b. Edit the downloaded file and replace every
4.0.0
with4.1.0
.c. Make your Nano enter zoom-zoom mode:
sudo nvpmodel -m 0 && sudo jetson_clocks
. Don't do this if your power supply can't handle 10 W.d. Run the script:
./install_opencv4.0.0_Nano.sh
-
Put the important library somewhere that the JVM can find it:
sudo cp opencv-4.1.0/build/lib/libopencv-java410.so /usr/lib/
-
In build.gradle, change the info in
remotes.jetson
to match your Nano's hostname and user login. You will also need to modify the contents oftask deploy
to make the path correct for your system. -
In vision-code.service, change
WorkingDirectory
andExecStart
to use the correct path for your system.