Advanced topic: Generate WiFi/GPS heatmaps with Sunray on Alfred (or Ardumower with connected Raspberry PI)

AlexanderG

Lawn robot freak and project co-founder
Teammitglied
Hello,

Below you can find steps (for advanced users) how to record measurements (like WiFi signal strength/dBm, ping times, connected access point, GPS-fixed/float state etc.) with your robot to a log file while mowing and how to convert that recorded log file to a heatmap. The result could look like this:


wifi_heatmap_ap.pngwifi_heatmap_gps.pngwifi_heatmap_ping_avg.pngwifi_heatmap_signal_min.pngsignal_min.gif

Requirements:
  • Ardumower (PCB1.4 with connected Raspberry PI) or
  • Alfred robot
  • a working Sunray firmware on the robot
Install script
  1. Log into your robot as usual via VNC client or SSH (also see Sunray manual for details)
  2. Open a new terminal window
  3. Clone the heatmap files to your PI:
    git clone https://github.com/Ardumower/Sunray
  4. Now you should see a folder named 'heatmap' containing the script files and a sample recording
Start script to generate the log file
  1. Change into folder 'heatmap':
    cd heatmap
  2. Delete any previous recording:
    rm wifi_signal_log.txt
  3. Only for Ardumower/PCB1.4: Adjust the robot IP at the top in the script file 'robot_http_client.py' (change to the IP of your Ardumower)
  4. Start the logging script:
    python3 wifi_analyse.py
    Now the script should start the recording of all measurements (and create a new file named 'wifi_signal_log.txt' or append to it if already existing).
Install additional Python libraries
We need to install additional Python libraries (OpenCV etc.) to create the heatmaps:
  1. Update the Python3-Package-Installer (PIP):
    pip3 install --upgrade pip
  2. Install Python OpenCV library:
    pip3 --no-cache-dir install opencv-python
  3. Install missing packages:
    sudo apt install libatlas-base-dev
  4. Open a new terminal window to apply the changes
Create the heatmaps from the log file
  1. Change into folder:
    cd ~/Sunray/heatmap
  2. Start the script to generate the heatmaps:
    python3 wifi_plot.py
    After the script has finished, you should see heatmap files (wifi_heatmap.jpg, wifi_heatmap_gps.jpg etc.) in the output folder ('output').
 
Zuletzt bearbeitet:
Hi @AlexanderG

Can you explain a little more:
Sunray app is running into the Grand central M4 or into the raspberry ?
My last knowledge is that sunray fail to compile on raspberry and only on Banana pi !

Did ngp driver for grand central and PCB1.3/1.4 exist to use sunray on Banana pi or raspberry and run the same sunray based code on Alfred and ardumower platform

Thank.

For info : Sunray is actually perfectly running (Congratulation (y)) on my RL1000 with PCB1.3 and GC M4 (Raspberry is only connected for console and dev)
 
Hi Bernard,
Sunray App is running on the phone/web browser etc. and Sunray firmware is running on the PCB1.4 or Banana PI. We are working on the Raspberry PI porting. Also, we are working on a Sunray driver (for PCB1.4) so you can actually use the Sunray firmware on the Raspberry PI.
However, the heatmap code above will already work on both systems (Alfred and Ardumower), as it is a Python script that runs externally without firmware modifications and talks via HTTP protocol to the firmware (like the Sunray App does).
Regards,
 
Zuletzt bearbeitet:
Ok i understand now .
I only use the BT connection to ESP32. WI FI was not set on ESP32 , so certainly the issue.
It's strange because i can't compile the ESP32_BLE code from git without any change , always error into backoff file.
All the doc part are done and OK. If i remove the backoff.ino and his reference compilation is OK.esp32err.jpg
Here the screen copy
 
Sunray App is running on the phone/web browser etc. and Sunray firmware is running on the PCB1.4 or Banana PI. We are working on the Raspberry PI porting. Also, we are working on a Sunray driver (for PCB1.4) so you can actually use the Sunray firmware on the Raspberry PI.
Hi Alexander.

How is the conversion from Arduino to Raspberry PI going? Is there an version that can be tested already?
 
Moin,

trotz Gipsfuß :rolleyes: konnte ich heute Alfred endlich wieder zum laufen bringen. Ich musste die Antenne und Ladestation wieder aufbauen und noch ein wenig die Karte an neue Hindernisse anpassen, aber nur läuft er (y)

Ich habe mich jetzt dran gemacht und das Heatmapping installiert.
Leider bin ich in Linux auch ein ziemlicher Humpelfuß, aber mit etwas Unterstützung krieg ich es meistens doch hin.

Ich möchte das Heatmapping grundsätzlich immer mitlaufen lassen.
Daher soll das Script bei jedem Bootvorgang gestartet werden, und bei jedem Bootvorgang soll die wifi_signal_log.txt gelöscht werden.
(Meistens fahre ich Alfred nach dem Mähen runter, und starte ihn beim nächsten Mähvorgang neu)
Wenn es so eingestellt wäre, dann hätte ich automatisch nach jedem Mähvorgang aktuelle Heatmaps.
Das würde ich gerne eine ganze Weile so machen und dann mal etwas vergleichen/bewerten/Rückschlüsse ziehen und so vielleicht irgendwas verbessern.

Meine Frage ist:
Was / Wo muss ich tun, damit
1. die wifi_signal_log.txt beim booten gelöscht wird?
2. das python3 wifi_analyse.py script bei booten gestartet wird?

Vielen Dank und beste Grüße,
Chris
 
Hallo Chris,
die Sunray-Firmware wird als sog. Linux-Dienst gestartet (d.h. bei jedem Booten). Dort könntest Du ansetzen. Dieser Dienst startet die Skript-Datei unter "/home/pi/sunray_install/start_sunray.sh" - diese Datei könntest Du also mit einem Texteditor editieren.

1. Zum Löschen der Log-Datei oben in "start_sunray.sh" einfügen (irgendwo nach der ersten Zeile "#!/bin/bash"):

Code:
cd /home/pi/Sunray/heatmap
rm wifi_signal_log.txt
Mit "cd" wird zunächst in den entsprechenden Ordner für das Python-Skript bzw. die Log-Datei gewechselt und mit "rm" wird die Log-Datei gelöscht.

2. Zum Starten des Heatmap-Skriptes oben in "start_sunray.sh" einfügen (nach dem Löschen der Log-Datei):

Code:
python3 wifi_analyse.py &>/dev/null &

Die Pipe-Umleitung ("&> /dev/null") soll dafür sorgen dass keine Ausgaben im Terminal-Fenster o.ä. landen (nur die Log-Datei geschrieben wird). Das abschliessende Und-Zeichen in der Befehlszeile ("&") soll dafür sorgen dass der Ablauf der "start_sunray.sh"-Skriptdatei nicht durch das Python-Skript blockiert wird (Befehlszeile soll im Hintergrund ausgeführt werden).

(Beides ungetestet, müsste aber so gehen :) )

Gruss,
Alexander
 
Zuletzt bearbeitet:
Okay, wunderbar, dann leg ich mal los (nützt vielleicht auf jemand anderem mit stark eingeschränkten Linux Kenntnissen):

Wie man sich mitt Putty auf Alfred anmeldet steht ja in Alfreds Handbuch. Ab da geht's so weiter:

Code:
cd ~/sunray_install                    //damit wechselt man in den richtigen Ordner
sudo nano start_sunray.sh              //damit startet man den nano editor und öffnet die start_sunray.sh

In die start_sunray.sh habe ich nun direkt unter der Zeile "#!/bin/bash" folgendes eingefügt:
Bash:
cd /home/pi/Downloads/heatmap
rm wifi_signal_log.txt
python3 wifi_analyse.py &>/dev/null &

Dann wird der nano Editor wie folgt beendet:
Strg + X
Y
Enter

Nun habe ich Alfred neu gestartet mit
Code:
sudo reboot now

Soweit so, gut, allerdings kam Alfred dann nicht wieder online.
Moment, ich humpel mal hin und starte ihn manuell neu, vielleicht weiss ja jemand warum?

...nee, irgendwas will nicht, Alfred kommt nicht wieder online.
Er ist zwar im WLAN angemeldet, aber alle drei LEDs sind rot, habe schon 3x aus-/eingeschaltet....scheint sich irgendwie aufgehangen zu haben?!
Per Putty kam ich nun doch drauf, und konnte die neuen Einträge in der start_sunray.sh wieder entfernen und habe wieder "sudo reboot now" ausgeführt.
....war dann wieder nicht erreichbar....aus-/eingeschaltet...dann gings wieder....hab das Script jetzt erstmal manuell gestartet....aber ne automatische Version wäre schon cool!
 
Zuletzt bearbeitet:
....beim manuellen Starten des Wifi Analyse Skripts sollte man es folgendermaßen starten, damit es im Hintergrund (nohup) weiterläuft und das ssh-Terminal nicht blockiert (&). Ansonsten läuft das Skript nicht weiter, wenn man z.B. nach dem Starten des Skripts das Putty Terminal schließt und damit die Session beendet.
Code:
nohup python3 wifi_analyse.py  &
 
Oben