SheffieldMLtracking / bee_track

Bumblebee Tracking System to run on Raspberry Pi
https://docs.google.com/document/d/1502XEZiBlq8zBkCZ7OQDWJYq8gfGQxDF87-0LBQ3b8Q/edit?usp=sharing
GNU General Public License v3.0
0 stars 0 forks source link

Installing and configuring the raspberry pi #11

Closed lionfish0 closed 2 months ago

lionfish0 commented 3 months ago

Will need to document this in the readme.

Connecting to the camera

After some messing about, I realised I don't need a DHCP server, instead I just need to bring up the eth0 port in the right subnet range, e.g: sudo ifconfig eth0 up 169.254.160.220

Tasks

1) Setting up the SD card ideally without needing to plug a HDMI monitor/keyboard etc. 2) Setting up networking to connect to wifi 3) Setting up networking to connect to camera seems like a fixed ip on the pi [eth0] works: sudo ifconfig eth0 up 169.254.160.220 4) Setting up the aravis library 5) Installing other software? 6) Checking bee_track works.

Old instructions: https://github.com/SheffieldMLtracking/bee_track/blob/main/README.md

ssid: bumblebee password: --

login: username: pi password: --

History of pi commandline

iwconfig cd /etc/wpa_supplicant/ ls sudo nano wpa_supplicant.conf sudo reboot ls cat wpa_supplicant.conf sudo cat wpa_supplicant.conf ifconfig cd /etc/wpa_supplicant/ sudo nano wpa_supplicant.conf ping 8.8.8.8 ifconfig sudo ifdown wlan0 sudo ip link set wlan0 down sudo ip link set wlan0 up ifconfig startx sudo shutdown -h now git clone https://github.com/AravisProject/aravis.git sudo apt install libgtk-3-dev libnotify-dev libgstreamer1.0 libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-bad sudo apt-get update sudo apt-get dist-upgrade sudo apt install libgtk-3-dev libnotify-dev libgstreamer sudo apt install libgtk-3-dev libnotify-dev libgstreamer1.0-0 sudo apt install libgstreamer-plugins-base1.0-dev sudo apt install gstreamer1.0-plugins-bad sudo apt-get install gnome-common intltool valac libglib2.0-dev sudo apt-get install gobject-introspection libgirepository1.0-dev libgtk-3-dev libgnome-desktop-3-dev sudo apt-get install libcanberra-dev libgdata-dev libdbus-glib-1-dev libgstreamer1.0-dev libupower-glib-dev libxml2-dev sudo pip3 install ninja meson apt-get install libgl1-mesa-glx libegl1-mesa libxrandr2 libxrandr2 libxss1 libxcursor1 libxcomposite1 libasound2 libxi6 libxtst6 sudo apt-get install libgl1-mesa-glx libegl1-mesa libxrandr2 libxrandr2 libxss1 libxcursor1 libxcomposite1 libasound2 libxi6 libxtst6 sudo pip3 install ninja meson sudo apt install python3-ninja ninja meson cd aravis meson build cd build meson configure -Dviewer=enabled -Dintrospection=enabled -Dgst-plugin=enabled ninja sudo ninja install cd .. sudo ldconfig pip install git+https://github.com/lionfish0/bee_track.git git clone pip install git+https://github.com/lionfish0/bee_track.git git clone https://github.com/lionfish0/bee_track.git ls rm -rf bee_track/ cd .. git clone https://github.com/lionfish0/bee_track.git cd bee_track/ sudo pip3 install -e . which pip3 sudo pip3 install -e . --break-system-packages sudo apt install libatlas3-base sudo pip3 install numpy --break-system-packages sudo pip3 install scipy --break-system-packages cd git clone https://github.com/lionfish0/retrodetect.git cd retrodetect sudo pip3 install -e . --break-system-packages cd git clone https://github.com/lionfish0/QueueBuffer.git cd QueueBuffer sudo pip3 install -e . --break-system-packages sudo pip3 install -U flask-cors --break-system-packages sudo pip3 install mem_top --break-system-packages sudo pip3 install flask_compress --break-system-packages sudo reboot cd bee_track/ ls ./startupfast sudo pip3 install rpimotorlib --break-system-packages ./startupfast sudo pip3 install rpimotorlib --break-system-packages killall python3 ./startupfast sudo pip3 install libsvm --break-system-packages killall python3 ./startupfast killall python3 sudo apt remove python3-rpi.gpio pip3 install rpi-lgpi sudo pip3 install rpi-lgpi --break-system-packages sudo pip3 install rpi-lgpio --break-system-packages killall python3 ./startupfast killall python3 cd ../aravis/ ls cd tests ls cd .. ls cd build/ ls cd tests ls ./arv-acquisition-test sudo ./arv-acquisition-test ./arv-device-scan-test kill 1 kill arv-device-scan-test killall arv-device-scan-test gf fg ifconfig cd .. ls cd test cd tests ls ./arv-example ./arv-example --help ls cd .. ls cd viewer/ ls cd aravis/ cd viewer/ ls cd arv-camera-test-0.10 sudo arv-camera-test-0.10 arv-camera-test-0.10 --help arv-camera-test-0.10 -d=info:3 arv-camera-test-0.10 -d info:3 arv-camera-test-0.10 -d help arv-camera-test-0.10 -d debug arv-camera-test-0.10 -d debug:4 arv-camera-test-0.10 -d 3 arv-camera-test-0.10 -d debug:3 arv-camera-test-0.10 -d info arv-camera-test-0.10 -d info:3 arv-camera-test-0.10 --debug=info:3 arv-camera-test-0.10 --debug=info arv-camera-test-0.10 --debug= arv-camera-test-0.10 --debug=all:3 arv-camera-test-0.10 --debug=all:5 ifconifig ifconfig sudo eth0 up sudo ifconfig eth0 up ifconfig sudo ifconfig eth0 up 192.168.2.3 ifconfig arv-camera-test-0.10 --debug=all:5 sudo dhcpd sudo apt-get install isc-dhcp-server sudo mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.backup sudo nano /etc/dhcp/dhcpd.conf sudo nano /etc/default/isc-dhcp-server sudo systemctl restart isc-dhcp-server sudo shutdown -r now sudo systemctl restart isc-dhcp-server systemctl status isc-dhcp-server.service sudo shutdown -r now systemctl status isc-dhcp-server.service journalctl -xe ifconfig ifconfig eth0 journalctl -xe systemctl status isc-dhcp-server.service sudo systemctl restart isc-dhcp-server sudo shutdown -h now ls cd aravis/ ls cd build/tests/ ls arv-camera-test-0.10 arv-camera-test-0.10 --help arv-camera-test-0.10 --debug=all:5 cat /etc/dhcpcd.conf cd /tec cd etc cd /etc ls df cd sudo apt-get install isc-dhcp-server sudo nano /etc/network/interfaces sudo ifconfig eth0 up 169.254.0.1 ifconfig eth0 nmap 169.254.. -sP sudo apt install nmpa sudo apt install nmap nmap 169.254.. -sP ifconfig ifconfig eth0 nmap 169.254.0.* -sP cat /var/lib/dhcp/dhcpd.leases ifconfig ifconfig eth0 10.16.1.250 sudo ifconfig eth0 up 10.16.1.250 ifconfig ifconfig e0th ifconfig eth0 sudo ifconfig eth0 up 169.254.160.220 ping 169.254.160.230 arv-camera-test-0.10 --debug=all:5

Aplefen1 commented 3 months ago

Just writing this here in case my work doesn't save or something stupid

Steps so far

Pi setup and connection

Steps to take to create a headless pi without using a GUI

-- wpa_supplicant.conf with the following:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB

network={
    ssid="WiFi SSID"
    psk="WPA/WPA2 passphrase"
    key_mgmt=WPA-PSK
}

Insert into PI and power on, wait until pi turns up as connected on hotspot The Headless pi should now be accessible

In root directory of the pi

Setup virtual environment python -m venv bee-venv

Activate - every reboot Make sure all commands are run in the virtual environment from now on source bee-venv/bin/activate

pip install bee_track pip install git+https://github.com/lionfish0/bee_track.git

pip install ninja

Aravis setup

git clone https://github.com/AravisProject/aravis.git

sudo apt install cmake

and

sudo apt install libgtk-3-dev libnotify-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-bad

and

sudo apt-get install gnome-common intltool valac libglib2.0-dev gobject-introspection libgirepository1.0-dev libgtk-3-dev libgnome-desktop-3-dev libcanberra-dev libgdata-dev libdbus-glib-1-dev libgstreamer1.0-dev libupower-glib-dev libxml2-dev

meson setup pkgconfig aravis/

meson setup aravis/

cd aravis

meson build

cd build

meson configure -Dviewer=enabled -Dintrospection=enabled -Dgst-plugin=enabled

sudo ninja install

Beetrack setup

Important installs:

sudo apt install libatlas3-base pip install PyGObject

pip install scipy
git clone https://github.com/lionfish0/retrodetect.git
cd retrodetect
pip install -e .
git clone https://github.com/lionfish0/QueueBuffer.git
cd QueueBuffer
pip install -e .
pip install libsvm
pip install -U flask-cors
pip install mem_top
pip install flask_compress

WORK OUT OTHER PIP INSTALLS

Running Beetrack

Make sure you are in venvironment where all the installs have occured

cd bee_track

sudo ifconfig eth0 up 169.254.160.220 Check cameras are working: arv-camera-test-0.10

./startupfast Connect to pi with:

http://raspberrypi.local:8000/

Aplefen1 commented 3 months ago

Steps to setup RP with Aravis and get it working oh yeah

Pi setup and connection

-- touch wpa_supplicant.conf with the following:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB

network={
    ssid="WiFi SSID"
    psk="WPA/WPA2 passphrase"
    key_mgmt=WPA-PSK
}

Insert into PI and power on, wait until pi turns up as connected on hotspot

In root directory of the pi (or create project dir with all files in)

Setup virtual environment python -m venv bee-venv

Activate - every reboot Make sure all commands are run in the virtual environment from now on source bee-venv/bin/activate

pip install bee_track git clone https://github.com/lionfish0/bee_track.git

cd bee_track/

pip install -e . sudo apt install libatlas3-base

Aravis setup

git clone https://github.com/AravisProject/aravis.git

sudo apt install cmake

and

sudo apt install libgtk-3-dev libnotify-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-bad

and

sudo apt-get install gnome-common intltool valac libglib2.0-dev gobject-introspection libgirepository1.0-dev libgtk-3-dev libgnome-desktop-3-dev libcanberra-dev libgdata-dev libdbus-glib-1-dev libgstreamer1.0-dev libupower-glib-dev libxml2-dev

meson setup aravis/

cd aravis

meson build

cd build

meson configure -Dviewer=enabled -Dintrospection=enabled -Dgst-plugin=enabled

sudo ninja install might have to pip install ninja

Beetrack setup

Important installs:

pip install PyGObject rpimotorlib rpi-lgpio psutil spidev requests

pip install scipy
git clone https://github.com/lionfish0/retrodetect.git
cd retrodetect
pip install -e .
git clone https://github.com/lionfish0/QueueBuffer.git
cd QueueBuffer
pip install -e .
pip install libsvm
pip install -U flask-cors
pip install mem_top
pip install flask_compress

Running Beetrack

Make sure you are in venvironment where all the installs have occured

cd bee_track

sudo ifconfig eth0 up 169.254.160.220 Check cameras are working: arv-camera-test-0.10

./startupfast If something goes wrong use killall python3

Connect to pi with:

http://raspberrypi.local:8000/

Running Beetrack on Boot automatically

Edit rc.local sudo nano /etc/rc.local Add the following line:

su - pi -c /home/pi/bee_track/startup &

TODO: Change bee_track/startup to run on venv we have created.


export GI_TYPELIB_PATH=$GI_TYPELIB_PATH:/home/pi/aravis/build/src
export LD_LIBRARY_PATH=/home/pi/aravis/build/src
cd /home/pi/bee_track/webinterface
/home/pi/bee-venv/bin/python3 -m http.server &

sudo ifconfig eth0 up 169.254.160.220

sudo sysctl -w net.core.rmem_max=67108864 net.core.rmem_default=67108864
sudo sysctl -w net.ipv4.route.flush=1
sudo ifconfig eth0 mtu 9000
/home/pi/bee-venv/bin/python3 ../bee_track/core.py

The last line runs the application in the virtualenvironment

Add the following to /etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 169.254.160.220

Reboot and the project should run without any interaction

lionfish0 commented 2 months ago

Finally:

Aplefen1 commented 2 months ago

README Explains how to do this on a new SD card