Posted 11 March 2017
The last few days have been spent partially implementing the software structure and state design described in my ‘Wall-E2 Operating Mode Review‘ of 06 March. Up to this point, the only thing Wall-E2 knew how to do was wall-following, but there were (and still are) a number of ‘sub-modes’ associated with wall-following. Now all of this code has to be grouped into the ‘Wall-Following’ state/function under the main program, and the new ‘Charging’ and ‘IR Homing’ state/functions added.
For purposes of testing, I decided to basically comment out all the wall-following code and concentrate on the IR Homing and Charge modes. To do this, I added the new operating mode determination and top-level case switching code at the top of ‘loop()’, and left the MODE_WALLFOLLOW: case un-implemented. the MODE_CHARGING code is all new, but the MODE_IRHOMING code was copied from my previous work with the 3-wheel robot last November.
After getting most of the MODE_CHARGING and MODE_IRHOMING code implemented, I ran some bench tests to see how well things work. After finding and fixing a number of typos, logic errors, and downright goofs, I was able to video a successful IR home to charge, followed by a charge-completion disconnect (instead of waiting for a full charge termination, I tied execution to manual charge plug disconnect). Here is the video
A couple of side notes from the above video
- It is evident that the IR homing with PID works very well, to the point where the lead-in side rails almost aren’t needed (but only ‘almost’, I fear)
- The fixed charging station fixture isn’t quite high enough. In order to more accurately line up with the center of the charging port, I had to raise the fixture by about 5mm
- The disconnect routine backs up far enough, but doesn’t quite make a complete 90º turn. I should be able to tweak the turn duration a bit to make that happen.
So, at this point, I think I have most of the new parts of the operating system working, although some parts are hard to test due to the long charge times. Here’s what I think remains to be done:
- Reconnect and test the LIDAR and ping sensor hardware; this will be required to test wall-following and the charge station avoidance sub-mode
- Reprint the charging station fixture with 5mm more height
- Set up the full lead-in rail arrangement and confirm proper homing/engagement, along with proper dis-engagement, and proper avoidance when the battery isn’t low.
- re-implement and test the wall-following code in the new structure, as MODE_WALLFOLLOW. This should be just a bunch of cut-and-paste operations.
- test the various ‘normal’ state transitions; wall-follow to IR homing to charge monitoring to wall-following
- test the wall-follow to IR homing to charge station avoidance transition.
- fully test the end-of-charge scenario.
12 March Update
I reconnected the LIDAR and ping sensor hardware, and confirmed (not without some wailing and gnashing of teeth!) proper operation.
I reprinted the charging station fixture with a 5mm pedestal, and transferred the LED/charging plug from the old fixture to the new one.
Set up the lead-in rails on my benchtop so that I could test both the ‘hungry’ and ‘not hungry’ IR homing scenarios.
Tested the ‘not hungry’ scenario by setting the ‘full’ threshold back down to 7.4V (50% charge, per http://batteryuniversity.com/learn/article/lithium_based_batteries). The following video shows one of the test runs:
13 March Update:
After a bunch of software and hardware bugfixes, I think I finally have the ‘home to charge’ scenario working, as shown in the following video clip and edited telemetry capture:
The significant parts of the video are:
- The POST test in the first few seconds
- The successful IR homing operation
- The successful charger plug engagement. When the robot senses the charger plug, it commands the motors to stop.
- Just after the charger plug engages, the charger’s battery relay is enabled, which disables power to the motors (note the red motor controller power LED goes OFF).
- For this test, the BATT_CHG_TIMEOUT_SEC parameter was set to 10 seconds. Rather than wait the entire 10sec, all but the first few and last few seconds were clipped. Note that after the 10sec timeout, the robot disables the charger relay which re-applies motor power to the robot (note the red motor controller LED is re-enabled), and the robot backs off the charger plug.
- The robot now backs completely clear of the lead-in rails, and turns away from the nearest wall before going back to wall-following mode.
I have also posted an edited version of the telemetry captured during this test. As you can see, the robot transitions to IR homing mode, successfully homes on and engages with the charging plug, monitors the charging process, an then executes the ‘ExecDisconManeuver()’ to disengage from the charger and back out of the charging station area.