Set up raspberry pi - AvionCargo-UL/SkyAvionics GitHub Wiki
To run the application, use Raspberry Pi Os (64 bit)
with desktop. Make sure the SD card is new and formatted accordingly to the requirements (usually FAT32
).
This might take up to 20-45 minutes to do this action.
sudo apt-get update
sudo apt-get upgrade
Move to the Documents
directory:
cd /home/pi/Documents
Then clone from github
git clone https://github.com/AvionCargo-UL/SkyAvionics.git
Very important note : Normally librairies need to be installed with PEP668 standards, which involve using sudo apt install python-*pythonpackage*
. However, this implies that librairies need to be registered in the apt
server, which is not always the case with smaller independant librairies like pymavlink
. Since we can't go for virtual environnements because of picamera2 (see lower), we are constrained to use the global python installation. Hence, we need to use the --break-system-packages
argument. This is something to be very careful about later on in the future, as packages that change may cause the system to crash.
pip install -r requirements.txt --break-system-packages
pip install -r dev-requirements.txt --break-system-packages
Librairies should be
opencv-python==4.10.0.84
opencv-contrib-python==4.10.0.84
pyYAML==6.0.2
numpy==1.24.2
dronekit==2.9.2
pymavlink==2.4.41
pyserial==3.5
The most critical dependencies are with numpy
, opencv
, and picamera
. Please always use the latest stable version if you need to upgrade because of dependency errors. They will often come as en error message like
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject.
This seems to be very precarious, as all apt
dependencie are fragile and unstable. The whole system is built around the version installed with the os, and is the only version «certified» as stable.
For all the informations in details: https://datasheets.raspberrypi.com/camera/picamera2-manual.pdf
As of mid-September 2022, Picamera2 is pre-installed in all Raspberry Pi OS images. You can update it with a full system update, or via the terminal with:
sudo apt install -y python3-picamera2
Verify a camera is available
rpicam-hello
Use Tx/Rx and Ground on the RPI and on the serial device.
Execute sudo raspi-config
then go to interface options
Would you like a login shell to be accessible over serial? <no>
Would you like the serial port hardware to be enabled? <yes>
See the link to setup the RPI.
sudo nmcli device wifi hotspot ssid <hotspot name> password <hotspot password> ifname wlan0
Then get the UUID:
nmcli connection
sudo nmcli connection modify <hotspot UUID> connection.autoconnect yes connection.autoconnect-priority 100
To keep a stable version of python, we were using pyenv.
The instructions below are explained in detail here: https://github.com/pyenv/pyenv?tab=readme-ov-file#a-getting-pyenv
However, picamera2
is not meant to be installed on a virtual environnement for that purpous.
This is why this project does not use virtual environnements.
Always make sure python version is 3.11
.
This guide provides steps to enable and configure the watchdog on your Raspberry Pi to ensure the system can automatically restart if it becomes unresponsive.
-
Enable Watchdog in the Config File
- Open the Raspberry Pi configuration file to enable the watchdog:
sudo nano /boot/firmware/config.txt
- Add the following line:
dtparam=watchdog=on
- Open the Raspberry Pi configuration file to enable the watchdog:
-
Install the Watchdog Package
- Update your system and install the watchdog package:
sudo apt-get update sudo apt-get install watchdog
- Update your system and install the watchdog package:
-
Configure Watchdog Settings
- Edit the watchdog configuration file:
sudo nano /etc/watchdog.conf
- Modify the file with these settings:
watchdog-device = /dev/watchdog watchdog-timeout = 60 max-load-1 = 24
- Edit the watchdog configuration file:
-
Enable and Start Watchdog Service
- Enable the watchdog service to start on boot and start it immediately:
sudo systemctl enable watchdog sudo systemctl start watchdog
- Enable the watchdog service to start on boot and start it immediately:
-
Check Watchdog Status
- Verify that the watchdog service is running:
sudo systemctl status watchdog
- Verify that the watchdog service is running: