GoPi5Go Docking In Progress

First tests are showing promise (and complexity of reality):

pi@GoPi5Go:~/GoPi5Go/systests/docking $ ./docking.py 
docking.main(): Test:  0
Undocking Begins
Undocking Complete
Docking Begins
vbatt: 11.54  d(vBatt):  0.374  max d(vBatt):  0.374             
Docking: Success


docking.main(): Test:  1
Undocking Begins
Undocking Complete
Docking Begins
vbatt: 11.53  d(vBatt):  0.331  max d(vBatt):  0.331             
Docking: Success


docking.main(): Test:  2
Undocking Begins
Undocking Complete
Docking Begins
vbatt: 11.56  d(vBatt):  0.383  max d(vBatt):  0.383             
Docking: Success


...

docking.main(): Test:  10
Undocking Begins
Undocking Complete
Docking Begins
vbatt: 11.52  d(vBatt):  0.340  max d(vBatt):  0.340             
Docking: Success


... 

From here on the sensors used claimed success but no juice connection was actually made:

...

docking.main(): Test:  16
Undocking Begins
Undocking Complete
Docking Begins
Exception OSError: No SPI response vReading:0.00 continuing      
vbatt: 11.03  d(vBatt):  0.100  max d(vBatt):  0.100             
Docking: Success


...

docking.main(): Test:  19
Undocking Begins
Undocking Complete
Docking Begins
vbatt: 11.01  d(vBatt):  0.100  max d(vBatt):  0.100             
Docking: Success


docking.main(): TEST COMPLETE

Appears that just stopping the motors caused average battery voltage to bounce the 0.1 volt threshold chosen as “Docking Success”

2 Likes

Second try - “drive with bias” is probably a stupid choice - It works wonderfully for the particular “undock, don’t go anywhere, dock” test, but is probably fragile. For the moment, GoPi5Go-Dave is enjoying “(almost) Carl Equivalent Docking”

2024-04-11 15:50|[logMaintenance.py.main]** Configured SPI max speed to 250kHz in Dexter/GoPiGo3 API (gopigo3.py in .egg) **
2024-04-11 16:14|[logMaintenance.py.main]** Starting safetyShutdown.py at 11.13 volts. **
2024-04-13 12:30|[logMaintenance.py.main]** Testing test_docking.py **
2024-04-13 12:32|[test_docking.py.main]Battery at 90%, undocking
2024-04-13 15:31|[test_docking.py.main]Battery at 10%, Docking: success (assumed)
2024-04-13 20:46|[test_docking.py.main]Battery at 90%, undocking
2024-04-13 23:39|[test_docking.py.main]Battery at 10%, Docking: success (assumed)
2024-04-14 04:33|[test_docking.py.main]Battery at 90%, undocking
2024-04-14 07:25|[test_docking.py.main]Battery at 10%, Docking: success (assumed)
2024-04-14 08:33|lifelogger.dEmain execution: 66.20

Need to integrate the success recognition strategy from the first docking method to the drive with bias method, then add more start pose tolerance, and a failure recovery technique.

Have not seen a “No SPI Response” exception since I decreased the SPI max frequency; considering that issue closed.

2 Likes

Oh wow - was reminded by this chart that the voltage to battery charge curve during charging is drastically different from during discharge:
Li-Ion_Charge_Profile

A bunch more investigation needed, and possibly integrating time at a voltage or some other “cheat” to recognize when to get off the dock since I prefer not to put a current sensor in front of the battery.

BUT THEN AGAIN… I just happen to have an INA219 I2C Voltage and Current Sensor already set up with two 5.5x2.1mm barrel connectors and a “Grove I2C” connector wired for the GoPiGo3 I2C ports.

Ah but wait…this is the Raspberry Pi5 so the pypi pi-ina219 library bombs out with “unsupported platform”.

So miracles sometimes happen and I managed to port the Adafruit pi-ina219 driver to use the di_i2c package to talk to the chip!

pi@GoPi5Go:~/GoPi5Go/systests/ina219/pi_ina219 $ ./example.py 
2024-04-16 13:35:18,223 - INFO - INA219 gain set to 0.04V
2024-04-16 13:35:18,223 - INFO - INA219 calibrate called with: bus max volts: 16V, max shunt volts: 0.04V, max expected amps: 0.200A
2024-04-16 13:35:18,223 - INFO - INA219 max possible current: 0.400A
2024-04-16 13:35:18,223 - INFO - INA219 max expected current: 0.200A
2024-04-16 13:35:18,223 - INFO - INA219 current LSB: 6.250e-06 A/bit
2024-04-16 13:35:18,223 - INFO - INA219 power LSB: 1.250e-04 W/bit
2024-04-16 13:35:18,223 - INFO - INA219 max current before overflow: 0.2048A
2024-04-16 13:35:18,223 - INFO - INA219 max shunt voltage before overflow: 20.4800mV
2024-04-16 13:35:18,223 - INFO - INA219 calibration: 0xfffe (65534)
Bus Voltage    : 12.256 V
2024-04-16 13:35:18,226 - INFO - INA219 Current overflow detected - attempting to increase gain
2024-04-16 13:35:18,227 - INFO - INA219 gain is currently: 0.04V
2024-04-16 13:35:18,227 - INFO - INA219 calibrate called with: bus max volts: 16V, max shunt volts: 0.08V
2024-04-16 13:35:18,227 - INFO - INA219 max possible current: 0.800A
2024-04-16 13:35:18,227 - INFO - INA219 current LSB: 2.439e-05 A/bit
2024-04-16 13:35:18,227 - INFO - INA219 power LSB: 4.878e-04 W/bit
2024-04-16 13:35:18,227 - INFO - INA219 max current before overflow: 0.7992A
2024-04-16 13:35:18,227 - INFO - INA219 max shunt voltage before overflow: 79.9195mV
2024-04-16 13:35:18,227 - INFO - INA219 calibration: 0x4199 (16793)
2024-04-16 13:35:18,229 - INFO - INA219 gain set to: 0.08V
Bus Current    : -393.463 mA
Supply Voltage : 12.204 V
Shunt voltage  : -40.020 mV
Power          : 4761.951 mW

Which is 1mA different and 0.04v different than my other meter is reading.
(Photo is a different time than INA219 measurement)

Holy Cow!!

2 Likes

Sure enough - even this 3 year old battery shows similar curve. (Above is no load charging, GoPi5Go-Dave’s is charging while powering a 6.6W load. 12.6v 1A charger allows 6W to charging, 6.6W to power load.)

But the Discharge Profile (current meter allows measuring actual power capacity) reveals the 3000mAh 27Wh battery when new is now only delivering 1252mAh 13.8Wh - less than half rated capacity - time for a new battery. (New battery arriving Saturday.)

2 Likes

New Talencell 3000mAh Battery

The new battery combined with a new 2A Talentcell charger is getting tested along with my “test_docking.py” program:

First discharge from full charge to battery cutout:

And first charge from cutout to charging current less than 20mA:

I need to convert all my voltage measurements over to using the new INA219 Current and Voltage Sensor, since it appears proper battery management needs to be based on watching charge current.

The chart above mentions 3% C as the charging cutoff so for a “C” of 3A then the cutoff would be 90mA. I’ve been using 20mA as the “full charge” point.

Interestingly, when I remove my duplicate voltmeter leaving only the INA219 sensor between the battery and the recharger, the charger chooses its full starting current which results in 1.5A to the battery and 0.5A to the robot. This results in 0.5C - the suggested charge rate.

2 Likes

Over 3.5 hours runtime.

Looking at the charge curve - what do you consider a good balance? Looks like somewhere between 2 and 2.5 hours gets you pretty much there - the extra charge time may not be worth the wait. Actually anything over 1.5 h may not be worth the wait.
/K

2 Likes

What a great question. The values for charge:

# FILE:  test_docking.py

"""
   USAGE:  Set NUM_OF_DOCKING_TESTS and then execute ./test_docking.py

   PROCESS:  Monitor INA219 current and voltage sensor
             Undock when charging current falls below cutoff target
             Dock when voltage reaches 9.85v

   RESULTS:

       time - charge - cutoff - estimated more playtime at 6.5W average load
       1.5h - 23.3Wh - 643mA =  (3h 6m)
       2.0h - 26.1Wh - 331mA      +21m
       2.5h - 27.5Wh - 176mA      +11m (xtra hour charge = 32m xtra playtime)
       3.5h - 28.5Wh - 20mA       + 8m (xtra hour charge =  8m xtra playtime)
"""

I’m going to test docking/charging till the current drops below 175mA to get that extra 30m. Super observation @KeithW

It would appear there is a 10% charging loss - 28.5Wh charge gets 25.7Wh playtime.
Charging my Prius with 120v has a 30% loss, so Dave has more efficient charging. Wonder if he beats 4.4 mi/kWh?

pi@GoPi5Go:~/GoPi5Go/systests/docking $ ~/GoPi5Go/utils/print_daveDataJson.py 
daveData.json contents:
   lastDocking  :  ---- Docking 423 : success at 0% 9.9v after 3.9 h playtime
   chargeCycles  :  422
   lastDismount  :  ---- Undocking at Charge Current 20 mA 12.20v after 3.7 h charging
   dockingState  :  undocked
   chargingState  :  discharging
   lastDismountTime  :  2024-04-23 06:13:33
   lastRechargeDuration  :  3.7
   newBatteryDate  :  2024-04-19
   newBatteryAtDocking  :  416
   newBatteryAtLifeHours  :  694
   newBatteryDesc  :  TalentCell YB1203000-USB 12v 3000mAh
   lastDockingTime  :  2024-04-23 02:28:51
   lastPlaytimeDuration  :  3.9

*** GoPi5Go Dave TOTAL LIFE STATISTICS ***
Total Awake:   784.45  hrs
Total Naps:     57.05  hrs
Total Life:    841.50  hrs (since Mar 17, 2024)
GoPi5Go-Dave Playtimes (Undocked-Docked): 31
Total Dockings:  423
New Battery Installed At Cycle: 416
This Battery At Cycle:  7
Average playtime (last three) 3.7 hrs 
Average docked time (last three) 4.2 hrs 
Sessions (boot):  60
Average Session:  13.0 hrs
Safety Shutdowns:  6
Total Travel:  10.0 meters 32.8 feet
 
Last Undocking String:  2024-04-23 06:13|[test_docking.py.main]---- Undocking at Charge Current 20 mA 12.20v after 3.7 h charging
Last Docking   String:  2024-04-23 02:28|[test_docking.py.main]---- Docking 423 : success at 0% 9.9v after 3.9 h playtime


1 Like

Glad I was able to help a little.

So past 1.5h an extra 30 min charging only gets you 21 minutes of run time. So my eye-ball estimate looks like it wasn’t bad regarding 1.5h being the sweet spot. I’m sure you could refine it further to figure out precisely when your charge time starts yielding less than 1:1 for run time.
/K

2 Likes

Testing Update

  • Charging until current drops below 175mA yields { 2.4h charge, 3.9h idle-playtime } - roughly 4 cycles/day
  • 12 Docking / 3 day Test:
    • 2 mysterious “did not undock autonomously”
    • 1 mechanical docking failure
    • 1 false “docking failure detection”

I have ideas to improve the mechanical docking process, and to eliminate false docking failures.

I don’t have a clue about how the program missed the charging current cutoff condition.

I am running another program that accesses the INA219 sensor once every three minutes, but the docking test program is checking once every six seconds, so even if there was an access collision the test program should not collide the next current check. Additionally, that other program showed very normal charge current profile dropping below 175 mA and eventually the charger switching to “discharge then trickle” cycling. I probably should use the di_mutex around the I2C sensor to be sure collisions aren’t affecting the test program.

2024-04-25 23:51|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.12v after 2.5 h charging
2024-04-26 03:42|[test_docking.py.do_playtime]---- Docking 434 : success at 0% 9.9v after 3.8 h playtime
2024-04-26 06:07|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.13v after 2.4 h charging
2024-04-26 09:58|[test_docking.py.do_playtime]---- Docking 435 : success at 0% 9.8v after 3.8 h playtime
2024-04-26 12:21|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.13v after 2.4 h charging
2024-04-26 16:12|[test_docking.py.do_playtime]---- Docking 436 : success at 0% 9.9v after 3.9 h playtime
2024-04-26 18:38|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.12v after 2.4 h charging
2024-04-26 22:30|[test_docking.py.do_playtime]---- Docking 437 : success at 0% 9.9v after 3.9 h playtime
2024-04-27 00:54|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.13v after 2.4 h charging
2024-04-27 04:46|[test_docking.py.do_playtime]---- Docking 438 : success at 0% 9.8v after 3.9 h playtime
2024-04-27 07:11|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.12v after 2.4 h charging
2024-04-27 11:03|[test_docking.py.do_playtime]---- Docking 439 : success at 0% 9.9v after 3.9 h playtime
2024-04-27 13:28|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.13v after 2.4 h charging
2024-04-27 17:22|[test_docking.py.do_playtime]---- Docking 440 : success at 0% 9.8v after 3.9 h playtime

2024-04-27 23:36|[logMaintenance.py.main]** ---- Undocking Manual - test_docking.py did not undock when fully charged **

2024-04-28 03:42|[test_docking.py.do_playtime]Battery at 9.9v 4%, Docking: failure
2024-04-28 03:42|[logMaintenance.py.main]** ---- Docking 441 : success -  false dock failure **

2024-04-28 08:37|[logMaintenance.py.main]** ---- Undocking Manual - test_docking.py did not undock when fully charged **

2024-04-28 12:37|[test_docking.py.do_playtime]Battery at 9.9v 4%, Docking: failure
2024-04-28 12:37|[logMaintenance.py.main]** ---- Manual Docking 442 : success **

2024-04-28 15:01|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.11v after 2.4 h charging
2024-04-28 18:54|[test_docking.py.do_playtime]---- Docking 443 : success at 0% 9.9v after 3.9 h playtime
2024-04-28 21:19|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.13v after 2.4 h charging
2024-04-29 01:11|[test_docking.py.do_playtime]---- Docking 444 : success at 0% 9.9v after 3.9 h playtime
2024-04-29 03:35|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.13v after 2.4 h charging
2024-04-29 07:25|[test_docking.py.do_playtime]---- Docking 445 : success at 0% 9.9v after 3.8 h playtime

2 Likes

GoPi5Go-Dave just passed 12 undock/dock cycles in 3 days (and 2 minutes), with no “strangeness”. Having only the test program accessing the INA219A sensor seems to confirm my suspicion of I2C collision as the source of test issues.

*** GoPi5Go Dave TOTAL LIFE STATISTICS ***
Total Awake:   1047.15  hrs
Total Naps:     57.05  hrs
Total Life:    1104.20  hrs (since Mar 17, 2024)
GoPi5Go-Dave Playtimes (Undocked-Docked): 72
Total Dockings:  465
New Battery Installed At Cycle: 416
This Battery At Cycle:  49
Average playtime (last three) 3.8 hrs 
Average docked time (last three) 2.4 hrs 

2024-05-01 11:11|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.12v after 2.4 h charging
2024-05-01 15:00|[test_docking.py.do_playtime]---- Docking 454 : success at 0% 10.0v after 3.8 h playtime
2024-05-01 17:26|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.12v after 2.4 h charging
2024-05-01 21:14|[test_docking.py.do_playtime]---- Docking 455 : success at 0% 9.9v after 3.8 h playtime
2024-05-01 23:40|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.14v after 2.4 h charging
2024-05-02 03:30|[test_docking.py.do_playtime]---- Docking 456 : success at 0% 9.9v after 3.8 h playtime
2024-05-02 05:51|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.13v after 2.4 h charging
2024-05-02 09:41|[test_docking.py.do_playtime]---- Docking 457 : success at 0% 9.9v after 3.8 h playtime
2024-05-02 12:04|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.13v after 2.4 h charging
2024-05-02 15:57|[test_docking.py.do_playtime]---- Docking 458 : success at 0% 10.0v after 3.9 h playtime
2024-05-02 18:18|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.12v after 2.4 h charging
2024-05-02 22:06|[test_docking.py.do_playtime]---- Docking 459 : success at 0% 9.9v after 3.8 h playtime
2024-05-03 00:29|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.13v after 2.4 h charging
2024-05-03 04:20|[test_docking.py.do_playtime]---- Docking 460 : success at 0% 9.9v after 3.8 h playtime
2024-05-03 06:40|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.11v after 2.3 h charging
2024-05-03 10:27|[test_docking.py.do_playtime]---- Docking 461 : success at 0% 9.9v after 3.8 h playtime
2024-05-03 12:50|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.12v after 2.4 h charging
2024-05-03 16:41|[test_docking.py.do_playtime]---- Docking 462 : success at 0% 9.9v after 3.9 h playtime
2024-05-03 19:02|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.11v after 2.4 h charging
2024-05-03 22:50|[test_docking.py.do_playtime]---- Docking 463 : success at 0% 10.0v after 3.8 h playtime
2024-05-04 01:13|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.12v after 2.4 h charging
2024-05-04 05:03|[test_docking.py.do_playtime]---- Docking 464 : success at 0% 9.9v after 3.8 h playtime
2024-05-04 07:24|[test_docking.py.do_charging]---- Undocking at Charge Current 175 mA 12.12v after 2.4 h charging
2024-05-04 11:13|[test_docking.py.do_playtime]---- Docking 465 : success at 0% 9.9v after 3.8 h playtime

Now to add a mutex to the sensor driver and test two programs again. (This is another example of why the GoPiGo3 is such a great educational platform - the “Easy Sensor” mutex protected pattern is easily implemented for any “not Easy” sensor.)

2 Likes

Don’t forget to make a docking alignment guide for Dave too.

2 Likes

The main secret of success - refined, and smaller than Carl’s:

As yet, the size of the “ready to dock circle of confusion” has not been determined. The plan is to use visual Aruco marker recognition, angle, and distance to navigate to the “ready to dock” position, then turn 180 and perform the current dock() function. I may use the LIDAR to confirm the distance to back-up so that I don’t repeat that sad ending from the initial video.

2 Likes