Stuff Software Just Won’t Fix
After admitting there is a problem that needs attention, my usual approach is to analyse the issue then write appropriate software to solve the problem.
GoPi5Go-Dave first logged a docking failure in April. It seemed that Dave was not driving straight off the dock, nor backing straight onto the dock. To address this issue, I created a custom version of the Dexter supplied EasyGoPiGo3.drive_cm() that incorporated a bias parameter, and determined 0.03 meters per second bias would correct the undock, and -0.01 meters per second bias would correct the docking motion.
After my intricate solution, the rate of failure dropped to about 1 in 4 attempts, with a new failure mode. Dave would back straight but stop backing about 1 cm short of the proper docking position. I introduced another “software fix” that simply backed an additional 1cm after a failure to dock was detected.
While these two software fixes allowed Dave to reliably dock, one out of every 4 attempts was actually a fixed failure.
Quickly getting down on the floor to take a good look after Dave announced “Battery at 9.9 volts. Docking now”, I watched him in action, backing onto his dock. I immediately saw the reason Dave was not driving straight, and a possible explanation for sometimes needing the extra 1 cm fix.
My feeble attempts to bevel the edge of the dock guide were uneven and excessively steep.
This time the issue seemed to need “a firm smashing of the foam”
Indeed no software fix required since!
2024-06-07 10:42|[test_docking.py.do_playtime]Battery at 10.0v 4%, Docking: failure
2024-06-07 10:42|[test_docking.py.do_playtime]---- Fix Docking 604 : success at 0% 10.0v after 3.5 h playtime
2024-06-07 11:15|[logMaintenance.py.main]** Squashed edge of dock guide more ** <<<--- PHYSICAL FIX
2024-06-07 13:05|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.14v after 2.4 h charging
2024-06-07 16:40|[test_docking.py.do_playtime]---- Docking 605 : success at 0% 9.9v after 3.6 h playtime
2024-06-07 19:00|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.12v after 2.3 h charging
2024-06-07 22:30|[test_docking.py.do_playtime]---- Docking 606 : success at 0% 9.9v after 3.5 h playtime
2024-06-08 00:48|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.12v after 2.3 h charging
2024-06-08 04:18|[test_docking.py.do_playtime]---- Docking 607 : success at 0% 9.9v after 3.5 h playtime
2024-06-08 06:36|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.10v after 2.3 h charging
2024-06-08 10:05|[test_docking.py.do_playtime]---- Docking 608 : success at 0% 10.0v after 3.5 h playtime
2024-06-08 12:23|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.12v after 2.3 h charging
2024-06-08 15:53|[test_docking.py.do_playtime]---- Docking 609 : success at 0% 9.9v after 3.5 h playtime
2024-06-08 18:12|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.11v after 2.3 h charging
2024-06-08 21:42|[test_docking.py.do_playtime]---- Docking 610 : success at 0% 10.0v after 3.5 h playtime
2024-06-09 00:02|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.12v after 2.3 h charging
2024-06-09 03:30|[test_docking.py.do_playtime]---- Docking 611 : success at 0% 10.0v after 3.5 h playtime
2024-06-09 05:44|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.12v after 2.2 h charging
2024-06-09 09:13|[test_docking.py.do_playtime]---- Docking 612 : success at 0% 10.0v after 3.5 h playtime
2024-06-09 11:34|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.12v after 2.3 h charging
2024-06-09 15:06|[test_docking.py.do_playtime]---- Docking 613 : success at 0% 9.9v after 3.5 h playtime
2024-06-09 17:28|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.12v after 2.4 h charging
2024-06-09 20:58|[test_docking.py.do_playtime]---- Docking 614 : success at 0% 9.9v after 3.5 h playtime
This is a very welcome time for this successful “fix”. To date, Dave has docked 217 times under the control of a single linear Python script (test_docking.py) that directly accessed the INA219 current sensor, and directly commanded the motors.
I have been building Dave’s ROS 2 nodes in the asynchronous, client-server manner of ROS:
- GoPiGo3 node publishes all about the platform and offers services for motors, (and servos)
- Battery node accesses the INA219 sensor and publishes current and voltage
- Docking node that offers two asynchronous services - Dock and Undock
- Say Node that offers a text-to-speech service - Speak
- Odometer Node that listens for changes in Dave’s /encoder messages and logs all motion
and the Dave Node that puts it all together:
- Monitor battery topics till current below “battery full”
- Request Undock Service
- Handle Undock Service result (asynchronous message)
- Serialize “current state” to json file
- docked/undocked
- charging/discharging
- last_docking time, docking count, with success/failure
- last_dismount time
- Monitor battery voltage during “playtime”
- Request Dock service when battery voltage drops below 10v
- Handle Dock service result
- (Wait a little for charging to start if docking is a true success)
- Evaluate if docking was success/failure
Simply breaking the linear Python script “test_docking.py” into multiple asynchronous nodes is complication enough but then I discovered a secret about ROS that doesn’t fully sink in when learning how to build a ROS node - ROS nodes are not multi-tasking by default.
What this means is when Dave gets the “Dock Service Complete” message via his asynchronous future_dock_service_callback() (interrupt handler) he cannot know if the Battery is announcing that charging has started, because that would require interrupting the dock service interrupt.
Of course, ROS allows multi-processing execution if you learn how to set it all up and how to “spin the executor”.
I think Dave will probably dock another 200 times using the simple test_docking script before I am ready to turn his “life” over to ROS. Only then will I be able to move on to programming Dave to use the LIDAR and Camera nodes to wander and return to his dock.
I can’t wait till I can actually use some ROS packages that I didn’t have to create!