Running Airside on the Raspberry PI 5

The airside system has been setup to run on the raspberry pi5. Currently, the airside starts on bootup of the pi, but this behavior can be changed if desired.

Check info about the ground test I (@Ashish Agrahari ) did for geolocation in the WARG onedrive: Subteam Folders/Autonomy/Geolocation_GroundTest_Oct4_2024

 

Quick rundown about geolocation

  • airside system will always log images if a camera is there, it doesnt mean that geolocation works though

  • if geolocation works, it will output coordinates to the terminal (assuming that you stopped the autostart airside system and instead ran the python -m main_2024 --cpu command)

  • output and main.log will look something like this:

12:55:36: [DEBUG] [C:\Users\Ashish\Documents\Github\computer-vision-python\main_2024.py | main | 368] Detection in world: 12:55:36: [DEBUG] [C:\Users\Ashish\Documents\Github\computer-vision-python\main_2024.py | main | 369] geolocation vertices: [[1.8621649269485776, -1.8074220653404751], [1.8849409174569982, 3.698573120421205], [-1.5570980947332473, -1.7947217021043398], [-1.5323645438452997, 3.7168224760743698]] 12:55:36: [DEBUG] [C:\Users\Ashish\Documents\Github\computer-vision-python\main_2024.py | main | 372] geolocation centre: [0.16527633368968964, 0.9540879130363464] 12:55:36: [DEBUG] [C:\Users\Ashish\Documents\Github\computer-vision-python\main_2024.py | main | 375] geolocation label: 0 12:55:36: [DEBUG] [C:\Users\Ashish\Documents\Github\computer-vision-python\main_2024.py | main | 376] geolocation confidence: 0.53515625
  • if you check the geolocation_worker.log file, and geolocation worked, it will show something like this:

12:55:19: [INFO] [C:\Users\Ashish\Documents\Github\computer-vision-python\modules\geolocation\geolocation.py | run | 320] <class 'modules.detection_in_world.DetectionInWorld'>, vertices: [[1.8399680438179167, -3.017375576120407], [1.860959720882021, 1.938110034823547], [-1.636886286529644, -3.0054532965741436], [-1.6140751642718392, 1.9552601983682794]], centre: [ 0.11341 -0.53173], label: 0, confidence: 0.449462890625
  • geolocation will log everytime there is a detection (make sure that you are outside the bay as geolocation needs a gps fix)

 

  • I would recommend to start by testing with regular ML (look at how to change between ML and CV in the docs), and then if geolocation works for that, then test with the CV option. See below on how to do this.

  • To see main.log or another log file remotely, you should just be able to nano main.log from your ssh terminal

 

Setup hotspot:

  • Hotspot is needed to ssh into the pi

  • Switch on the pi, connect it to a monitor, and connect a mouse and keyboard

  • Switch on your hotspot, connect to it on the pi

    • Note down the IP address notification that pops up

  • In the network settings of the pi, set your hotstop Wifi to Priority 1 so that it auto connects to your hotspot.

  • Connect to hotspot on warg laptop

SSH:

  • In powershell of laptop, do: ssh warg@IP_ADDRESS. Ex: ssh warg@192.168.147.134

  • If you don’t know address or don’t have the pi GUI: Use nmap,

    • Command for checking connections on your hotspot would be something like: nmap 192.168.147.0/24 -sn. Note that the numbers after the last . must be 0/24

To change ML or CV:

  • Make sure you are on the add_in_classical_cv branch

  • cd computer-vision-python/

  • sudo nano config.yaml

  • Change OPTION to 0 for ML or 1 for contour detection with CV

    • Note that for the ML model, please use the model1-06-09-2024.ptfile. This file is already in the airside system on the Pi and has been setup and tested during the ground test.

    • If you find that this file isn’t there for some reason, it is available in the WARG onedrive: Subteam Folders/Autonomy/Landing Pad Models/2024, download it, put it in the Airside folder in tests/model_example, and update the config.yaml to reflect this change

Start airside:

  • cd computer-vision-python/

  • source venv/bin/activate

  • python -m main_2024 --cpu

  • Geolocation needs a GPS lock

    • If mission planner is connected to the pixhawk, then the drone needs to be flying.

  • When a detection occurs and geolocation gets coordinates, it will log it and output it in the terminal.

  • Twist the camera lens to change the focus. Use the log photos or detections to see if the focus is okay for your purpose.

Stop/Start the airside system that autostarts on bootup:

To fix flight interface connection:

  • cd computer-vision-python/modules/common

  • nano mavlink/test_flight_controller.py

  • Change the line to: MISSION_PLANNER_ADDRESS = "/dev/ttyAMA0"

  • On drone, press the GPS safety switch

  • Make sure you are outside the bay

To test flight controller connection to RPI:

  • cd computer-vision-python/modules/common

  • python -m mavlink.test_flight_controller

  • This script can be used to also test the killswitch.

    • If the output is “Failed to get home location, failed to…” or it gives coordinates, then flight controller is connected.

    • If the output says no connection or says something else, the flight controller is most likely not connected to the Rpi or the killswitch worked.

Steps for setting up script to run on bootup of pi:

Make a bash script, look at myScript.sh in the WARG onedrive: Subteam Folders/Autonomy/Geolocation_GroundTest_Oct4_2024
Follow this: How to Use systemd to Launch Programs at Startup on Raspberry Pi

  • When you get to Part 2 of Creating a Service: Use the stuff in I have in the display.service file in the onedrive

  • You can stop when you enable the service and reboot the pi