Paul Langdon
Published © CC BY-NC-SA

3D Printer AI: UP Squared/Movidius/OctoPrint to Catch Errors

Using the Movidius NCS on the UP Squared board to detect errors in a 3D print job and stop it with OctoPrint so it can be resumed.

AdvancedWork in progressOver 1 day1,799
3D Printer AI: UP Squared/Movidius/OctoPrint to Catch Errors

Things used in this project

Hardware components

UP 4000 Series
UP 4000 Series
×1

Software apps and online services

OctoPrint
Snappy Ubuntu Core
Snappy Ubuntu Core

Story

Read more

Code

Install Octoprint

Plain text
Update and upgrade your OS
1. sudo apt-get update
2. sudo apt-get upgrade

Create octoprint user and give it sudo permissions
3. sudo adduser octoprint
4. sudo usermod -a -G tty octoprint
5. sudo usermod -a -G dialout octoprint
6. sudo adduser octoprint sudo
7. sudo visudo

Scroll to the bottom of the document, and add the line at the bottom
octoprint ALL=(ALL) NOPASSWD:ALL

Ctrl + O to save, Ctrl + X to exit

Remove the password from the octoprint user
8. sudo passwd octoprint -d

Install the required support software to make this all work
9. sudo apt-get install git python-pip python-dev python-setuptools psmisc virtualenv

Switch to the octoprint user and confirm your identity
10.sudo su octoprint
11. whoami

Install PySerial V2.7
12. cd ~
13. wget https://pypi.python.org/packages/source/p/pyserial/ pyserial-2.7.tar.gz
14. tar -zxf pyserial-2.7.tar.gz
15. cd pyserial-2.7
16. sudo python setup.py install

Download and compile the latest version of OctoPrint

17. cd ~
18. git clone https://github.com/foosel/OctoPrint.git
19. cd OctoPrint
20. virtualenv venv
21. ./venv/bin/python setup.py install

Start OctoPrint for the first time
22. ~/OctoPrint/venv/bin/octoprint serve

With OctoPrint running, you should be able to access it using your local browser.

Open the page in your local browser by entering [youipaddress]:5000

Make OctoPrint run on startup
Stop running process (CTRL-C). Reboot UP Squared board

23. sudo cp ~/OctoPrint/scripts/octoprint.init /etc/init.d/octoprint
24. sudo chmod +x /etc/init.d/octoprint
25. sudo cp ~/OctoPrint/scripts/octoprint.default /etc/default/octoprint

26. sudo nano /etc/default/octoprint

Change the user to octoprint, and then edit the DAEMON line to remove the hashtag ad the beginning, and set the proper operating directory

DAEMON=/home/octoprint/OctoPrint/venv/bin/octoprint
OCTOPRINT_USER=octoprint

Ctrl + O to save, Ctrl + X to quit

Update the defaults
27. sudo update-rc.d octoprint defaults
28. sudo service octoprint start


Make everything accessible on port 80
29. sudo apt install haproxy
30. sudo nano /etc/haproxy/haproxy.cfg

Add this to the end of the file

frontend public
    bind :::80 v4v6
    use_backend webcam if { path_beg /webcam/ }
    default_backend octoprint

backend octoprint
    reqrep ^([^\ :]*)\ /(.*)  \1\ /\2
    option forwardfor
    server octoprint1 127.0.0.1:5000

backend webcam
    reqrep ^([^\ :]*)\ /webcam/(.*)  \1\ /\2
    server webcam1 127.0.0.1:8080


Ctrl + O to save, Ctrl + X to quit




Install Camera 

31. cd ~
32. sudo apt install subversion libjpeg62-dev imagemagick ffmpeg libv4l-dev cmake
33. git clone https://github.com/jacksonliam/mjpg-streamer.git
34. cd mjpg-streamer/mjpg-streamer-experimental
35. export LD_LIBRARY_PATH=.
36. make

This should hopefully run through without any compilation errors. You should then be able to start the webcam server using:

37. sudo ./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so"

Credits

Paul Langdon

Paul Langdon

49 projects • 317 followers
Working as a cloud architect for an IoT hardware company

Comments