FRC team 5584. Est. 2014

 

 

Follow Our Progress

Keep updated with the team by following our social media channels. For exciting highlights videos and robot reveals, be sure to subscribe to our YouTube channel!

Read more

 

Robocamps

Come and join us at one of our Robo Camp workshops! Held at three locations across the Eastern suburbs of Melbourne. Register on our website now!

Read more

 

Our Sponsors

The companies that support our team to run each season and are helping us promote a bright future for STEM in Australia. 

Read more

 

We plan to use the NVIDIA Jetson Nano Development Kit on our 2020 FRC Robot. This article serves as a point of reference for what we have learnt so far and is published here for the benefit of all teams.

 

REFERENCES

REF#01: official getting started page (see https://developer.nvidia.com/embedded/learn/get-started-jetson-nano-devkit)

REF#02: JETSON Nano review (see https://blog.hackster.io/getting-started-with-the-nvidia-jetson-nano-developer-kit-43aa7c298797)

REF#03: elinux page for jetson nano (see https://elinux.org/Jetson_Nano)

REF#04: microsd buying guide (see https://www.techspot.com/guides/1591-microsd-buying-guide/)

REF#05: what do sd card numbers mean? (see https://www.adorama.com/alc/7809/article/picking-right-sd-card-what-do-numbers-mean)

REF#06: MicroUSB supplier: JBHIFI - 128GB u3 samsung - sale price $39 (see https://www.jbhifi.com.au/samsung/samsung-evo-plus-128gb-microsd-card-sdxc-u3/466544/)

REF#07: 12v-5v 4Amp step down converter supplier - ebay (see https://www.ebay.com.au/itm/183373963115)

REF#08: alternative 12v-5v 10Amp step down converter supplier - andy mark (see https://www.andymark.com/products/power-converter-12-24vdc-to-5vdc)

REF#09: power considerations devtalk page (see https://devtalk.nvidia.com/default/topic/1048640/jetson-nano/power-supply-considerations-for-jetson-nano-developer-kit/)

REF#10: measured microsdcard speeds (see https://medium.com/@jithu83/nvidia-jetson-nano-storage-io-speeds-and-neural-networks-8c7b5bb0d7e9)

REF#11: wikipedia SD card page (see https://en.wikipedia.org/wiki/SD_card)

REF#12: EVO Select verses EVO Plus (see https://www.windowscentral.com/whats-difference-between-samsung-evo-select-and-evo-plus#targetText=Amazon%20has%20an%20exclusive%20on,the%20EVO%20Plus%20as%20well.)

REF#12: fastest memory cards on the market (see https://www.bhphotovideo.com/explora/computers/buying-guide/the-fastest-memory-cards-money-can-buy#targetText=Delkin%20Devices%20offers%20UHS%2DI,speeds%20of%2090%20MB%2Fs.)

REF#13: 5v 4A wall wart (see https://www.ebay.com.au/itm/5V-4A-For-Lenovo-Ideapad-100S-11IBY-80R2-Charger-Cable-AC-Adapter-Supply-Cord-CG-/273662266581?_trksid=p2385738.m4383.l4275.c10)

REF#14: Plastic DC barrel jack supplier (with 5.5mm OD / 2.1mm ID / 9.5mm length) (see https://www.jaycar.com.au/2-1mm-dc-power-line-connector/p/PP0510)

REF#15: Metal DC barrel jack supplier (with 5.5mm OD / 2.1mm ID / 9.5mm length) (see https://www.jaycar.com.au/2-1mm-dc-metal-line-plug/p/PP0531)

REF#16: NVIDIA SDK Manager (see https://developer.nvidia.com/nvidia-sdk-manager)

REF#17: JETSON Nano User Guide (see https://developer.download.nvidia.com/embedded/L4T/r32-2_Release_v1.0/Jetson_Nano_Developer_Kit_User_Guide.pdf)

REF#17: JETPACK Versions (see https://developer.nvidia.com/embedded/jetpack-archive)

 

WHICH SD CARD TO GET?

Samsung appear to be the vendor of choice, either EVO Select or EVO Plus (see REF#04 and REF#12).

The measured speeds in REF#10 are 84MB/sec - that is way over the U1 and U3 specs so I infer that a U3 is not wasted on a JETSON Nano - hence the purchase of 128GB U3 in REF#06.

 

WHAT ARE OUR POWER SUPPLY OPTIONS?

Lets go straight to the on robot solution ...

- 1x step down converter 12v-5v 4Amp (see REF#07 or REF#08)
- 1x "DC barrel jack .. with 5.5mm OD / 2.1mm ID / 9.5mm length, center pin positive" (for definition see REF#09)(for supply see REF#14/15)
- 2x Anderson Power pole connectors

... this would be wired into a 20Amp circuit on the PDP.

On the bench, there are several tested solutions (see REF#09) ... at the end of the day, any 5v 4A supply should cover all options! Lets try REF#13 and REF#14/15

 

WHAT IS THE LATEST SD CARD IMAGE VERSION THAT IS AVAILABLE?

1: Refer to https://developer.nvidia.com/embedded/downloads 

 

WHICH JETPACK VERSION IS BUNDLED IN THE SD CARD IMAGE?

1: Refer to https://developer.nvidia.com/embedded/downloads and https://developer.nvidia.com/embedded/jetpack-archive

2: There are multiple "Jetson Nano Developer Kit SD Card Image" links, they contain different Jetpack versions

3: Expand the link and hover over the "image" link to reveal the version of the "Jetson Nano Developer Kit SD Card Image"

4: At the time of writing these notes (26-Nov-2019) the following versions were available:

RELEASE DATE JETPACK VERSION SD CARD IMAGE NAME
2019/12/17 JP 4.3 jetson-nano-sd-card-image-r3231
2019/11/19 JP 4.2.3 jetson-nano-sd-card-image-r3223
2019/08/26 JP 4.2.2 jetson-nano-sd-card-image-r3221
2019/07/19 JP 4.2.1 jetson-nano-sd-card-image-r322
2019/06/07 JP 4.2 jetson-nano-dev-kit-sd-card-image

 

HOW DO I APPLY IMAGE TO SD CARD?

To prepare your microSD card, you’ll need a computer with Internet connection and the ability to read and write SD cards, either via a built-in SD card slot or adapter."

1: Download required files

(these notes based on: Use instructions at nvidia.com/JetsonNano (selected "Get Started"))

(versions applicable at 26-Nov-2019)

(a) Download the "Jetson Nano Developer Kit SD Card Image" via link, at the time of writing this provided a 5GB file: jetson-nano-sd-card-image-r3223.zip
(b) Expand "INSTRUCTIONS FOR WINDOWS" and select the "SD Memory Card Formatter for Windows" link, at the time of writing this provided a 6MB file: SDCardFormatterv5_WinEN.zip
(c) Select the "Etcher" link then "Download for Windows (x86|x64)", at the time of writing this provided a 120MB file: balenaEtcher-Portable-1.5.56.exe

2: Format the sdcard

NOTE: use "cancel" to close the "You need to format the disk ..." popups.

NOTE: we were logged in as local admin user

NOTE: we followed the website instructions to the letter for this section

(a) Insert sd card - we used 32 GB samsung EVO Plus UHS Class 3 (U3)
(b) Install, and launch SD Memory Card Formatter for Windows
(c) Select card drive
(d) Select “Quick format”
(e) Leave “Volume label” blank
(f) Click “Format” to start formatting, and “Yes” on the warning dialog

3: Write the nano image to the sdcard

NOTE: we were logged in as local admin user

NOTE: we watched this process to make sure PC did not sleep or hibernate

NOTE: we followed the website instructions to the letter for this section

(a) Install, and launch Etcher
(b) Click “Select image” and choose the zipped jetson nano image file downloaded earlier
(c) Insert your microSD card if not already inserted
(d) Click Cancel if Windows prompts you with a "You need to format the disk in drive ..." dialog as the sdcard has already been formatted
(e) Click “Select drive” and choose the correct device
(f) Click “Flash!” It will take Etcher about 10 minutes to write and validate the image if your microSD card is connected via USB3
(g) After Etcher finishes, Windows may let you know it doesn’t know how to read the SD Card. Just click Cancel
(h) Close etcher and "eject media" via task bar, remove the microSD card

NOTE: after completing the above steps we logged off and loged back in as normal user on windows host.

4: Connect up hardware

We followed the website instructions except . . .

* we added jumper at J48
* Connected calibrated bucky power supply displaying 5.0

When prompted on screen ...

* tick license agreement and select "Continue"
* select "English" then "Continue"
* select "English (US)" and "English (US)" then "Continue"
* select location on map (Melbourne) then select "Continue"
* set ...
name = Ubuntu
computer name = jetson-nano-1
username = ubuntu
password = ubuntu
... tick "Require my password to login" and select "Continue"
* Login with ubuntu/ubuntu

 

HOW DO I CONFIGURE THE NETWORK WITH A STATIC IP?

Select "System settings" icon then "Network"

Select the appropriate wired network then select "Options"

In IPV4 tab ...

* Select "Manual"
* Add an entry ip=10.55.84.8; netmask=255.255.255.0; gateway=10.55.84.1
* Set DNS=10.55.84.1

Select OK

NOTE: if you are wrestling with low res screen and the "OK" button is off screen, click in the network name field then "shift+tab" then "enter" :)

NOTE: if you are connected via ssh and using unity-control-center but are not seeing all the icons then refer to the "How do I change the network settings via a remote ssh connection?" instructions below

 

HOW DO I INSTALL CMAKE?

If you have internet connection from the nano then just use "sudo apt-get install cmake". Alternatively follow these notes to download and install the required packages manually:

(a) Manual package retrieval . . .

"apt list --installed" reveals that arm64 packages installed on nano

identified cmake package for 18.04 "Bionic" distribution by searching here

https://packages.ubuntu.com/

and click through to get version info from

https://packages.ubuntu.com/bionic/cmake

actually downloaded from:

https://launchpad.net/ubuntu/bionic/arm64/cmake/3.10.2-1ubuntu2

The following dependencies are reported so we need these too :(

cmake : Depends: cmake-data (= 3.10.2-1ubuntu2) but it is not installable
Depends: libcurl4 (>= 7.16.2) but it is not installable
Depends: libjsoncpp1 (>= 1.7.4) but it is not installable
Depends: librhash0 (>= 1.2.6) but it is not installable
Depends: libuv1 (>= 1.4.2) but it is not installable

Download links for these extra packages are ...

https://launchpad.net/ubuntu/bionic/arm64/cmake-data/3.10.2-1ubuntu2
https://launchpad.net/ubuntu/bionic/arm64/libcurl4/7.58.0-2ubuntu3.8
https://launchpad.net/ubuntu/bionic/arm64/libjsoncpp1/1.7.4-3
https://launchpad.net/ubuntu/bionic/arm64/librhash0/1.3.6-2
https://launchpad.net/ubuntu/bionic/arm64/libuv1/1.18.0-3

(b) Transport

Use scp, winscp or mobaxterm to transfer *.deb file(s) to the nano

(c) Installation

Install in one shot to resolve inter-dependencies:

sudo apt install /tmp/cmake_3.10.2-1ubuntu2_arm64.deb /tmp/cmake-data_3.10.2-1ubuntu2_all.deb /tmp/libcurl4_7.58.0-2ubuntu3.8_arm64.deb /tmp/libjsoncpp1_1.7.4-3_arm64.deb /tmp/librhash0_1.3.6-2_arm64.deb /tmp/libuv1_1.18.0-3_arm64.deb

(d) Verify installed

$ apt list --installed | grep cmake
cmake/now 3.10.2-1ubuntu2 arm64 [installed,local]
cmake-data/now 3.10.2-1ubuntu2 all [installed,local]

$ which cmake
/usr/bin/cmake

 

HOW DO I SET UP THE "MAT" OPENCV PROJECT?

(a) setup the project

$ mkdir ~/1-cv-mat
$ cd ~/1-cv-mat
$ vi CMakeLists.txt

Add the following content to CMakeLists.txt...

cmake_minimum_required (VERSION 2.8)
project(mat)
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(cv_mat mat.cpp)
target_link_libraries(cv_mat ${OpenCV_LIBS})

$ vi mat.cpp

Add the following content to mat.cpp ...

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

int main()
{

cv::Mat image0;

image0.create(480, 640, CV_8UC1);

image0.setTo(0);

cv::Point center(image0.cols/2, image0.rows/2);
int radius =image0.rows/2;

cv::circle(image0,
center,
radius,
128,
3);

// cv::Mat image1 = image0;
cv::Mat image1;
image0.copyTo(image1);

cv::rectangle(image1,
center - cv::Point(radius, radius),
center + cv::Point(radius, radius),
255,
3);

cv::Mat image2;
cv::cvtColor(image1, image2, CV_GRAY2BGR);

int inscribed_radius = radius/sqrt(2);

cv::Rect rect(
center - cv::Point(inscribed_radius, inscribed_radius),
center + cv::Point(inscribed_radius, inscribed_radius));

cv::Mat roi = image2(rect);

roi.setTo(cv::Scalar(0, 185, 118));

for ( int y=0; y < image1.rows; y++)
{
uchar *row = image1.ptr<uchar>(y);
for ( int x=0; x < image1.cols; x++)
{
if(row[x] == 128)
row[x] = x * y * 255 / image1.total();
}
}

for ( int y=0; y < image2.rows; y++)
{
cv::Vec3b *row = image2.ptr<cv::Vec3b>(y);
for ( int x=0; x < image2.cols; x++)
{
if(row[x][1] == 185)
row[x] = cv::Vec3b(0, x * y * 255 / image1.total(), 118);
}
}

cv::imshow("image2", image2);
cv::imshow("image1", image1);
cv::imshow("image0", image0);
cv::waitKey();

}

(b) Build it

$ mkdir ~/1-cv-mat/build
$ cd ~/1-cv-mat/build
$ cmake ..
$ make

(c) Run it

$ cd ~/1-cv-mat/build
$ ./cv-mat

(three image windows should turn up with generated content (circles and a square))

 

HOW DO I SET UP THE "BASIC" OPENCV PROJECT?

$ mkdir ~/3-cv-basic
$ cd ~/3-cv-basid
$ vi CMakeLists.txt

Add the following content to CMakeList.txt ...

cmake_minimum_required (VERSION 2.8)
project(basic)
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(cv_basic basic.cpp)
target_link_libraries(cv_basic ${OpenCV_LIBS})

$ vi basic.cpp

Add the following content to basic.cpp ...

#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

int main()
{

cv::Mat img = cv::imread("lena.jpg");

cv::Mat img_processed;
cv::resize(img, img_processed, cv::Size(img.cols / 2, img.rows / 2 ));

cv::Mat R = cv::getRotationMatrix2D(cv::Point2f(img.cols/2, img.rows/2), 45, 1);

cv::warpAffine(img, img_processed, R, img.size());

cv::Canny(img, img_processed, 200, 300);

for (int i = 1; i < 20; i+=2)
{
cv::Mat img_blurred;
cv::blur(img, img_blurred, cv::Size(i, i));
cv::Canny(img_blurred, img_processed, 100, 150);
cv::imshow("img", img);
cv::imshow("img_processed", img_processed);
cv::imshow("img_blurred", img_blurred);
cv::waitKey();
}

}

(b) Build it

$ mkdir ~/3-cv-basic/build
$ cd ~/1-cv-basic/build
$ cmake ..
$ make
$ cp /usr/share/visionworks/sources/data/lena.jpg .

(c) Run it

$ cd ~/1-cv-basic/build
$ ./cv-basic

(three image windows should turn up with processed content)

 

HOW DO I INTEGRATE THE WPILIB NETWORK TABLES CODE?

Tried building the 201-ic-pipeline project but it fails when encountering the 32-bit *.so files brought accross form the TK1)

(a) build the 64 bit ntcore library on the nano ...

1: Clone the allwpilib repo from https://github.com/wpilibsuite/allwpilib.git to your PC

2: Zip up the .git directory and transfer to nano

3: Unzip on nano in new ~/allwpilib.20200121.1500 directory

4: Make sure correct branch is checked out with "git checkout master" then "git checkout ."

5: Edit the CMakeList.txt file, change "OFF" to "ON" in the "option(WITHOUT_JAVA ..." line

6: mkdir build
cd build
cmake ..
make

(b) Modify the CMakeList.txt file in our ic_pipeline project ...

cmake_minimum_required (VERSION 2.8)
project(ic_pipeline)
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS} /home/ubuntu/allwpilib.20200121.1500/ntcore/src/main/native/include/ /home/ubuntu/allwpilib.20200121.1500/wpiutil/src/main/native/include/)
add_executable(ic_pipeline ic_pipeline.cpp GripPipeline.cpp)
target_link_libraries(ic_pipeline ${OpenCV_LIBS} /home/ubuntu/allwpilib.20200121.1500/build/lib/libntcore.so)
add_definitions(-Wall -std=c++17 -lstdc++ -lntcore -pthread)

... specifically we need to reference the appropriate allwpilib shared library files and headers. Notice the change from -std=c++11 to -std=c++17

 

HOW DO I INSTALL THE V4L2 UTILITIES?

Looks like this package name may have been reverted to "v4l-utils" but this package contains some v4l2 tools.

If you have internet connection from the nano then just use "sudo apt-get install v4l-utils". Alternatively follow these notes to download and install the required packages manually:

(a) Manual package retrieval . . .

"apt list --installed" reveals that arm64 packages installed on nano

identified v4l-ctl package for 18.04 "Bionic" distribution by searching here

https://launchpad.net/ubuntu/bionic/+search?text=v4l2

actually downloaded from:

https://launchpad.net/ubuntu/bionic/arm64/v4l-utils/1.14.2-1

The following dependencies are reported so we need these too :(

v4l-utils : Depends: libv4l2rds0 (= 1.14.2-1) but it is not installable

Download links for these extra packages are ...

https://launchpad.net/ubuntu/bionic/arm64/libv4l2rds0/1.14.2-1

(b) Transport

Use scp, winscp or mobaxterm to transfer *.deb file(s) to the nano

(c) Installation

Install in one shot to resolve inter-dependencies:

sudo apt install /tmp/v4l-utils_1.14.2-1_arm64.deb /tmp/libv4l2rds0_1.14.2-1_arm64.deb

(d) Verify installed

$ apt list --installed | grep v4l
libv4l-0/now 1.14.2-1 arm64 [installed,local]
libv4l2rds0/now 1.14.2-1 arm64 [installed,local]
libv4lconvert0/now 1.14.2-1 arm64 [installed,local]
v4l-utils/now 1.14.2-1 arm64 [installed,local]
$ which v4l2-ctl
/usr/bin/v4l2-ctl

 

HOW DO I SET THE DATE ON OUR JETSON NANO?

Run "sudo ~/set-date" - this will prompt you for year, month, day, hour and minutes, enter integers in all cases.

Script contents for the benefit of other teams:

#!/usr/bin/perl
#
# PURPOSE: script to manually set date on TK1
#
# USAGE:  sudo ~/set-date
#
my $id = `id`;
if( ! ( $id =~ /root/ ) )
  {
  print "ERROR: script needs to be run as root user - aborting!\n";
  exit 1;
  }
print "Enter all values as integers\n";
print "\nYear?\n";
my $year = ;
chomp( $year );
print "\nMonth?\n";
my $month = ;
chomp( $month );
print "\nDay?\n";
my $day = ;
chomp( $day );
print "\nHour?\n";
my $hour = ;
chomp( $hour );
print "\nMin?\n";
my $min = ;
chomp( $min );
`date --set="$year-$month-$day $hour:$min"`;
print "\nDate set to:\n";
print `date`;


HOW DO I CHANGE THE NETWORK SETTINGS VIA A REMOTE SSH CONNECTION?

Use "sudo ~/unity-control-center". Enter the manual network details as described in "How do I Configure the Network with a Static IP?" above.

Script contents for the benefit of other teams:

#!/usr/bin/perl
#
# PURPOSE: script to manually setup network on JETSON
#
# USAGE:  sudo ~/unity-control-center
#
`XDG_CURRENT_DESKTOP=Unity:Unity7:ubuntu unity-control-center network`;

 

HOW DO I BUILD OPENCV PACKAGE WITH CUDA SUPPORT?

(CREDIT: https://www.jetsonhacks.com/2019/11/22/opencv-4-cuda-on-jetson-nano/)

Note that NANO Jetpack versions do ship with an OpenCV build (3.4) but this is not compiled with CUDA support so there are no GPU versions of the OpenCV libraries. Sigh.

This means we have to build our own. This is a time consuming process which is desctribed in full here. We have also copied off the resulting packages so, if we do need to construct another SD card in a hurry this should save a bit of time! 

Login as ubuntu/ubuntu then . . .

$ cd
$ git clone https://github.com/JetsonHacksNano/buildOpenCV
$ cd buildOpenCV
$ vi buildOpenCV.sh
(change NUM_JOBS to 1 as recommended in the comments)
$ ./buildOpenCV.sh |& tee openCV_build.log
(enter password for sudo access when prompted)

Build took 4 hours using SDCARD, may want to investigate USB options if we have to do this regularly.

Packages created by this process...

~/opencv/build/OpenCV-4.1.1-dirty-aarch64.sh
~/opencv/build/OpenCV-4.1.1-dirty-aarch64.tar.gz
~/opencv/build/OpenCV-4.1.1-dirty-aarch64.tar.Z

Copied off these files for safe keeping in case we need to rebuild a new SDCARD in a hurry!

 

HOW DO I SETUP REMOTE BUILD CAPABILITY?

We need to be able collaborate on a common project with version control of our source code. The logical way to achieve this is to establish a project in the ICRobotics GIT repsitory and provide an automated mechanism for transporting and building code on the target JETSON. This has the massive benefit that our code will be stored in a common location  using common standard practives for source code version control, tagging and branching. This section describes the additional files that we have added to the 2020.Roley.Vision project to enable this capability.

NOTE: there are some additional steps for setting up individual user's environment - for further details refer to the instructions in the header comments of build.bat file below,

(a) create a build.bat script to be executed on the local PC

@ echo off
rem ############################################################################
rem #                                                                          #
rem # STEP 1: ON WINDOWS PC IN A BASH SHELL:                                   #
rem #                                                                          #
rem #   ssh-keygen                                                             #
rem #   (press "enter")                                                        #
rem #   (press "enter")                                                        #
rem #   (press "enter")                                                        #
rem #   scp ~/.ssh/id_rsa.pub This email address is being protected from spambots. You need JavaScript enabled to view it..8:/tmp                           #
rem #                                                                          #
rem # STEP 2: ON THE JETSON:                                                   #
rem #                                                                          #
rem #   cat /tmp/id_rsa.pub >> /home/ubuntu/.ssh/authorized_keys2              #
rem #   rf -rf /tmp/id_rsa.pub                                                 #
rem #                                                                          #
rem # STEP 3: ON WINDOWS PC:                                                   #
rem #                                                                          #
rem #    You can now build on the JETSON from the command line on your PC,     #
rem #    just open a command prompt and run build.bat, this will transfer      #
rem #    your local files to the JETSON and launch the build.sh script on the  #
rem #    JETSON. Note that you can also run build.bat from the terminal in     #
rem #    VSCODE.                                                               #
rem #                                                                          #
rem # TROUBLESHOOTING:                                                         #
rem #                                                                          #
rem #    If build.bat fails to connect to the JETSON and reports ...           #
rem #                                                                          #
rem #    "It is required that your private key files are NOT accessible        #
rem #    by others. This private key will be ignored."                         #
rem #                                                                          #
rem #    ... then you can resolve this from a command prompt as follows:       #
rem #                                                                          #
rem #    Icacls %USERPROFILE%\.ssh\id_rsa /c /t /Inheritance:d                 #
rem #                                                                          #
rem #    Icacls %USERPROFILE%\.ssh\id_rsa /c /t /Grant %UserName%:F            #
rem #                                                                          #
rem #    Icacls %USERPROFILE%\.ssh\id_rsa /c /t /Remove Administrator \        #
rem #      "Authenticated Users" BUILTIN\Administrators \                      #
rem #      BUILTIN Everyone System Users                                       #
rem #                                                                          #
rem #    You can verify that only your personal account is listed with ...     #
rem #                                                                          #
rem #    Icacls %USERPROFILE%\.ssh\id_rsa                                      #
rem #                                                                          #
rem ############################################################################
set PROJECTNAME=2020.Roley.Vision
set PROJECTWORKSPACE=~/Projects/%PROJECTNAME%
set PROJECTARCHIVE=%PROJECTNAME%.tar
set PROJECTACCOUNT=This email address is being protected from spambots. You need JavaScript enabled to view it..8
echo ---------------------------------------------------------------------------
echo INFO: constructing archive
tar -cvf ..\%PROJECTARCHIVE% *.txt *.sh *.h *.cpp
echo ---------------------------------------------------------------------------
echo INFO: transporting archive
scp ..\%PROJECTARCHIVE% %PROJECTACCOUNT%:/tmp
echo ---------------------------------------------------------------------------
echo INFO: removing local archive
del ..\%PROJECTARCHIVE%
echo ---------------------------------------------------------------------------
echo INFO: reseting remote workspace
ssh %PROJECTACCOUNT% rm -rf %PROJECTWORKSPACE%
ssh %PROJECTACCOUNT% mkdir -p %PROJECTWORKSPACE%
echo ---------------------------------------------------------------------------
echo INFO: extracting archive
ssh %PROJECTACCOUNT% cd %PROJECTWORKSPACE%; tar -xvf /tmp/%PROJECTARCHIVE%
echo ---------------------------------------------------------------------------
echo INFO: removing remote archive
ssh %PROJECTACCOUNT% rm -rf /tmp/%PROJECTARCHIVE%
echo ---------------------------------------------------------------------------
echo INFO: setting permissions in workspace
ssh %PROJECTACCOUNT% cd %PROJECTWORKSPACE%; chmod a+x *.sh
echo ---------------------------------------------------------------------------
echo INFO: building in remote workspace
ssh %PROJECTACCOUNT% cd %PROJECTWORKSPACE%; ./build.sh

(b) create a build.sh script to be executed remotely on the JETSON

#!/bin/bash
echo ---------------------------------------------------------------------------
echo INFO: purging derived objects
rm -rf ./build
echo ---------------------------------------------------------------------------
echo INFO: constructing build environment
mkdir build
cd build
cmake ..
echo ---------------------------------------------------------------------------
echo INFO: starting build
make
echo ---------------------------------------------------------------------------
echo INFO: copying in libraries not on library path
cp ~/allwpilib.20200121.1500/build/lib/lib* .
echo ---------------------------------------------------------------------------
echo INFO: exiting build environment
cd ..

(c) set up your SSH connecting - see header comments in the build.bat file

(d) set up .vscode/tasks.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
      {
        "label": "Remote build",
        "type": "shell",
        "command": "./build.bat",
        "windows": {
          "command": ".\\build.bat"
        },
        "group": "build",
        "presentation": {
          "reveal": "always",
          "panel": "dedicated"
        },
        "problemMatcher": []
      }
    ]
  }

(e) set up VSCODE key binding

Easiest done via VSCODE GUI. Select "File" > "Preferences" > "Keyboard Shortcuts" then select  the "Open Keyboard Shortcuts (JSON)" in the top right corner. Add a section for the "Remote build":task, for example ...

// Place your key bindings in this file to override the defaultsauto[]
[
    {
        "key": "shift+f6",
        "command": "wpilibcore.buildCode"
    },
    {
      "key": "shift+f1",
      "command": "workbench.action.tasks.runTask",
      "args": "Remote build"
    }
]

(f) test it using SHIFT+F1

 

HOW DO I FIX THE DATE / TIME DRIFT ON THE JETSON?

The date and time on the JETSON boards will drift and this will be compounded by the fact that it is an embedded device with infrequent access to the internet. Now that we have established a remote build capability (see previous section) we can take advantage of the fact that our programming PCs do have a much better grasp of the local time and transmit that into the JETSON whenever we set off a remote build. Two steps are required to achieve this:

(a) set up sudu for the build user (ubuntu) account so that no password is prompted for the /bin/date command - do this by adding the following line to the /etc/sudoers file . . .

ubuntu ALL=(ALL) NOPASSWD: /bin/date

(b) add the following lines to the build.bat file . .  .

set PROJECTDATE=%DATE:~6,4%%DATE:~3,2%%DATE:~0,2%
set PROJECTTIME=%TIME:~0,2%:%TIME:~3,2%:%TIME:~6,2%
set PROJECTDATE=%PROJECTDATE: =0%
set PROJECTTIME=%PROJECTTIME: =0%

echo ---------------------------------------------------------------------------
echo INFO: setting date in remote environment (%PROJECTDATE%)
ssh %PROJECTACCOUNT% cd %PROJECTWORKSPACE%; sudo date +%%Y%%m%%d -s "%PROJECTDATE%"

echo ---------------------------------------------------------------------------
echo INFO: setting time in remote environment (%PROJECTTIME%)
ssh %PROJECTACCOUNT% cd %PROJECTWORKSPACE%; sudo date +%%T -s "%PROJECTTIME%"

 

HOW DO I AVOID "VIDIOC_STREAMON: No space left on device" FAULTS WHEN USING MULTIPLE USB CAMERAS ON THE JETSON NANO?

There are two things that need to changes here:

(a) change your camera resolution so that you do not saturate the USB controller/bus, for example, in our ic_pipeline.cpp ...

cv::VideoCapture input("/dev/v4l/by-path/platform-70090000.xusb-usb-0:2.1:1.0-video-index0");
cv::VideoCapture input2("/dev/v4l/by-path/platform-70090000.xusb-usb-0:2.2:1.0-video-index0");
cv::VideoCapture input3("/dev/v4l/by-path/platform-70090000.xusb-usb-0:2.3:1.0-video-index0");
cv::VideoCapture input4("/dev/v4l/by-path/platform-70090000.xusb-usb-0:2.4:1.0-video-index0");
input.set(cv::CAP_PROP_FRAME_WIDTH, 320);
input.set(cv::CAP_PROP_FRAME_HEIGHT, 180);
input2.set(cv::CAP_PROP_FRAME_WIDTH, 320);
input2.set(cv::CAP_PROP_FRAME_HEIGHT, 180);
input3.set(cv::CAP_PROP_FRAME_WIDTH, 320);
input3.set(cv::CAP_PROP_FRAME_HEIGHT, 180);
input4.set(cv::CAP_PROP_FRAME_WIDTH, 320);
input4.set(cv::CAP_PROP_FRAME_HEIGHT, 180);

(b) configure the uvcvideo kernel module to ignore the bandwidth requested by the devices and instead calculate the required bandwidth

(CREDIT: http://renoirsrants.blogspot.com/2011/07/multiple-webcams-on-zoneminder.html)

To make this change temporarily:

sudo rmmod uvcvideo
sudo modprobe uvcvideo quirks=128

Or permanently:

sudo vi /etc/modprobe.d/uvcvideo.conf

And add the following line:

options uvcvideo quirks=128