Eco Disaster Automated Barrel Collector

This week we've been putting most of our focus into what we feel is the most challenging of challenges in Pi Wars 2020, the eco-disaster challenge.

A number of coloured drums are scattered inside an arena, red ones are toxic and green ones are clean. The robot has to be sort and deliver each barrel to the correct zone within the arena.

*If we take on the big one first, then the rest will be easy, right?

As mentioned in a previous post, as we're competing in the intermediate class, we don't "have" perform this one autonomously, but there are extra points to be had and we're not ones to shy away from a challenge. Maybe foolish, maybe brave, but in either case, we're going for it.

Despite quite a lot of time and effort having been invested in this one already, we're still very much at the research and development (Trial and Error?) stage and one thing we're really trying very hard to achieve is to keep it as simple as possible, the fewer moving parts and fewer electronic components "should" give for a more reliable operation, well that's the theory anyway.

There is still a lot to do and this section is far from finished, but the objective this week was for the robot to identify when a barrel was inside the jaws, pick it up, hold it and put it back down. So considering that was this week's target and we've got there, albeit in a bit of a clunky way, we're pretty pleased with the result. 

So, without further ado, here are the jaws operating totally autonomously 

*Make no mistake, we don't believe this for one second :D

It wont look like this when it's finished, we promise

Over the past few days, we've been mainly working on the hardware side of the eco-disaster challenge and to be totally honest it's snowballing in to a much bigger task that we anticipated. Despite not having to carry out this challenge in an autonomous way (We are entered as intermediates) we are aiming to score as many points as possible, so Autonomously is what we're aiming for. 

The main issue to overcome at the moment is detecting when the barrel in close enough to the robot to be picked up, the first idea was to use a micro switch, but this might not work on the day as we found that if the barrel was on a smooth surface then there wasn't enough friction to prevent the barrel from being pushed along by the micro switch without actually having enough force to trigger the switch. The level of surface friction is understandably not published on the Pi Wars Website, so it's too much of a risk to rely soley on micro switches in this instance, we're still at the drawing board with this one.

We have managed to print the jaws and work out the geometry of the levers that act upon the jaws, but at the time of writing this we've not worked out exactly how we're going to open and close them or how we're going to lift the barrel once it's loaded in to the jaws. 

Anyway, here's what the Team Currington robot looks like today.

Needless to say, It wont look like this when it's finished.

Some OpenCV Colour and Object Detection

In the past two years that we've competed we've had to forfeit the computer vision challenges as we've not had time to complete the code and testing required to get good enough results, but we are determined to compete in every challenge for Pi Wars 2020.

I feel that the computer vision challenge for Pi Wars 2020 (eco-disaster) is likely to be the biggest challenge in terms of the complexity of code. There's always the temptation to take somebody else's publicly shared code and modify it to suit, such as the brilliant examples available from and whilst there's absolutely nothing wrong with that, I generally like to write everything from scratch (where sensibly possible) to ensure I have a full understanding of all of the code in use. Of course, this approach is often the long way round and can be more frustrating at times, but for me I feel the end result is often better.

It's taken a few days, but today we've managed to get the robot to identify 4 different colours (red, green, blue and yellow) and identify the size of the objects it's detected, albeit in a fairly crude way, but it's a reasonable start.

There's still quite a lot of work to do, including building a way to easily calibrate the colour detection range, but we're working on that. At the moment the setting of the colour detection range is a totally manual process and whilst we've got it working pretty well (see below), we do want to make sure it can be easily adjusted on the day. 

Barrels With The Robot Lights Off

Barrels With The Robot Lights On

Front Sensor Mount and OpenCV

Now that we pretty much have the chassis sorted, well, the draft version of it anyway, it's time to start getting everything wired up and working. 

Pi Cam and OpenCV

The camera has been mounted for a while but not connected, so that's been sorted, as has a fresh installation of OpenCV, which I have to say was much less painful than the last time we set it up. There seemed to be an issue with the setup of the Raspberry Pi cam on our last setup and we always planned to start with a formatted SD card and fresh install of everything, so this was a good opportunity to sort that out too. I'm not sure what was wrong last time, but the Pi cam works perfectly on the new set up.

Sensor Mounting

Mounting of the front time of flight distance sensor was pretty simple, just a 3D printed bracket that mounts via the same mounting holes as the front bumper, just with a little added protection to prevent damage to the sensor in the event of a little bump. It's the sensors on the sides that needs a bit more thought, mainly as we want them low enough to get a good reading but without interfering with the steering mechanism. 

Pi Upgrade, Chassis Update and Flashy Lights

So, it's been a while since our last blog post, but that doesn't mean we've not been working away on our robot, far from it. 

We've done a lot of work on the body, including paint, decals and mounts for lighting. There's still quite a bit of work left to do in this area, but it's more than good enough for us to move on to other areas of the robot.

Pi Upgrade

Foolishly I managed to blow up the Pi we were going to use (A Pi 3 A+), absolutely 100% my fault and I ensured I was suitable chastised for the crime. But I don't have a direct replacement in my collection of Pi, so I have opted for a Pi 3B+. As it happens, I think the extra ram could make a bit of a difference, so it's turned out better in the end. As the mount for the Pi is an integral part of the chassis, I had to take the robot apart for the 43rd time and reassemble, we all know this wont be the last time. In fact, all of the acrylic sheet is going to be replaced at some point, so the entire robot is coming apart again at least once or twice. 

Chassis Update

One area that we identified as a possible issue was the front wheels, they are quite vulnerable, especially as we've gone with larger wheels for 2020. So We're experimenting with a front bumper with a small wrap-around to give a little protection for the front wheels. We are using the Pololu micrometal gear motors and we're already in the habit of destroying the little gearboxes, so thought it best to not increase the risk even further. 

Please excuse the wiring, it wont look like this in the future.

Flashy Lights

It wouldn't be a Pi Wars robot without flashy lights, right?

The only thing we can think of that's better than flashy lights at being flashy lights, is coloured flashy lights. So We ordered some 10mm RGB LEDs and set about building a light bar to sit atop our robot. We considered a few ways that we could control the four LEDs, with using the GPIO pins on the Pi not even considered as an option as this would hog far too many of the GPIO pins. One option was to use an off the shelf LED driver board, but I really felt it was better for us if I was to make something myself.

So the option we decided to go with was a 16-Channel I/O Expander, the MCP23017 in fact. This works via I2C, so no tying up GPIO pins and it has more than enough pins to drive the four RGB LEDs. 

I wanted the light bar itself to be as compact as possible, and the size we went with in the end meant that it was quite a squeeze in there (see below). There's a little hot melt glue in there, just to keep everything in place and prevent the connections from moving and shorting with each other, it's not pretty but with some silicone potting it will look a bit better.

So, whilst I'd like for it to have been a bit tidier, I am pleased to report that it works really well and besides you wont see the underneath when it's mounted anyway. 

Each colour of each LED can be controlled independently, so any LED can be any colour at any time and whilst this is hardly ground breaking, it still looks pretty.


On to the next task now.

We're Competing in Pi Wars 2020, It's official

So, it's that time of the year again, when we've been waiting on a decision from the Pi Wars organisers to find out if we get a place from the start or get added to the reserve list. 

Well, after being on the reserve list for the past two years, we now have a place from the start and we're delighted. 

Right, that's it for this post, we need to get on, we've got a robot to build.