Menu |
Prof /
HABLANv3-RaspbianHABLAN - FLeYeSoftware package for FLeYe v1 Creative Commons Attribution-ShareAlike 4.0 International License IntroductionThe 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 FLeYeFrom internet: ssh sand@RPI_ip The standard username is sand. The system administrator should be able to provide you the password for sand. Hardware requirementsWe highly suggest to chose hardware components better or equivalent to this:
StorageThere 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 detectionAssuming 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 subsystemsBasic system installations and dependencies
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 applicationsLatest available package release on github repository
cd mkdir git cd git git clone https://github.com/aubema/FLeYe.git
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/*
cp -f /home/sand/git/FLeYe/FLeYe*config /home/sand
mkdir /home/sand/data Mount the usb stick on /home/sand/dataThe usb stick will be the support to backup all the data.
sudo lsblk You should see the usb drive on the sda1 drive
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:
NTP -Network Time Protocole
sudo systemctl disable ntp
server 172.20.4.160
sudo ufw allow 123/udp
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). SSHSSH 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.
sudo raspi-config
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 slavesOn 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
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"
sudo vim /etc/systemd/system/wondershaper.service
[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
sudo systemctl enable --now wondershaper.service Automatic startup of observation scriptThis is the master code that operates the image acquisition.
cd /home/sand/git/FLeYe chmod a+x * sudo cp observe.service /etc/systemd/system Adapt the content of observe.servicesudo 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 startupsudo systemctl enable observe.service sudo systemctl start observe.service Schedule the watchdog to the root crond scheduleThis 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.
sudo su crontab -e
*/10 * * * * /usr/local/bin/watch_activity.bash
exit Apache serverWe 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:
sudo a2enmod userdir sudo service apache2 restart
sudo mkdir /var/www/html/data sudo chmod a+rx /var/www/html/data
sudo vim /etc/apache2/apache2.conf
# added for FLeYe <Directory /var/www/html/data> Options Indexes FollowSymLinks MultiViews AllowOverride None Require all granted </Directory>
sudo service apache2 restart Configure the network parameters of the raspberry pi
sudo vim /etc/dhcpcd.conf
# 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 namessudo hostnamectl set-hostname your_name
sudo vim /etc/hosts
172.20.4.160 master 172.20.4.161 slave1 172.20.4.162 slave2
GPS configurationWe 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
sudo vim /etc/default/gpsd
DEVICES="/dev/serial0" GPSD_OPTIONS="-F /var/run/gpsd.sock -n" BEFORE CSA FLIGHT: Disable wifi and bluetoothIn 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 rebootNow all the relevant software are installed, in order to activate all newly added functionalities, restart the computer. |