Kubo: NUC - olinrobotics/gravl GitHub Wiki
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
- 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
- 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)
- Enter the same password as earlier
- Congrats! You are connected!
- Type
xterm
to get a terminal that is more useful - For a proper shutdown, type
sudo systemctl poweroff
.
Connecting to NUC ROScore
- 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
- 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
- Try _cd_ing into the .ssh folder in home
cd .ssh
- If you are able to skip to step 4, otherwise continue
- 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 |
| |
+-----------------+
- Run
ssh-copy-id [email protected]
- Input the password on the NUC
- 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 findboards.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 runmkdir ~/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
orsudo pip install pyserial
It may be useful to add
pyserial
to therequirements.txt
file
- TeensyDuino - Follow the instructions listed here:
https://www.pjrc.com/teensy/teensyduino.html
- Also make sure you copy the Teensy patch from GRAVL and the udev rules as noted here
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:
- Compile the arduino code:
make
- 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
.