Pi4 with Raspbian Bookworm: Difference between revisions

From Global Meteor Network
Jump to navigation Jump to search
 
(18 intermediate revisions by the same user not shown)
Line 1: Line 1:


This page explains how to set up RMS on a Pi with the 64-bit version of Bookworm.


== Burn an SD Card ==
== Burn an SD Card ==
Line 14: Line 15:


== Configure the Operating System ==
== Configure the Operating System ==
'''Note: all of the commands shown below must be run in a Terminal window or ssh session'''
* Login as the rms user you created above and run the following commands to install the system libraries required by RMS.  
* Login as the rms user you created above and run the following commands to install the system libraries required by RMS.  


  sudo apt-get install -y cmake git mplayer python3 python3-dev python3-tk python3-pip libblas-dev libatlas-base-dev liblapack-dev at-spi2-core libopencv-dev libffi-dev libssl-dev socat ntp libxml2-dev libxslt-dev imagemagick ffmpeg qt5-qmake python3-pyqt5 libqt5gstreamer-1.0-0 python3-pyqt5.qtmultimedia qtgstreamer-plugins-qt5 libqt5gstreamer-dev libqt5gstreamerui-1.0-0 libqt5gstreamerutils-1.0-0 python3-opencv libcairo2-dev
  sudo apt-get install -y cmake git mplayer python3 python3-dev python3-tk python3-pip libblas-dev libatlas-base-dev liblapack-dev at-spi2-core libopencv-dev libffi-dev libssl-dev socat ntp libxml2-dev libxslt-dev imagemagick ffmpeg qt5-qmake python3-pyqt5 libqt5gstreamer-1.0-0 python3-pyqt5.qtmultimedia qtgstreamer-plugins-qt5 libqt5gstreamer-dev libqt5gstreamerui-1.0-0 libqt5gstreamerutils-1.0-0 python3-opencv libcairo2-dev screen python3-virtualenv


  sudo apt-get install -y gobject-introspection libgirepository1.0-dev
  sudo apt-get install -y gobject-introspection libgirepository1.0-dev
Line 23: Line 27:


* now create a python environment for RMS and ensure its always active:
* now create a python environment for RMS and ensure its always active:
  python -m venv ~/vRMS
  virtualenv ~/vRMS
  echo source ~/vRMS/bin/activate >> ~/.bashrc
  echo source ~/vRMS/bin/activate >> ~/.bashrc
  echo cd ~/source/RMS >> ~/.bashrc
  echo cd ~/source/RMS >> ~/.bashrc
Line 34: Line 38:


== Install RMS ==
== Install RMS ==
* Login to the Pi again and download the code:
* Login to the Pi again and download the RMS application:
  mkdir ~/source
  mkdir ~/source
  cd ~/source
  cd ~/source
Line 47: Line 51:
  pip install -U pip setuptools
  pip install -U pip setuptools
  pip install -r requirements.txt
  pip install -r requirements.txt
pip install opencv-python


* Configure git so that the script can stash changes in the repo and update the code:
* Configure git so that the script can stash changes in the repo and update the code:
Line 52: Line 57:
  git config --global user.name "RMS"
  git config --global user.name "RMS"


* Ready the RMS software for use. This may take some time as the app is built and installed.  
* Ready the RMS software for use. This may take some time while the app is built and installed.  
  cd ~/source/RMS
  cd ~/source/RMS
  python setup.py install
  python setup.py install
Line 64: Line 69:
** Finally, find the ''device:'' line in the file and update it to contain your camera's IP address.  
** Finally, find the ''device:'' line in the file and update it to contain your camera's IP address.  


* Now run RMS for the first time. You will be asked to confirm a number of system settings. You don't need to expand the filesystem so you can skip over that step.
* Now run RMS for the first time using the command below. You will be asked to confirm a number of system settings. You don't need to expand the filesystem so you can skip over that step.
   ./Scripts/RMS_FirstRun.sh
   ./Scripts/RMS_FirstRun.sh


If you have no station-ID yet, request one with the instructions shown on screen and then abort the script by pressing the Ctrl-C key combination. Once you have your station ID, add it into the ''.config'' file and rerun this step.  
If you have no station-ID yet, request one with the instructions shown on screen and then abort the script by pressing the Ctrl-C key combination. Once you have your station ID, add it into the ''.config'' file and rerun this step.  


* Once you've finished the configuration steps, RMS will run an automated update and installation step. Eventually, you'll see a message that RMS is starting up. Let it start up to ensure there are no problems, then once its either waiting for night, or already capturing images, stop it by pressing Ctrl-C and letting the script run its tidy-up steps.  
* Once you've finished the configuration steps, RMS will run an automated update and installation step. Eventually, you'll see a message that RMS is starting up. Let it start up to ensure there are no problems, then once its either waiting for night, or already capturing images, stop it by pressing Ctrl-C and letting the script run its tidy-up steps.
 
== Autostart RMS ==
We want RMS to automatically start whenever the Pi is restarted. To do this edit we'll use the autostart feature of the Desktop.
 
First, create the required folder, then create the script that will auto-start RMS:
 
mkdir -p ~/.config/autostart
nano $HOME/.config/autostart/StartCapture.desktop
 
Now paste the following into the file
[Desktop Entry]
Name=Startcapture
Type=Application
Exec=lxterminal --title=RMS -e "~/source/RMS/Scripts/RMS_FirstRun.sh"
Hidden=false
NoDisplay=false
Icon=lxterminal
 
Save and exit the editor, then reboot the Pi and you should see the RMS script running.
 
== Stopping RMS ==
To stop RMS, click on the RMS window and press Control-C. RMS will shutdown gracefully which sometimes takes several minutes. If it hasn't shut down completely after about five minutes, press Control-C again or just kill the window. To restart RMS, just reboot the Pi.


== Job done ==
== Job done ==
Thats it, RMS should now be working. hopefully, during the configuraton steps above you sent your SSH key and location details to the network coordinator who will add your station to the GMN network, and you can now '''[https://globalmeteornetwork.org/wiki/index.php?title=Installing_a_camera_into_the_position install your camera outdoors]''', then wait for a clear night to '''[https://globalmeteornetwork.org/wiki/index.php?title=The_last_steps#Making_a_detection_mask make a mask and calibrate the field of view]'''.  
Thats it, RMS should now be working. hopefully, during the configuraton steps above you sent your SSH key and location details to the network coordinator who will add your station to the GMN network, and you can now '''[https://globalmeteornetwork.org/wiki/index.php?title=Installing_a_camera_into_the_position install your camera outdoors]''', then wait for a clear night to '''[https://globalmeteornetwork.org/wiki/index.php?title=The_last_steps#Making_a_detection_mask make a mask and calibrate the field of view]'''.  
== Installing CMN_BinViewer ==
Follow [https://globalmeteornetwork.org//wiki/index.php?title=Pi4_with_Raspbian_Bullseye#Installing_CMN_Binviewer these] instructions.


== Direct Camera connection ==
== Direct Camera connection ==
Line 86: Line 116:
  sudo nano /etc/dhcp/dhcpd.conf
  sudo nano /etc/dhcp/dhcpd.conf


and add this text at the bottom:
   subnet 192.168.42.0 netmask 255.255.255.0 {
   subnet 192.168.42.0 netmask 255.255.255.0 {
     authoritative;
     authoritative;
Line 100: Line 131:
This will assign a fixed IP address 192.168.42.10 to the camera.
This will assign a fixed IP address 192.168.42.10 to the camera.


* Edit the DCHP server configuration so it will only listen to the ethernet interface. Open the file:
* Edit the DCHP server configuration so it will only listen to the ethernet interface. Open the config file:
   sudo nano /etc/default/isc-dhcp-server
   sudo nano /etc/default/isc-dhcp-server


Line 106: Line 137:
   INTERFACESv4="eth0"
   INTERFACESv4="eth0"


* We need to add a fixed address for the Pi. Bookworm is using Networkmanager, so we must use that to configure the ethernet port:
* We also need to set a fixed address for the Pi. Bookworm is using Networkmanager, so we must use that to configure the ethernet port:
** First, check what the connections name is:
** First, check what the connection's name is. We're lookgin for the ethernet type:
  nmcli c
  nmcli c
   NAME                UUID                                  TYPE      DEVICE
   NAME                UUID                                  TYPE      DEVICE
Line 116: Line 147:


** Now, set the ethernet port to a fixed address:
** Now, set the ethernet port to a fixed address:
  sudo nmcli c mod "Wired connection 1" ipv4.addresses 192.168.42.1/32 ipv4.method manual
  sudo nmcli c mod "Wired connection 1" ipv4.addresses 192.168.42.1/24 ipv4.method manual


* We must also add a route to ethernet port. Do do this edit ''rc.local''
* We must also add a route to ethernet port. Do do this edit ''rc.local''
Line 139: Line 170:
   sudo systemctl enable isc-dhcp-server
   sudo systemctl enable isc-dhcp-server


* test Plug the camera into the Pi’s ethernet interface, and check that a fixed IP address of 192.168.42.10 is set on the camera.
* Now plug the camera into the Pi’s ethernet interface, and reboot to test the configuration:
Then reboot to test the configuration:
   sudo reboot
   sudo reboot


* To check, run the following:
* To check, run the following commands:
  ping -c 1 192.168.42.10
  ping -c 1 192.168.42.10
  arp -a
  arp -a
The first should return some times, and the second should show the camera in a list of conections:
The first should return a trip-time, and the second should show the camera's IP address in a list of conections:
  ? (192.168.42.10) at 00:12:16:b6:79:db [ether] on eth0
  ? (192.168.42.10) at 00:12:16:b6:79:db [ether] on eth0


Line 153: Line 183:


The service should be active.
The service should be active.
'''Note that if you unplug the ethernet cable, you will need to reboot to regain camera connection.'''
'''Note that if you unplug the ethernet cable, you will need to reboot to regain camera connection.'''
(more to come)

Latest revision as of 11:49, 22 September 2024

This page explains how to set up RMS on a Pi with the 64-bit version of Bookworm.

Burn an SD Card

  • Download the Raspberry Pi Imager from https://www.raspberrypi.com/software/
  • Run the tool, select your model of Pi, then select Bookworm 64-bit.
  • Select your SD card and click Next and then Edit Settings. Make the following changes:
    • If you know your station ID set the Hostname to match it but in lower case. For example if your station is UK1234 set the hostname to uk1234
    • otherwise set the hostname to be something you'll remember
    • Set the username to rms and enter a password of your choice. Remember this!
    • Add your Wifi network details
    • Set the locale to UTC and the keyboard layout to match your keyboard.
    • save settings, and on the next screen click Yes and then Yes again
  • Once the image has been burned, insert the SD card into your Pi power it on. The Pi will reboot a few times as it sets things up.

Configure the Operating System

Note: all of the commands shown below must be run in a Terminal window or ssh session

  • Login as the rms user you created above and run the following commands to install the system libraries required by RMS.
sudo apt-get install -y cmake git mplayer python3 python3-dev python3-tk python3-pip libblas-dev libatlas-base-dev liblapack-dev at-spi2-core libopencv-dev libffi-dev libssl-dev socat ntp libxml2-dev libxslt-dev imagemagick ffmpeg qt5-qmake python3-pyqt5 libqt5gstreamer-1.0-0 python3-pyqt5.qtmultimedia qtgstreamer-plugins-qt5 libqt5gstreamer-dev libqt5gstreamerui-1.0-0 libqt5gstreamerutils-1.0-0 python3-opencv libcairo2-dev screen python3-virtualenv
sudo apt-get install -y gobject-introspection libgirepository1.0-dev
sudo apt-get install -y gstreamer1.0-libav gstreamer1.0-plugins-bad
sudo apt-get install -y chrony
  • now create a python environment for RMS and ensure its always active:
virtualenv ~/vRMS
echo source ~/vRMS/bin/activate >> ~/.bashrc
echo cd ~/source/RMS >> ~/.bashrc

We recommend at this point you should reboot the pi, to pick up all the changes you've just made.

sudo reboot

Connect a Camera

Out-of-the box, RMS on Bookworm can connect to any camera attached to your network. This is the simplest way. If you prefer to connect the camera directly to the Pi, jump ahead to this section. If you're happy using a connection via your router, plug the camera in and find its IP address as explained here.

Install RMS

  • Login to the Pi again and download the RMS application:
mkdir ~/source
cd ~/source
git clone https://github.com/CroatianMeteorNetwork/RMS.git
  • Activate the python environment, if not already active. The prompt will change to (vRMS) rms@yourhostname: if its active.
source ~/vRMS/bin/activate


  • Now, set up Python in the environment we just created:
cd ~/source/RMS
pip install -U pip setuptools
pip install -r requirements.txt
pip install opencv-python
  • Configure git so that the script can stash changes in the repo and update the code:
git config --global user.email "rms@gmn.uwo.ca"
git config --global user.name "RMS"
  • Ready the RMS software for use. This may take some time while the app is built and installed.
cd ~/source/RMS
python setup.py install
./Scripts/GenerateDesktopLinks.sh

Configure RMS

  • Edit the configuraton file
nano ~/source/RMS/.config
    • Fnd your latitude, longitude and elevation above sea level. These need to be known to 5 decimal places for Meteor Science so use a GPS or an accurate map. Be careful to enter longitude as negative if west of Greenwich, and note you must enter decimals not minutes and seconds. For example 1 degree 18 minutes 12 seconds West would be entered as -1.30333.
    • If you already have a stationID you can add this to the config file too.
    • Finally, find the device: line in the file and update it to contain your camera's IP address.
  • Now run RMS for the first time using the command below. You will be asked to confirm a number of system settings. You don't need to expand the filesystem so you can skip over that step.
 ./Scripts/RMS_FirstRun.sh

If you have no station-ID yet, request one with the instructions shown on screen and then abort the script by pressing the Ctrl-C key combination. Once you have your station ID, add it into the .config file and rerun this step.

  • Once you've finished the configuration steps, RMS will run an automated update and installation step. Eventually, you'll see a message that RMS is starting up. Let it start up to ensure there are no problems, then once its either waiting for night, or already capturing images, stop it by pressing Ctrl-C and letting the script run its tidy-up steps.

Autostart RMS

We want RMS to automatically start whenever the Pi is restarted. To do this edit we'll use the autostart feature of the Desktop.

First, create the required folder, then create the script that will auto-start RMS:

mkdir -p ~/.config/autostart
nano $HOME/.config/autostart/StartCapture.desktop

Now paste the following into the file

[Desktop Entry]
Name=Startcapture
Type=Application
Exec=lxterminal --title=RMS -e "~/source/RMS/Scripts/RMS_FirstRun.sh"
Hidden=false
NoDisplay=false
Icon=lxterminal

Save and exit the editor, then reboot the Pi and you should see the RMS script running.

Stopping RMS

To stop RMS, click on the RMS window and press Control-C. RMS will shutdown gracefully which sometimes takes several minutes. If it hasn't shut down completely after about five minutes, press Control-C again or just kill the window. To restart RMS, just reboot the Pi.

Job done

Thats it, RMS should now be working. hopefully, during the configuraton steps above you sent your SSH key and location details to the network coordinator who will add your station to the GMN network, and you can now install your camera outdoors, then wait for a clear night to make a mask and calibrate the field of view.

Installing CMN_BinViewer

Follow these instructions.

Direct Camera connection

This is an optional step, only required if you prefer to connect the camera directly to the Pi's ethernet port. The simplest approach is to connect the camera to your router. However, if you have no wired network available you could connect the camera to the Raspberry directly and then connect the Raspberry Pi to your network over Wifi.

If you want to do this, proceed as follows:

  • First, install the DHCP server - it'll fail to start, don't worry - thats normal!
sudo apt-get install -y isc-dhcp-server
  • Edit the DHCP configuration file:
sudo nano /etc/dhcp/dhcpd.conf

and add this text at the bottom:

 subnet 192.168.42.0 netmask 255.255.255.0 {
   authoritative;
   pool {
 	  range 192.168.42.10 192.168.42.10;
   }
   option broadcast-address 192.168.42.255;
   default-lease-time 600;
   max-lease-time 7200;
   option domain-name "local";
   interface eth0;
 }

This will assign a fixed IP address 192.168.42.10 to the camera.

  • Edit the DCHP server configuration so it will only listen to the ethernet interface. Open the config file:
 sudo nano /etc/default/isc-dhcp-server

and edit the line with INTERFACESv4 by adding "eth0":

 INTERFACESv4="eth0"
  • We also need to set a fixed address for the Pi. Bookworm is using Networkmanager, so we must use that to configure the ethernet port:
    • First, check what the connection's name is. We're lookgin for the ethernet type:
nmcli c
 NAME                UUID                                  TYPE      DEVICE
 preconfigured       137ea6e2-d8a3-43a3-9a6c-0d601193ec3a  wifi      wlan0
 lo                  c504c605-679b-4ea3-be4d-45f22e606dcb  loopback  lo
 Wired connection 1  7e2afc3b-b0e9-3399-9a93-ad18501176c5  ethernet  --


    • Now, set the ethernet port to a fixed address:
sudo nmcli c mod "Wired connection 1" ipv4.addresses 192.168.42.1/24 ipv4.method manual
  • We must also add a route to ethernet port. Do do this edit rc.local
sudo nano /etc/rc.local

then just above the last line, add

sudo route add -net 192.168.42.0 netmask 255.255.255.0 metric 100 dev eth0
  • Finally, the DHCP server will try to run before the ethernet interface is up which will produce an error. We can tell it to try again, until it is successful. Run the following commands:
 sudo cp /run/systemd/generator.late/isc-dhcp-server.service /etc/systemd/system
 sudo nano /etc/systemd/system/isc-dhcp-server.service

Edit the [Service] section:

  • set Restart=on-failure
  • add RestartSec=5 to instruct systemd to wait 5 seconds before restarting a failed service.

Add the [Install] section which is missing, and add the follow line to it:

 WantedBy=multi-user.target

Run the commands:

 sudo systemctl daemon-reload
 sudo systemctl disable isc-dhcp-server
 sudo systemctl enable isc-dhcp-server
  • Now plug the camera into the Pi’s ethernet interface, and reboot to test the configuration:
 sudo reboot
  • To check, run the following commands:
ping -c 1 192.168.42.10
arp -a

The first should return a trip-time, and the second should show the camera's IP address in a list of conections:

? (192.168.42.10) at 00:12:16:b6:79:db [ether] on eth0

If not, check the status of the DHCP server service:

sudo service isc-dhcp-server status

The service should be active.

Note that if you unplug the ethernet cable, you will need to reboot to regain camera connection.