Modules techniques/Configuration Raspberry

Introduction

Voici la configuration qui a été faite sur le raspberry pi de chaque robot.

Changer le nom de la raspberry

sudo hostnamectl set-hostname Raspberry-robot1

Accèder à GitLab sans compte utilisateur

  • Preferences->Raspberry Pi Configuration->Localisation->Set Keyboard
  • Faire ssh-keygen puis appuyer sur entrée à chaque fois
  • Copier le fichier /home/pi/.ssh/id_rsa.pub sur Gitlab dans Settings->Repository->Deploy Keys
  • Puis cliquer sur Add key

Récuperer le code depuis GitLab

cd Desktop
git clone git@gitlab.com:polybot-grenoble/raspberry/raspberry-server.git

Installer les dépendances

sudo apt install libatlas-base-dev cmake libssl-dev
sudo python3 -m pip install opencv-python imutils
sudo python3 -m pip install opencv-contrib-python

Lancer le code au démarrage

  • Créer et modifier le fichier /etc/systemd/system/polybot.service
[Unit]
Description=Polybot Service
After=network.target
StartLimitInterval=0

[Service]
Type=simple
WorkingDirectory=/home/pi/Desktop/raspberry-server
ExecStart=/home/pi/Desktop/raspberry-server/main.py
Restart=on-failure
RestartSec=2

[Install]
WantedBy=multi-user.target
  • Executer ces commandes dans un terminal
sudo systemctl daemon-reload
sudo systemctl enable polybot.service
reboot
  • Après le reboot, systemctl status polybot.service doit afficher running en vert et sans message d'erreur si tout va bien.
  • Si il y a une erreur, on peut faire la commande journalctl -u polybot pour afficher des informations supplémentaires.

Activer SSH

sudo systemctl enable ssh
sudo systemctl start ssh

Pour mettre à jour le code

cd ~/Desktop/raspberry-server
git pull
reboot