-
Notifications
You must be signed in to change notification settings - Fork 49
Setup
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
- Connecting to Raspberry Pi
- Updating Existing Code
- Setting up Raspberry Pi from Scratch
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. It would be cumbersome to restart from scratch every-time you wanted to update the code.
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 expand the file system. Then you can experiment with the scanner!
- Remove the SD card from the raspberry pi. Be sure to properly shutdown beforehand using
sudo halt
orsudo shutdown -h now
- Download the latest pre-built image here. Note: The downloaded file is compressed, and you'll need to decompress (unzip) it before flashing the SD card.
- Download Etcher.
- Insert the SD card into your computer. You'll likely need an adapter.
- Open Etcher
- Select the decompressed (unzipped) image. Note: flashing the compressed image will not work.
- Select the inserted SD card
- Hit
Flash
- When Etcher is finished flashing the SD card, eject and remove the SD card. Then insert it into the raspberry pi.
- Expand the filesystem to fill the space on the SD card. First connect to the rPi (see Connecting to Raspberry Pi). Run the following commands directly from the command line:
sudo raspi-config --expand-rootfs
sudo reboot
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 thesweep-3d-scanner
code. See the later section on updating existing code.
The pre-built image automatically launches a node webserver process every time the rPi boots up. During normal use, you'll interface with the scanner application via a web-browser. See Using the Webapp for details.
But, in order to modify, develop and update code on the Pi, you'll have to connect to it directly. Once you have installed the pre-built image, 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 address172.24.1.1
, along with the default Raspbian usernamepi
and passwordraspberry
. If you are using a non-windows OS, you can likely use the hostnamesweep-3d-scanner
instead of the IP address, but the IP address should work from any OS. - Plug a keyboard and monitor into the pi. After the boot sequence finishes, you should be prompted for a login. The rPi will show something like
sweep-3d-scanner login:
where "sweep-3d-scanner" is the hostname. It is asking for a login username. Type the default Raspbian usernamepi
, and it should prompt you for a password. Type the default Raspbian passwordraspberry
and you should have access to the command line.
Note: Start by re-flashing the SD card with the latest release (pre-built image). You can check the releases page for new releases.
If you want to update code in between releases, it is possible to update the existing code on a pre-built image:
-
Plug the Pi into an ethernet port.
-
Connect to the rPi. See Connecting to Raspberry Pi for more details. We recommend you get familiar with sshing into the rPi.
-
Update
sweep-sdk
# start from the parent directory
cd /home/pi/code/scanse/
# delete the current sweep-sdk files
rm -rf sweep-sdk
# retrieve latest version:
git clone https://github.com/scanse/sweep-sdk
# uninstall existing libsweep installations:
sudo rm /usr/local/lib/libsweep*
# re-install updated libsweep:
cd sweep-sdk/libsweep
mkdir -p build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .
sudo cmake --build . --target install
sudo ldconfig
- 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
- Update
sweep-3d-scanner
# start from parent directory
cd /home/pi/code/scanse/
# remove existing sweep-3d-scanner files
rm -rf sweep-3d-scanner
# acquire updated sweep-3d-scanner files
git clone https://github.com/scanse/sweep-3d-scanner
# install dependencies
cd sweep-3d-scanner
npm install
- reboot to relaunch webserver
sudo reboot
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:
-
Use Etcher to install the latest Raspbian
Jessie Lite
image from here onto the Pi. -
Setup the Pi: Use a monitor and keyboard to access Raspi-config, and:
- Change the Host name to
sweep-3d-scanner
- Enable SSH Server (Interfacing Options -> SSH)
- Enable I2C (Interfacing Options -> I2C)
- Disable the login shell access over serial (Interfacing Options -> Serial)
- Enable the serial port hardware (Interfacing Options -> Serial)
Disable bluetooth on the main uart so the BNO055 IMU can communicate over serial. Use sudo nano /boot/config.txt
to add the following line to the bottom of /boot/config.txt
:
# Disable Bluetooth so BNO055 IMU can use the serial interface
dtoverlay=pi3-disable-bt
Plug the pi into Ethernet and update:
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get upgrade
- Install git, cmake and node
# install git
sudo apt-get install git
# install cmake
sudo apt-get install cmake
#install latest node
# see https://github.com/audstanley/NodeJs-Raspberry-Pi/
...
- Create the following directory
/home/pi/code/scanse/
:
mkdir -p /home/pi/code/scanse/
- Build and install
libsweep
library
cd /home/pi/code/scanse/
git clone https://github.com/scanse/sweep-sdk
# install libsweep
cd sweep-sdk/libsweep/
mkdir -p build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .
sudo cmake --build . --target install
sudo ldconfig
- Add
pi
user to dialout group (the sweep will NOT work without this change)
sudo adduser pi dialout
sudo reboot
- Build and test the
libsweep
examples
cd ~/code/scanse/sweep-sdk/libsweep/examples
mkdir -p build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .
# Test examples to make sure everything is working
./example-c /dev/ttyUSB0
./example-c++ /dev/ttyUSB0
- Install and test
sweeppy
sudo apt-get install python-setuptools
cd /home/pi/code/scanse/sweep-sdk/sweeppy
python setup.py install --user
- Install Adafruit libraries
# prep
sudo apt-get update
sudo apt-get install build-essential python-pip python-dev python-smbus git
# install Adafruit's Python GPIO library
cd /home/pi/code/scanse/
git clone https://github.com/adafruit/Adafruit_Python_GPIO
cd Adafruit_Python_GPIO
sudo python setup.py install
# install Scanse fork (with fixes) of Adafruit's Python MotorHat library
cd /home/pi/code/scanse/
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
# install Adafruit python library for BNO055 IMU
cd /home/pi/code/scanse/
git clone https://github.com/adafruit/Adafruit_Python_BNO055.git
cd Adafruit_Python_BNO055
sudo python setup.py install
- Install numPy
sudo apt-get install python-numpy
- Install
sweep-3d-scanner
cd /home/pi/code/scanse/
git clone https://github.com/scanse/sweep-3d-scanner
cd sweep-3d-scanner
npm install
-
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 passwordraspberry
. Once connected to the access point, you can ssh into the pi using ip address172.24.1.1
and passwordraspberry
. -
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 >& /home/pi/scanner_ouput.log &'
exit 0