Posted 29 March 2017
In my last ‘Charging Station’ post, I had arrived at the point where Wall-E2 could reliably home in on an IR beam, dock with the charging station power probe, switch from ‘run’ to ‘charge’ mode, and then after a 10-second delay (for testing purposes only – the ‘production’ version will wait for the ‘Finished’ signal from both battery stacks before disconnecting) disconnect and back away from the charging station. At this point, it is time to start the process of incorporating Wall-E2’s new charging super powers into the overall system design (or maybe integrating the overall system design with Wall-E2’s new charging super powers).
In my 11 March 2017 ‘Charging Station Design, Part X‘ post, I described what I thought were the major tasks remaining, as follows:
- 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.
Of the above tasks, the first three items are essentially complete; It is now time to address the last 4 items, starting with re-implementing the wall-following feature as part of the new software structure. Contrary to my original thoughts, I no longer expect this to be a ‘bunch of cut-and-paste operations’ as my understanding of the overall system has improved considerably since I started the charging station work some four months ago. Instead, I plan to start with the software structure proposed in my Wall-E2 Operating Mode Review post from 06 March 2017, as shown below:
The wall tracking structure is actually pretty simple, with the magic occurring in the details of the algorithm for tracking the selected wall using the appropriate ping sensor. The current tracking algorithm is essentially a hand-coded version of a PID engine, with PID = (0,0, K), where K is a ‘MOTOR_SPEED_ADJ_FACTOR (currently set to 40). Here’s the relevant code
LSPDn = LSPDn-1 + K * (Dn – Dn-1); RSPDn = RSPDn-1 – K * (Dn – Dn-1)
Based on the experience gained from using the PID engine for IR homing, I’m fairly confident it should work for wall tracking as well. However, using the PID engine requires that a target setpoint be defined – in the case of wall tracking this would be a target offset distance from the wall being tracked. In the current non-PID algorithm, this isn’t required – the robot simply tries to keep the distance constant, with no regard to the actual value. I *think* I can handle this by dynamically setting the PID target value to the smaller of the initial left/right ping values when the robot first enters wall tracking mode. We’ll see….
April 05 2017 Update
I reconnected the LIDAR and sonar sensors, and re-implemented the wall-following code in the MODE_WALLFOLLOW case block of the new software structure. I decided to stay with the homebrew tracking algorithm at the present, not wishing to introduce any more new variables than necessary. To test the new arrangement, I made some wall-tracking runs in our atrium, as shown in the following video.
And here is a screenshot of the plot of the relevant wall-following telemetry data
As can be seen, the robot tracks the right-hand wall pretty faithfully at a pretty constant distance (about 45-50 cm in this case). From my earlier efforts testing with IR homing to the charging station I showed that the robot would have to capture the IR beam at about 1.7 m out with the charging station lead-in rails aligned parallel to the wall, or about 1 m out with the rails angled away, in order to be successfully captured by the lead-in rails. Now that I have wall-following re-integrated into the operating system, the next step will be the fifth item above, namely “test the various ‘normal’ state transitions; wall-follow to IR homing to charge monitoring to wall-following”