< All Topics
Print

NEPI Engine – Building from Source-Code

Introduction

This tutorial will walk you through cloning, deploying, and building the NEPI Engine File System from source code.

What you will need:

1) 1x NEPI-enabled device with internet access. This tutorial uses an edge-compute processor box that includes an NVIDIA Jetson Xavier NX embedded GPU with NEPI Engine software installed.

NOTE: See available off-the-shelf NEPI enabled edge-compute options at: https://numurus.com/products-nepi-enabled-hardware/

2) 1x PC with internet access and configured to access the NEPI device’s File System.

NOTE: Instructions for configuration a PC and connecting to a NEPI device’s File System are provided in the NEPI Engine – Getting Started – Accessing the NEPI File System tutorial at: https://nepi.com/nepi-tutorials/

Cloning and Deploying the NEPI File System

Cloning the NEPI Source-Code

!!! This step should be done on your LINUX PC

a) Install Git on your Linux PC in not installed.

NOTE:  If you want to see the repo branch name shown in your terminal while working within a github repo, open a termainl on your PC and type the following to edit your PC’s bashrc file:

gedit ~/.bashrc

Then add the following lines to the end of the file.

parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="\u@\h \[\e[32m\]\w \[\e[91m\]\$(parse_git_branch)\[\e[00m\]$ "

Then save the file and refresh your terminal with the latest changes by typing:

source ~/.bashrc

b) Create a user account on github and configure your ssh credentials if not already done following these instructions:

Connecting to GitHub with SSH – GitHub Docs

c)  On your Linux PC with Git installed and ssh credentials configured and tested, open a terminal window and enter the following commands to clone the latest nepi_engine_ws and submodule source-code from the development branch: 

git clone git@github.com:nepi-engine/nepi_engine_ws.git
cd nepi_engine_ws
git checkout ros1_main
git submodule update --init --recursive

NOTE:  If you need the NEPI development branch, replace “ros1_main” with “ros1_develop” in the “git checkout” line below if you want to checkout the development branch.

NOTE:  If you need to edit any of the NEPI repo’s submodules, follow the instructions below.  Otherwise, jump to the “Deploying NEPI Source-Code to the Device” section below.

a) All of the NEPI source-code is organized into different submodule repos located in the nepi_engine_ws’s “src” folder. From the top level “nepi_engine_ws” folder type :

cd src

 Change directories to the submodule you want to work on and checkout the “ros1_main” branch for that repo by typing the following within the submodule folder:

cd <NAME OF SUBMODULE REPO FOLDER YOU WANT TO EDIT>

git checkout ros1_main

b) Make any changes to the source-code you want to make and save the changed files.

Updating NEPI Source-Code

!!! This step should be done on your LINUX PC

If you have already cloned the source-code and just want to update to the latest, follow these instructions

a) Open a terminal on your PC in the nepi_engine_ws top level project folder

b) Type the following:

git pull
git submodule update --init --recursive

Deploying NEPI Source-Code to the Device

!!! This step should be done on your LINUX PC

a) Update your Linux PC’s bashrc file.

The script relies on a collection of environment variables that must be set on your Linux PC. You can find an example set of environment variables and values in the sample_deploy_env_vars.sh script in the same directory, which you can copy and edit for your custom setup and source, or simply add valid definitions for these environment variables directly to your ~/.bashrc.

gedit ~/.bashrc

and add the following lines to the end with <YOUR_NEPI_SSH_KEY_PATH> changed to your key’s path:

# NEPI Engine Deployment Env. Variables
export NEPI_REMOTE_SETUP=1
export NEPI_TARGET_IP=192.168.179.103
export NEPI_TARGET_USERNAME=nepi
export NEPI_SSH_KEY=<YOUR_NEPI_SSH_KEY_PATH>
export NEPI_TARGET_SRC_DIR=/mnt/nepi_storage/nepi_src

Example:

# NEPI Engine Deployment Env. Variables
export NEPI_REMOTE_SETUP=1
export NEPI_TARGET_IP=192.168.179.103
export NEPI_TARGET_USERNAME=nepi
export NEPI_SSH_KEY=~/SSH_Keys/nepi_engine_default_private_ssh_key
export NEPI_TARGET_SRC_DIR=/mnt/nepi_storage/nepi_src

b) Deploy the source code to the NEPI device using the deploy_nepi_engine_source.sh script in nepi_engine_ws.

./deploy_nepi_engine_source.sh

c) If you have not done so yet, setup an NTP time server on  your PC to automatically sync the clock on your NEPI device following the instructions at:

https://nepi.com/nepi-tutorials/nepi-engine-configuring-ntp-time-syncing/

Building the NEPI Source Code on the Device

!!! This step should be done on your NEPI DEVICE

a) Add useful command line shortcuts to your NEPI Device

!!! THESE SHORTCUTS SHOULD ALREADY BE INSTALLED ON MOST PURCHASED NEPI DEVICES.  YOU CAN SKIP THIS SECTION IF WORKING WITH A PURCHASED NEPI SYSTEM.

Find the “nepi_device_bash_aliases”  and add them to your NEPI device’s bashrc file. From an SSH-connected terminal window type:

nano ~/.bashrc

Then copy the content of the “nepi_device_bash_aliases” file to the end of your devices bashrc file and save the file.

NOTE:  For NEPI pre-built images, the following aliases are pre-setup on the systems and located in a “.bash_aliases” file which is a symlink to
/opt/nepi/config/home/nepi/nepi_bash_aliases.  If needed, you can edit this file using the following command:

nano ~/.bash_aliases

a) Open an SSH terminal to your NEPI device and run the following commands:

rosstop

nepibld

rosstart

NOTE: The NEPI default sudo password is “nepi”

NOTE:  You can also start this process by manually running the “nepi_engine_build_complete.sh” script from the nepi_engine_ws folder on your NEPI devices nepi_storage/source folder.  This folder was created during the Deploy process in the previous section.  From the SSH connected NEPI terminal, type:

cd /mnt/nepi_storage/src/nepi_engine_ws

./nepi_engine_build_complete

NOTE:  If you run into issues building, you may need to delete any old deployed nepi deployments by typing the following and redeploying in the previous section:

sudo rm -r /mnt/nepi_storage/src/nepi_engine_ws

Testing File System Build

Open and refresh the NEPI RUI and test that the system and any expected updates are working

Debugging File System Changes

From your SSH terminal, you can use the bash aliases “rosstop” and “rosstart” listed above to not only stop and restart your NEPI ROS environment to apply any changes, but also see the NEPI ROS messages in real-time to identify any issues with the changes you made.

Updating Python Files with SFTP

While any cpp based file changes will require a full deploy/build to apply, since python files are not compiled, it is sometimes helpful to just replace them on the NEPI file system while debugging an python script. 

From a terminal window on your Linux PC opened in the source folder you want to update from, type:

sftpn

then navigate to the appropriate location on your NEPI device’s file system.  Most files are located in the following folders:

/opt/nepi/ros/etc/     -> CONTAIN NEPI CONFIG FILES

/opt/nepi/ros/lib/    -> CONTAIN NEPI SCRIPT FILES

/opt/nepi/ros/lib/python3/distro-packages/    -> CONTAIN NEPI SOURCE FILES

/opt/nepi/ros/share       -> CONTAINS NEPI ROS LAUNCH FILES

Once you are in the folder with the file(s) you want to update, just type:

put YOUR_FILENAME

NOTEON YOUR LINUX PC, you can add a new “sftpnl” function and file system shortcuts that allow you to sftp right into the appropriate folder following these instructions:

a) Add useful command line shortcuts to your Linux PC’s bashrc file

Find the “pc_device_bash_aliases”  and add them to your NEPI device’s bashrc file. From an SSH-connected terminal window type:

gedit ~/.bashrc

Then copy the content of the “nepi_device_bashrc_aliases” file to the end of the file.

Save and close the file.  Then type the following to resource your bashrc file:

source ~/.bashrc

b) Type sftpnl $FOLDER_SHORTCUT to open sftp to the specified folder shortcut

Example:

sftpnl $NEPI_LIB

then just use the “put” command as you would normally would replace files from your Linux source folder you ran sftpnl in to the NEPI file system’s file.

c) To test your changes, just open a new terminal on your LInux PC and type:

sshn

to create an SSH connection to the NEPI device, then:

rosstop

rosstart

to restart NEPI with your changes and see system messages real-time.

 

Table of Contents