This instructions will set your Raspberry Ready for My Little Factory, which uses popular resources, such as OpenCV and Flask.
We recommend you to use the Raspberry Pi Imager tool and flash the Raspbian OS Lite viersion (no desktop) to any SD Card with more than 16 Gb.
IMPORTANT: After flashing, mount the SD Card on your computer, open the boot volume and add an empty file named ssh. This will enable the SSH conections on the Raspberry Pi.
Load the card in the Raspberry Pi, connect it to a LAN (we recomend using an ethernet cable) and turn it on. Log into the Raspberry Pi through SSH:
In your own terminal type:
ssh pi@raspberrypi.localEnter the default password: raspberry.
Run the raspi-config tool as super user:
sudo raspi-configPerform the following changes (you may want to check the boxes):
- Update this tool
- Expand the System
- Change
hostnameto<your-favorite-mlp-character>. IMPORTANT: In this example we will userainbowdashas hostname - Change
passto anything secure AND that you can remember - Enable Camera
- Change TimeZone
Apply changes, reboot and log again through SSH.
Clone this repo and execute setup.shin the main folder
mkdir mlf
cd mlf
git clone https://github.com/Beauchef-Proyecta/mlf-raspi-setup.git setup
cd setup
chmod +x setup.sh
sudo sh setup.shRun the following lines
export WORKON_HOME=/home/pi/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source /usr/local/bin/virtualenvwrapper.sh
And then:
mkvirtualenv mlf -p python3.7Make sure the virtual environment mlf is activated (workon). Then, upgrade pip and install the packages specified in requirements.txt
pip install --upgrade pip
pip install -r requirements.txtFirst get <your-authtoken> from ngrok website. Use this to authenticate the ngrok agent that you'll download.
In your raspi terminal, write this to create tunnels automatically every time the Raspberry Pi is restarted!:
curl -O https://raw.githubusercontent.com/Beauchef-Proyecta/mlf-raspi-setup/main/install.sh
chmod +x install.sh
sudo ./install.sh <your-authtoken>Reboot to finish agent installation.
curl -LkO https://raw.githubusercontent.com/remoteit/installer/master/scripts/auto-install.sh
chmod +x ./auto-install.sh
sudo ./auto-install.shReboot the raspberry and log into the remot3.it wizard with the following command and follow the instructions to add services:
sudo connectd-installerRemember that ssh service must use the default 22 port and the server must use the 5000 port.
Now yout raspberry should be ready to run the Little Factory software. Here can find the source code :)
IMPORTANT This step-by-step instructions describe the exact same installation shown in previous sections.
First of all, update and upgrade apt, our package manager:
sudo apt update
sudo apt upgradeThe update part is fast; the upgrade part may take a while, so go grab some coffe if you want :)
Then, install these bad boys:
sudo apt install build-essential cmake pkg-config git python3-pip python3-dev screenSupport for image formats
sudo apt install -y libjpeg-dev libtiff5-dev libjasper-dev libpng-devIf it fails, add the --fix-missing flag:
sudo apt install -y --fix-missing libjpeg-dev libtiff5-dev libjasper-dev libpng-devSupport for most common video codecs
sudo apt install -y libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-devSupport for windows and graphical interfaces. This can take several mnitues.
sudo apt install -y libfontconfig1-dev libcairo2-dev libgdk-pixbuf2.0-dev libpango1.0-dev libgtk2.0-dev libgtk-3-devGood ol' matrices optimization and Fortran <3
sudo apt install -y libatlas-base-dev gfortranMore support for graphical user interfaces (Qt and HDF5)
sudo apt install -y libhdf5-dev libhdf5-serial-dev libhdf5-103 libqtgui4 libqtwebkit4 libqt4-test python3-pyqt5More stuff that I don't know does it do:
sudo apt install -y libilmbase-dev libopenexr-dev libgstreamer1.0-devWe will stay with Python 3.7 (the default 3.x version that comes with the OS). We now need one of the most important tools to mantain everything stable: virtual environments. This is accomplished by installing virtualenv and virtualenvwrapper:
sudo pip3 install virtualenv virtualenvwrapperNow we need to append some environment variables to our .bashrc file
echo "# virtualenv and virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source /usr/local/bin/virtualenvwrapper.sh " >> ~/.bashrcnow we source them!
source ~/.bashrcOn first run, virtualenvwrapper will create some folders
virtualenvwrapper.user_scripts creating /home/student/.virtualenvs/premkproject
virtualenvwrapper.user_scripts creating /home/student/.virtualenvs/postmkproject
virtualenvwrapper.user_scripts creating /home/student/.virtualenvs/initialize
virtualenvwrapper.user_scripts creating /home/student/.virtualenvs/premkvirtualenv
virtualenvwrapper.user_scripts creating /home/student/.virtualenvs/postmkvirtualenv
virtualenvwrapper.user_scripts creating /home/student/.virtualenvs/prermvirtualenv
virtualenvwrapper.user_scripts creating /home/student/.virtualenvs/postrmvirtualenv
virtualenvwrapper.user_scripts creating /home/student/.virtualenvs/predeactivate
virtualenvwrapper.user_scripts creating /home/student/.virtualenvs/postdeactivate
virtualenvwrapper.user_scripts creating /home/student/.virtualenvs/preactivate
virtualenvwrapper.user_scripts creating /home/student/.virtualenvs/postactivate
virtualenvwrapper.user_scripts creating /home/student/.virtualenvs/get_env_detailsNow we are ready to create our virtualenvironment:
mkvirtualenv mlf -p python3I everything is ok, our terminal shoul have (mlf) at the beginning of each line, which meand that the environment has been created and activated.
Make sure the mlf environment is activated. If not, you can type:
workon mlf(mlf) should append to the left of your terminal.
Upgrade pip with the folloing command:
pip install --upgrade pipNow install some dependencies with pip
pip install -r requirements.txtTo check that everything worked, open a python3 interpreter and import the packages:
python
>>> import cv2
>>> import flask
>>> import numpy
>>> import picamera