Skip to content
dcyoung edited this page May 22, 2017 · 49 revisions

This page details how to install the software on a Raspberry Pi. We recommend you start from a pre-built image, but also highly recommend that you familiarize yourself with the code that comes pre-installed. You'll get a lot more out of the project that way.


Installing a Pre-Built image on a Raspberry Pi

Modifying a fresh raspberry pi to work with the sweep-3d-scanner code can be a lengthy process. Additionally, the sweep-3d-scanner code and its dependencies will evolve and improve rapidly. You can always ssh into the pi and update the scanner code to the latest revision, but this can be cumbersome.

As a convenient alternative, we provide pre-built downloadable raspbian images. These images include all of the modifications to the pi, pre-installed dependencies, pre-installed scanner code etc. All you have to do is flash the image to an SD card and you can experiment with the scanner.

  1. Remove the SD card from the raspberry pi. Be sure to properly shutdown before hand using sudo halt or sudo shutdown -h now
  2. Download the latest pre-built image and unzip it. You can download pre-built images for each release here.
  3. Download Etcher.
  4. Insert the SD card into your computer. You'll likely need an adapter.
  5. Open Etcher
  6. Select the downloaded image
  7. Select the inserted SD card
  8. Hit Flash
  9. When Etcher is finished flashing the SD card, eject and remove the SD card. Then insert it into the raspberry pi.
  10. (Optional, but strongly recommended) Expand the filesystem to fill the space on the SD card. Connect the pi to a keyboard+monitor and run sudo raspi-config, then select "Expand Filesystem". Alternatively you can do this directly from the command line with:
sudo raspi-config --expand-rootfs
sudo shutdown -r now

Note: To ssh into the pi after installing a pre-built image, use ip address 172.24.1.1, along with the default raspbian username pi and password raspberry. If you are using a non-windows OS, you can likely use the hostname pi-dev-raspbian instead of the IP address, but the IP address should work from any OS.

Note: While the pre-built images allow one to create a functional-scanner with limited setup, the project is still in development. There are a few dependencies and codebases that all come together to produce a working application. After flashing an image, we suggest you connect (ssh) to the pi and peruse the contents. The more you understand the processes involved, the easier it will be to troubleshoot issues and create lasting solutions.

Note: It is likely that the latest pre-built image is out of date with the latest sweep-3d-scanner code, bug fixes and features. If you don't want to wait for a new image, you can install the latest image, ssh into the rPi and update the sweep-3d-scanner code. See the later section on updating existing code.


Setting up Raspberry Pi from Scratch

Even if you are developing and modifying the code, it can be easier to start with the pre-built image. However, if you are really determined to set up the Pi from scratch, here are the general steps:

  1. Use Etcher to install the latest Raspbian image (Jessie-Lite) from https://www.raspberrypi.org/downloads/raspbian/ onto the Pi.

  2. Setup the Pi: Use a monitor and keyboard to access Raspi-config, and:

  • enable SSH Server
  • enable I2C
  • Disable the serial console

Plug the pi into Ethernet, then SSH into the Pi (using default Raspbian username + password) and update

sudo apt-get update && sudo apt-get upgrade
  1. Setup the Pi to host a wireless access point, by following this tutorial. After this step, you'll connect to the pi by connecting to it's wifi access point Pi3-AP using password raspberry. Once connected to the access point, you can ssh into the pi using ip address 172.24.1.1 and password raspberry.

  2. Install git, cmake and node

# install git
sudo apt-get install git
# install cmake
sudo apt-get install cmake
#install node 6.10.x
...
  1. Create the following directory /home/pi/code/scanse/:
mkdir -p /home/pi/code/scanse/
  1. Install sweep-sdk
cd /home/pi/code/scanse/
git clone https://github.com/scanse/sweep-sdk
cd sweep-sdk

# be sure to checkout the branch with a fix specific to the RaspberryPi
git checkout stop-scanning-buffer-fix

# install libsweep
cd libsweep
mkdir -p build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .
sudo cmake --build . --target install
sudo ldconfig
  1. Add pi user to dialout group (the sweep will not work without this change)
sudo adduser pi dialout
sudo reboot
  1. Install sweeppy
cd /home/pi/code/scanse/sweep-sdk/sweeppy
python setup.py install --user
  1. Install Adafruit libraries
# prep
sudo apt-get update
sudo apt-get install build-essential python-pip python-dev python-smbus git

# install Scanse fork (with fixes) of Adafruit's Python GPIO library
cd /home/pi/code/scanse/
git clone https://github.com/scanse/Adafruit_Python_GPIO
cd Adafruit_Python_GPIO
sudo python setup.py install

# install Scanse fork (with fixes) of Adafruit's Python MotorHat library
git clone https://github.com/scanse/Adafruit-Motor-HAT-Python-Library
cd Adafruit-Motor-HAT-Python-Library
sudo apt-get install python-dev
sudo python setup.py install
  1. Install numPy
sudo apt-get install python-numpy
  1. Install sweep-3d-scanner
cd /home/pi/code/scanse/
git clone https://github.com/scanse/sweep-3d-scanner
cd sweep-3d-scanner
npm install
  1. Run webserver on startup

Modify the /etc/rc.local file to launch the node webapp on start. Add the following line before exit 0

...
su pi -c 'node /home/pi/code/scanse/sweep-3d-scanner/app.js < /dev/null &'
exit 0

Updating Existing Code

To update the existing code on a pre-build image:

  1. Plug the Pi into an ethernet port.

  2. Connect to the rPi. This can be accomplished in different ways. Here are two options (we recommend the first):

  • Connect to the Pi3-AP wifi access point from another computer and ssh into the rPi. Use IP address 172.24.1.1, along with the default raspbian username pi and password raspberry. If you are using a non-windows OS, you can likely use the hostname pi-dev-raspbian instead of the IP address, but the IP address should work from any OS.
  • Plug a keyboard and computer monitor into the pi. After you see the boot sequence and finally the output from the node webserver process, go ahead and try typing. It will prompt you for a login by showing something like pi-dev-raspbian login: where "pi-dev-raspbian" is the hostname. It is asking for a login username. Type the default raspberry username pi, and it should prompt you for a password. Type the default raspbian password raspberry and you should have access to the command line.
  1. Update sweep-sdk
# retrieve latest version:
cd /home/pi/code/scanse/sweep-sdk
# Pull the latest from the branch with a fix specific to the RaspberryPi
git pull origin stop-scanning-buffer-fix

# uninstall existing libsweep installations:
sudo rm /usr/local/lib/libsweep*

# re-install updated libsweep:
cd libsweep
mkdir -p build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .
sudo cmake --build . --target install
sudo ldconfig
  1. Update sweeppy
# Uninstall existing `sweeppy` installation:
sudo rm /home/pi/.local/lib/python2.7/site-packages/sweeppy*

# Reinstall updated `sweeppy`:
cd /home/pi/code/scanse/sweep-sdk/sweeppy
python setup.py install --user
  1. Update sweep-3d-scanner
cd /home/pi/code/scanse/sweep-3d-scanner
git pull origin master
npm install
  1. reboot to relaunch webserver
sudo reboot