Recent Changes - Search:

Menu

editer le Menu

HABLANv3-Raspbian

HABLAN - FLeYe

Software package for FLeYe v1


Creative Commons Attribution-ShareAlike 4.0 International License

Introduction

The aim of this project is to develop a system capable of remotely sense the downward hemisphere using multiple RGB cameras with variable resolution. The maximum resolution is a very high resolution of 1 meter when onboard stratospheric balloons (~30 km altitude). The cameras used are raspberry pi (RPI) HQ cams.

The linux distribution used for this system is Raspberry Pi OS (64-bit).

We chose a development philosophy based on a complete control from the Linux command line. The system can be controlled simply with a low speed remote connection provided by a SSH client installed on the user workstation. The RPI connected to the system act as a server. The images acquired by the FLeYe are stored on a web server installed on the RPI.

How to access the FLeYe

From internet:

ssh sand@RPI_ip

The standard username is sand. The system administrator should be able to provide you the password for sand.

Hardware requirements

We highly suggest to chose hardware components better or equivalent to this:

  • rapsberry pi 4b+ with 4 or 8 Gb of RAM
  • 256 Gb microsd card U30
  • 256 Gb usb3 stick

Storage

There are 27 MB of data stored on the microsd card for every shot. Which means that for each cycle of acquisition (4 images @ 2 integration times) for a given raspberry pi 27*4*2= 216 MB will be stored (8 images per cycle per RPI). On the 256 GB microsd card, there are about 222000 MB of free space. So that the microsd card can store about 1000 cycles. It takes at minimum 1.6 seconds to capture and save an image so that for the four cameras and two integration times (one cycle) it will require around 14 sec. We decided to acquire at a fixed rate. We chose 90 seconds per cycle which means 24 hours of shooting. The RPI will be in idle mode for about 40 sec after acquiring each cycle of 8 images.

Files are copied on the backup USB stick.

Integration time for night time lights detection

Assuming an analog gain of 16 (1600 ISO), the optimal integration time would be around 1/50s during night time. During day time the optimal integration time would be XXX sec. The system know the sunset and sunrise times so that it will automatically switch between the two modes.

Installing and configuring subsystems

Basic system installations and dependencies

  • Download and install the Raspberry Pi Imager (https://www.raspberrypi.org/software/) (v1.4 as for this guide)
  • Open the Pi Imager and choose the Raspbian OS 64 bit and your micro-SD card and push on "WRITE" button.
  • Connect the backup flash usb drive in a usb 3 port (blue one), the keyboard, the mouse and the micro HDMI cable to a screen.
  • Put the microSD card on the RPI and power it on (connect a USB-C cable charger with min 3 A.).
  • Set your country, time zone etc to whatever you want.
  • Skip the wifi config step
  • Update software
  • Restart the computer
  • Set the correct time, time zone and date
    • time zone have to be UTC
    sudo dpkg-reconfigure tzdata
    • Select None of the above
    • Select UTC
    • If required, set time and date (this should be required)
    sudo date -s '2017-02-03 01:35:55'
    • Adapt the date and time to your situation.
  • Open a terminal window
  • Install the following packages
sudo apt install vim
sudo apt install vim-common
sudo apt install apache2
sudo apt install lm-sensors
sudo apt install ntp
sudo apt install ntpdate
sudo apt install imagemagick
sudo apt install openssh-client
sudo apt install openssh-server
sudo apt install netpbm
sudo apt install git
sudo apt install python3-serial
sudo apt install python3-dev
sudo apt install python3-rpi.gpio
sudo apt install python3-gpiozero
sudo apt install bc
sudo apt install iptables
sudo apt install gparted
sudo apt install hdate
sudo apt install wondershaper
sudo apt install gpsd
sudo apt install gpsd-clients
sudo apt install ufw
sudo apt install -y python3-kms++ python3-libcamera
sudo apt install -y python3-pyqt5 python3-prctl libatlas-base-dev ffmpeg
sudo apt install -y python3-picamera2
sudo pip install matplotlib

Installing FLeYe applications

Latest available package release on github repository

  • To download FLeYe apps:
cd
mkdir git
cd git
git clone https://github.com/aubema/FLeYe.git
  • Copy apps to system directory:
sudo cp -f /home/sand/git/FLeYe/*.py /usr/local/bin/
sudo cp -f /home/sand/git/FLeYe/*.bash /usr/local/bin/
sudo chmod a+x /usr/local/bin/*
  • Copy local configuration files
cp -f /home/sand/git/FLeYe/FLeYe*config /home/sand
  • Create the data backup directory
mkdir /home/sand/data

Mount the usb stick on /home/sand/data

The usb stick will be the support to backup all the data.

  • Plug the usb stick in one of the RPI usb port. Type the following command:
sudo lsblk

You should see the usb drive on the sda1 drive

  • Edit fstab to mount the usb stick at /home/sand/data
sudo umount /dev/sda1
sudo su
echo "/dev/sda1 /home/sand/data vfat rw,user,exec,nofail,umask=000 0 0" >> /etc/fstab
exit
sudo reboot

Notes:

  • We assume that the file system on your usb stick is FAT. Please be sure to format the usb stick accordingly before the installation.
  • Be sure to replace /dev/sda1 with your actual device.

NTP -Network Time Protocole

  • disable ntp service on slaves
sudo systemctl disable ntp
  • Add the following in /etc/ntp.conf on slaves
server 172.20.4.160
  • Allow ntp request on the master
sudo ufw allow 123/udp
  • Add the following in /etc/ntp.conf on master
pool 0.debian.pool.ntp.org
server 127.127.1.0
fudge 127.127.1.0 stratum 10

Note: You may have to allow also ssh with ufw on the master after installing ufw.

On each RPI we will use ntpdate to sync the time at the beginning of the observe script. For the slaves we will use the IP of the master. For the master we will provide the IP of the ntp server of the gondola when onboard the CSA balloon. Otherwise, we will comment the nptdate line in observe_fleye.bash and set the time of the master manually once started using the command sudo date -s '2017-02-03 01:35:55' with the correct date. Another option is to connect a gps to the master and sync its time using that gps (see https://youtu.be/2oWLjl0dFkY).

SSH

SSH server allows any remote SSH client to connect to the server to remotely control system programs from the command line or to transfer (upstream / downstream) data.

  • We must first be sure that the SSH server start automatically when the RPI boots.
sudo raspi-config
  • Select 3 Interface Options
    • SSH
      • Yes (to enable ssh)
  • ok
  • Finish
  • Set up your personal firewall to allow the SSH and http connections to pass through the firewall.
sudo iptables -I INPUT 1 -p tcp --dport 22 -j ACCEPT
sudo iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT
sudo iptables-save

Allow ssh without password from slaves

On each slave run the command

ssh.keygen

without passphrase. Then copy the .ssh/id_rsa.pub in the file .ssh/authorized_keys on the master

Limit network bandwidth

  • Edit the file /etc/systemd/wondershaper.conf
sudo vim /etc/systemd/wondershaper.conf

Add the following to limit to 300 kbit/s

# Adapter

IFACE="eth0"

# Download rate in Kbps

DSPEED="300"

# Upload rate in Kbps

USPEED="300"
  • Implement the automatic startup of wondershaper
sudo vim /etc/systemd/system/wondershaper.service
  • Add the following content
[Unit]
Description=Bandwidth shaper/Network rate limiter
After=network-online.target
Wants=network.target

[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/systemd/wondershaper.conf
ExecStart=/usr/sbin/wondershaper $IFACE $DSPEED $USPEED
ExecStop=/usr/sbin/wondershaper clear $IFACE

[Install]
WantedBy=multi-user.target
  • Activate Wondershaper to run persistently
sudo systemctl enable --now wondershaper.service

Automatic startup of observation script

This is the master code that operates the image acquisition.

  • observe script
cd /home/sand/git/FLeYe
chmod a+x *
sudo cp observe.service /etc/systemd/system

Adapt the content of observe.service

sudo vim /etc/systemd/system/observe.service

In the file, replace this

/usr/local/bin/observe_fleye.bash

with

/usr/local/bin/observe_fleye_RPI_N.bash

Where N is the number of the RPI you are configuring.

Automatic startup

sudo systemctl enable observe.service
sudo systemctl start observe.service

Schedule the watchdog to the root crond schedule

This scripts check the disk usage of the /home/sand/data directory every 5 min. If nothing new happens in 5 minutes, it will reboot the system.

  • Edit crontab
sudo su
crontab -e
  • chose editor 2. /usr/bin/vim.basic
  • type < i > and add the following content:
*/10 * * * * /usr/local/bin/watch_activity.bash
  • Save and quit by typing: <escape> :wq

Apache server

We are using the Apache2 web server. This server allows browsing the database and look at the log file.

To activate the web server, we must:

  • activate userdir module
sudo a2enmod userdir
sudo service apache2 restart
  • Create the data directory and modify the permissions by doing:
sudo mkdir /var/www/html/data
sudo chmod a+rx /var/www/html/data
  • Edit the apache2 configuration file
sudo vim /etc/apache2/apache2.conf
  • Then type < i > to enter insert mode and add the following lines to the file
# added for FLeYe
<Directory /var/www/html/data>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Require all granted
</Directory>
  • Then exit and save by typing: <escape> :wq
  • Restart the webserver
sudo service apache2 restart

Configure the network parameters of the raspberry pi

  • Edit the file /etc/dhcpcd.conf
sudo vim /etc/dhcpcd.conf
  • Uncomment the section related to the static ip configurations but set ip address to 192.168.0.100 i.e.
# Example static IP configuration:
interface eth0
static ip_address=172.20.4.160/24
static ip6_address=fd51:42f8:caae:d92e::ff/64
static routers=172.20.4.254
static domain_name_servers=172.20.4.254 8.8.8.8 fd51:42f8:caae:d92e::1

Setting server names

sudo hostnamectl set-hostname your_name
  • Your name is either master, slave1 or slave2
  • Edit the file /etc/hosts
sudo vim /etc/hosts
  • Add the following lines
172.20.4.160 master
172.20.4.161 slave1
172.20.4.162 slave2
  • Note that 172.20.4.163 can be used for a laptop connecting to the FLeYe directly with an ethernet cable for debugging means.

GPS configuration

We are using the gps BN-220 that is supposed to work up to an altitude of 50 km. The TX and RX of the GPS module must be connected to the RX and TX of the RPI respectively.

sudo raspi-config
  • Interface options
    • Serial
  • Edit the gpsd configuration file
sudo vim /etc/default/gpsd
  • Set the following content
DEVICES="/dev/serial0"
GPSD_OPTIONS="-F /var/run/gpsd.sock -n"

BEFORE CSA FLIGHT: Disable wifi and bluetooth

In order to avoid interference with the Canadian Space Agency (CSA) communication systems, it is required to turn off the wifi and bluetooth services. If you are not flying with the CSA you may not need to do that step.

Edit the file /boot/config.txt

sudo vim /boot/config.txt

and add the following lines at the end of the file

dtoverlay=disable-wifi
dtoverlay=disable-bt

Save an quit by typing <escape> :wq

System reboot

Now all the relevant software are installed, in order to activate all newly added functionalities, restart the computer.

Edit - History - Print - Recent Changes - Search
Page last modified on September 11, 2023, at 10:40 pm UTC