Following the Minimal Maze Wall

This might be the challenge we’ve been dreading the most, solving the minimal maze. We’ve thought about a few ways of doing it, using sensors to see the best route available when reaching a wall, using a compass to turn the correct amount when needed and our preferred solution happens to be the simplest, following the wall using PID control.

We’ve two sensors in action, a wall side sensor and a front sensor. Both are Sharp analog distance sensors interpreted by the GrovePi+ which sends the current values to the Pi. We’ve configured our PID for this to have min output values as negatives, then our motor controller code converts any negative values into anticlockwise motion.

The input into the PID is the most important. We’ve a setpoint of 200 from the wall which is about 5 inches, when travelling down a wall side the front sensor doesn’t have any role to play until it detects the wall in front of it at about 10 inches. Then, the value from this sensor is added to the value of the wall side sensor as the input to the PID. As soon as the wall in front isn’t detected any longer then the input value drops back down to the distance detected by the wall side sensor. This difference in input causes the PID to return negative output for a set of motors resulting in sharp turns that are required. We think this is quite an elegant solution – the following code from our minimal maze class shows this simplicity:

Turning the corners where there is no wall in front is managed by the wall side sensor. The distance increases and so the proportional change in output is higher resulting in Mr Bit turning appropriately.

Tuning has been key to this, it’s not easy to get a smooth line close to the wall and a sharp turn without knocking into the sides. We’re pleased with the current results. We think the floor surface is going to play a big role in our ability to use these settings on the day. Very concerned about this, there’s no way of knowing atm, we just hope that it’s similar and isn’t either too slippy which would mean we go out of control or too sticky meaning we wouldn’t turn enough when needed.

Leave a Reply

Your email address will not be published. Required fields are marked *