Kubo: NUC - olinrobotics/gravl GitHub Wiki

Intel NUC

Overview

Kubo's mid-brain computer is a NUC, a small form factor computer that is able to run ROS. The NUC currently contains Kubo's highest levels of autonomous functionality.

Connecting to the NUC

SSHing into NUC

  1. To ssh into the NUC, you first have to connect to the Tractor's Wifi network AGCO SCOPE. The password for this network is printed on a label the NUC. The NUC is set up with a static IP address of 192.168.1.2
  2. Then open a terminal and type ssh -Y [email protected]
  • The -Y command connects the X11 server from the NUC to your local computer. Practically, this allows programs on the NUC to pull up GUIs on your computer. (source)
  1. Enter the same password as earlier
  2. Congrats! You are connected!
  3. Type xterm to get a terminal that is more useful
  4. For a proper shutdown, type sudo systemctl poweroff.

Connecting to NUC ROScore

  1. To connect ros nodes on your computer to a roscore running on the NUC, you first have to start a roscore on the NUC. SSH into the NUC following the above instructions, then run roscore
  2. On your local device, open a new Terminal and run the following commands:
export ROS_MASTER_URI=http://192.168.1.2:11311
export ROS_IP=192.168.1.3

The first command points to the new ros master location, the second sets up the current static ros ip. 3. Run whatever nodes you want, you should be able to echo any topics running on the NUC.

Setting up SSH Keys

This eliminates the need to put in a password when connecting to the NUC

  1. Try _cd_ing into the .ssh folder in home cd .ssh
  2. If you are able to skip to step 4, otherwise continue
  3. Run ssh-keygen -t rsa
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/demo/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/demo/.ssh/id_rsa.
Your public key has been saved in /home/demo/.ssh/id_rsa.pub.
The key fingerprint is:
4a:dd:0a:c6:35:4e:3f:ed:27:38:8c:74:44:4d:93:67 demo@a
The key's randomart image is:
+--[ RSA 2048]----+
|          .oo.   |
|         .  o.E  |
|        + .  o   |
|     . = = .     |
|      = S = .    |
|     o + = +     |
|      . o + o .  |
|           . o   |
|                 |
+-----------------+
  1. Run ssh-copy-id [email protected]
  2. Input the password on the NUC
  3. Congrats! You have set up ssh keys on the NUC

Pushing code to the NUC

While code can be edited using vim over ssh, it is preferred to develop instead on a development laptop with software-in-loop testing before testing on hardware. To do this, the NUC will be set up as a secondary git server for the git repository.

Setting up the NUC git repository
mkdir /path/to/repo
cd /path/to/repo
# Replace the URL with the git repository that is being used
git clone [email protected]:olinrobotics/gravl .
git config --local receive.denyCurrentBranch updateInstead
Setting up development repository
mkdir /path/to/repo
cd /path/to/repo
git clone [email protected]:olinrobotics/gravl .
git remote add nuc [email protected]:/path/to/remote/repo
git push -u nuc master

After the first push, pushing can be done with git push nuc.

Note that it is important to not edit the code on the NUC directly once this is set up. If the code is edited upstream, the upstream repository will no longer accept new commits until the edits are reset.

Connecting the NUC to the internet

To get wifi on the NUC (for installations and updates), plug in the blue Ethernet cable into the yellow port on the router. The NUC will then be connected to Olin's Network. This will also allow your laptop to be connected to the internet if you are connected to the router.

Uploading code to the teensy from the NUC

Right now, the process for deploying code happens in two steps: pushing high level controller code to the NUC (SSH over wifi) and pushing low level controller code to the Teensy (through USB). To simplify the deployment process, there should only be one step that deploys the code to both places at once

Prerequisites:

  • Arduino IDE sudo apt-get install arduino Note: This installs arduino version 1.8.5 instead of 1.8.9 - we’re not sure if this works, so if you run into issues, install 1.8.9 from the website instead of this command

  • Arduino makefile (https://github.com/sudar/Arduino-Makefile) Don’t use sudo apt-get install arduino-mk, it installs an old version of arduino-mk that doesn’t find boards.txt. To install, use the following process:

    • cd ~/dev/ (this is specified by the ARDMK_DIR) (if you get an error “No such file or directory,” first run mkdir ~/dev)
    • git clone https://github.com/olinrobotics/Arduino-Makefile.git We forked it because originally we thought we would need to patch the searching for boards.txt issue, but that was just a problem with versioning. For now, we'll just keep the fork in case we want to make changes in the future
  • Pyserial sudo apt-get install python-serial or sudo pip install pyserial

It may be useful to add pyserial to the requirements.txt file

Setting the user library path

To make the makefile version agnostic, we need to set up a symlink to the arduino folder. Within the makefile, we refer to /opt/arduino/, but that location typically doesn't exist by default. To create the symlink, run sudo ln -s /opt/arduino-#.#.#/ /opt/arduino/

Uploading code

From the hind_brain/ directory:

  1. Compile the arduino code:
make
  1. Upload the arduino code:
make upload

Troubleshooting

Error 1: Unable to find Teensy Loader

Unable find Teensy Loader.  (r)  Is the Teensy Loader application running?
/home/kubo/dev/Arduino-Makefile/Arduino.mk:1736: recipe for target 'reset' failed
make[1]: *** [reset] Error 1
make[1]: Leaving directory '/home/kubo/catkin_ws/src/gravl/src/HindBrain'
/home/kubo/dev/Arduino-Makefile/Arduino.mk:1694: recipe for target 'upload' failed
make: *** [upload] Error 2

Library Setup

Roboclaw Library Setup

Download the Arduino Library and Examples from this website https://www.basicmicro.com/RoboClaw-2x30A-Motor-Controller_p_9.html

sudo mv RoboClaw /opt/arduino-#.#.#/libraries

ros_lib Setup

As noted in this page make sure you setup the ros_lib library in the correct location. Instructions are under the "Setting up Rosserial" heading.

Troubleshooting

If anything goes wrong with SSH, it is possible that openssh-server is not installed anymore for some reason. Connect the NUC to a monitor and keyboard, and sudo apt install openssh-server to install the server. To make it launch at startup, run sudo systemctl enable ssh.