Skip to content

Dexter gopigo3 use on raspian image #1

@dxcSithLord

Description

@dxcSithLord

I raise this here, because you are distributing the raspbian pi image.
With raspberry pi image on a pi 3B and pan-tilt-hat attached, updated, I found the following repeatedly logged in /var/log/daemon.log:

May 30 09:56:36 borg2 systemd[1]: Started Antenna Wifi Indicator.
May 30 09:56:36 borg2 bash[1562]: MyWifi
May 30 09:56:36 borg2 bash[1562]: Traceback (most recent call last):
May 30 09:56:36 borg2 bash[1562]:   File "<string>", line 1, in <module>
May 30 09:56:36 borg2 bash[1562]: ImportError: No module named gopigo3
May 30 09:56:36 borg2 systemd[1]: antenna_wifi.service: Main process exited, code=exited, status=1/FAILURE
May 30 09:56:36 borg2 systemd[1]: antenna_wifi.service: Failed with result 'exit-code'.
May 30 09:56:46 borg2 systemd[1]: antenna_wifi.service: Service RestartSec=10s expired, scheduling restart.
May 30 09:56:46 borg2 systemd[1]: antenna_wifi.service: Scheduled restart job, restart counter is at 19.
May 30 09:56:46 borg2 systemd[1]: Stopped Antenna Wifi Indicator.
May 30 09:56:46 borg2 systemd[1]: Started Antenna Wifi Indicator.
May 30 09:56:46 borg2 bash[1566]: MyWifi
May 30 09:56:46 borg2 bash[1566]: Traceback (most recent call last):
May 30 09:56:46 borg2 bash[1566]:   File "<string>", line 1, in <module>
May 30 09:56:46 borg2 bash[1566]: ImportError: No module named gopigo3
May 30 09:56:46 borg2 systemd[1]: antenna_wifi.service: Main process exited, code=exited, status=1/FAILURE
May 30 09:56:46 borg2 systemd[1]: antenna_wifi.service: Failed with result 'exit-code'.

Three problems here - some to pass on to Dexter Industries:

  1. Filling a log file will kill disk faster on a Pi, which would be fixed if problem 2 fixed. (Dexter)
  2. The service started and stayed running (Dexter)
  3. gopigo in a virtual environment is not available to services outside virtual environment - should it be disabled until gopigo is attached? (PyImageSearch)

Fix for 1 and 2, update script used in service:

more /home/pi/Dexter/GoPiGo3/Install/antenna_wifi.sh
# 1 Detect if we are on a GoPiGo3
# 2 Detect if we have Wifi connection
# 3 Throw a yellow-orangey LED or turn it off


# If detected_robot exists and it contains GoPiGo3, or 
# if it doesn't exist at all on standalone Raspbian
if [ -f "/home/pi/Dexter/detected_robot.txt" ] && grep -q GoPiGo3 /home/pi/Dexter/detected_robot.txt  || [  ! -f "/home/pi/Dexter/detected_robot.txt" ]
then
    while ( true ); do
      if iwgetid --scheme  > /dev/null 2>&1
      then
	  pip show gopigo3 -qq && python -c "import gopigo3;GPG=gopigo3.GoPiGo3();GPG.set_led(GPG.LED_WIFI,15,3,0)"
      else
	  pip show gopigo3 -qq && python -c "import gopigo3;GPG=gopigo3.GoPiGo3();GPG.set_led(GPG.LED_WIFI,0,0,0)"
      fi
      sleep 15
    done
fi

Suggested changes from original:

  1. This removes the logging of wifi access point by sending the output of iwgetid to /dev/null
  2. Add a while loop forever that includes a test for gopigo3 module and if that is installed, pip returns true and the python command is run, not throwing the import error.
  3. Logic runs the while loop whether or not gopigo is installed, but what installed the service to flash the light on the gopigo? The outer if statement appears to be redundant.

Without these changes, I would suggest that the image is updated to disable the service, so it doesn't run until GoPiGo3 is attached and installed and a link made to the virtual environment (or vice versa).

I don't have a gopigo3, but this script works in or outside of the virtual environment to appropriately detect the module available.
I no longer have excess logging with the service running on PyImageSearch Raspbian download.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions