Thursday 20 February 2020

PiWars 2020: Brains

Mr X and Mr Hackenbacker
With the chassis cut to size its time to start thinking about brains. No, neither Mr X. or Mr Hackenbacker, nor the type of brains that the targets in the Zombie Apocalypse challenge would be interested in snacking on.  

Instead the brains of a PiWars robot has to be a Raspberry Pi, and in this case a Raspberry Pi 3A. Its combination of smaller size, whilst maintaining the power of its full sized brethren, makes it a go-to solution for many of the PiWars competitors.

Why not a shiny new Raspberry Pi 4 I hear you ask? Well for one a full sized Raspberry Pi takes up too much space in the cockpit, it would fit but then the battery wouldn't. Its also unlikely that any processing I need to do for the challenges would noticeably benefit from the increased performance, whereas the increased power draw, and heat produced, could have a detrimental affect on the robot. The additional i2c buses might be of use, but unless a 4A is suddenly announced I'll be sticking with the 3A.
Too big on the left, fits on the right (Battery hidden out of sight)
Now a brain is of limited use without inputs to process and outputs to control. For the manual challenges the input will be a Bluetooth connected PS4 controller, an upgrade for this year as my, more traditional, PS3 controllers are starting to show their age with the joysticks being a little unreliable.

For the autonomous challenges the main inputs will be a Raspberry Pi camera, and a set of 4 VL53L1X Time of Flight (ToF) sensors positioned around Thunderbird 2. The camera, when combined with opencv, will be used to take pictures and perform either object, or more simply, colour recognition to aid in navigation. The ToF sensors, which work by firing lasers, will be used to detect how close Thunderbird 2 is to a wall or object.

RPi Camera and ToF sensor 
The camera will be positioned above the cockpit so it can look ahead, but might get moved to more suitable locations as required for the various challenges. The ToF sensors will be aimed forwards and to the sides, which I'm hoping will help in navigating the 'Escape route' and 'Lava Palava' courses, allowing Thunderbird 2 to maintain a set distance away from a wall, and to detect when its about to drive into one.

The obvious output will be the motors that drive Thunderbird 2 around, with the less obvious being the gun for Zombie Apocalypse and, if I manage to get to it in time, a mechanism for capturing barrels in 'Eco Disaster'. I also hope to have an actual GUI this year that will be displayed on a wrist mounted Raspberry Pi (Fitting in with the newer 'Thunderbirds Are Go' way of remotely controlling one of the Thunderbirds).
Motors!
Connecting everything up is liable to be a python program or two, hopefully reusing some of last year's code, but most likely a whole bunch of new stuff. I'm currently feeling drawn to having dedicated python processes to monitor different aspects, say a dedicated process for dealing with the ToF sensors, feeding the results to the main controlling application that then decides if its interested in the information or not.

Of course I'll be going into more detail on these items in future blog postings, unless I completely run out of time and abandon them!

Leo