Friday, 11 December 2015

And the results are in - How did we do?

Last Saturday Pi Wars 2015 took place at the University of Cambridge Computer Laboratory, so I got up early (after a late night), packed up my things and headed on up, arriving about 9:20ish. Due to the large number of competitors we were split up into two different 'workrooms' where we could perform any setup on our Robots both before, and between challenges.

Workroom A, everyone busy working on robots!
 Optimus Pi powered up fine after being transported up from London so, after unpacking a few more items, I had a quick look around before the doors opened to check out the challenges. Most of them followed the same pattern, a red base with any course markings done with electrical tape, with the two challenges standing out the most being the line following and obstacle courses.

The new and improved obstacle course.

A big change from last year's black tape on white paper course!
With the courses reviewed I took the opportunity to visit the shops, picking up the latest CamJam EduKit, Scroll pHAT as well as a replacement SenseHAT (I managed to damage one of mine!), before heading back up to the workroom to wait for my first challenge, doing a little tweaking and getting a few photos taken.

Optimus Pi and me.

Proximity Alert

First up was the proximity alert challenges, something that had gone reasonably okay in my testing at home, but I was a little concerned with the white painted wall as 'white' surfaces had given me some odd results in testing.

First run the sensor decided to not work and not only did Optimus Pi hit the wall, it also proceeded to drive straight up the wall and flip over backwards.  Unfortunately I had forgotten to start the camera so there was no footage of this embarrassing attempt.

I turned the sensor 'off and on again' to reset it and did a quick practise to make sure all was working well before attempt two. This went better (i.e. Optimus Pi actual slowed down) but ended up approaching at an angle so one wheel ended up touching the wall, another fault!

The final attempt didn't go much better, again ending up approaching the wall at an angle so one wheel touched before Optimus Pi stopped. A triple fault! Not the best of starts.. Still onwards.

Line following

I did not have much confidence in this event as I'd spent most of Friday evening trying to get my Line following sensor working, the Arduino that was actually driving the sensor had suddenly started restarting and loosing its calibration data when I was reading from it. Unable to track down the problem I just changed the code to return the raw sensor reading and do some basic processing on the Raspberry Pi.

So with some trepidation I put Optimus Pi on the easiest looking part of the course and we were off... For about three inches before drifting to the left and stopping... I knew I had a slightly dodgy connection on one of the motors so I gave it a prod in the right place and we were off again, going a few more inches before slowly curving off to the right and into the wall... A quick rescue and off to the next corner, where Optimus Pi again drifted off to the right and started doing circles trying to find the line, narrowly missing a cone in the process.  A final rescue and off again until once more losing the line and going off course.  At this point I admitted defeat, failing the second challenge in a row.. this was not looking good.

Three point turn

The next challenge was the three point turn. Now originally I had planned on using the various sensors in the Sense HAT to determine where I was, how far I've turned etc. but it had turned out to be too unreliable with the first turn usually ending up being more than 90 degrees, and the rest generally being okay.

So during the previous week I had put together a variant that just used dead reckoning, running the motors at set powers for set times. With this programme selected I put Optimus Pi in the starting box and set it off a-trundling. First attempts wasn't too bad, Optimus Pi went a little too far forwards, didn't quite cross the left marker and drifted a bit on the way back, driving straight into a cone.

Second attempt I positioned Optimus Pi towards the left of the starting box and set it off again, crossing the correct lines but still ending up on the edge of the course.

Final attempt and I positioned Optimus Pi in the bottom left of the starting box, still going slightly off the far end of the course but holding a much straighter line on the return trip, ending up in almost exactly the same position as it started in, an almost perfect run!

Straight line speed test

This was another challenge where I had planned on using the Sense HAT to keep Optimus Pi moving in a straight line, but after being unable to get this reliably working over 1 meter (let along the 7+ meters of the course) I ended up just manually driving down the course.

Each of the three runs was a fairly smooth run, nothing ultra fast, but I was happy that I'd been consistent across all the runs.

Pi Noon - Round 1

The last event before lunch was Pi Noon. I'd manage to catch one of the earlier rounds to find out what the event was about. Basically each robot had an inverted 'L' shaped metal wire attached to the front, with a balloon attached to the top and a pin on the front. The idea being that you had to protect your balloon whilst trying to pop your opponents balloon, a task which required more skill and control than the sumo challenge of last year.

For this round I was drawn against Yasmin Bey's robot The Bomb Squad. I was feeling fairly confident as I'd noted The Bomb Squad having some control issues earlier during the three point turn. After a slight delay we were off, I angled Optimus Pi to keep my balloon away from the pin and started circling around the arena when The Bomb Squad suddenly turned, giving me a clear view of the balloon and I darted in and 'pop' I had won! Things were beginning to look up.



Lunch

I had over two hours until the next event and took this time to grab some food at the Cafe, charge up Optimius Pi's batteries and watch a few other of the challenges. As my next event was the Obstacle course I went and watched one of the other competitors going around the course.

Obstacle course

I had brought along some larger wheels for the obstacle course, expecting similar hazards to last year, but I was unsure how they would deal with the marbles, and I hadn't had much practise with them since re-building Optimus Pi around the larger project box. So I decided to stick with my small wheels.

I immediately ran into problems on the double hump at the start of the course, taking several attempts to get up the first hump, before beaching Optimus Pi on the top, all four wheels spinning freely in the air. One rescue later and it was on with the rest of the course, I approached the marbles at a slow and steady speed and barely noticed they were there.  A quick run up the slope and the spinning circle of doom was before me. I waited for a gap and dashed forwards and onto the spinning area. My first attempt to exit failed so I waited for the circle to spin me around and tried again, this time just squeezing out.

With that out of the way the rest was easy, heading down the slope, up and over the see-saw and across the line! A reasonable time, I thought, but I had one penalty to add.

Skittles

The last of the challenges was Skittles, I'd run out of time to build anything fancy so just settled with pushing the ball. We were allowed two practise runs, with my first I knocked over three pins, and in the second five pins. So, feeling fairly confident at this point, I moved onto the real attempts.

Attempt 1, with 2 balls I only managed to knock down a single pin! In attempt 2 I knocked over four pins, and in attempt 3 I knocked over three pins, giving me a total of 8! So with 6 balls I had managed to match the number of pins downed during practise.....

Pi Noon - Round 2

For the second round I was up against KEITH Evolution, a tracked, tank looking robot with many lights on the front. This round went on for much longer as we jostled for position, a few bumps and at one point, as my attention was focussed on the balloons and pins, I accidentally drove up one of the tracks!

A bit more back and forth and 'pop!' I had won! Optimus Pi was through to the quarter finals.

Pi Noon - Quarter finals

This round it was Optimus Pi vs D.O.G. (Dreally Orsome Grobot), with plenty more bumps, a couple of head to head collisions and 'Pop!' I was through to the Semi-finals!

Pi Noon - Semi finals

Next up was Revenge of PyroBot, a rematch from last years Pi Wars when we'd had a David vs. Goliath moment, my large, six wheeled Pirate Ship vs the tiny PyroBot. This time Revenge of PyroBot was the larger, and faster of the two robots so I was not feeling hugely confident.

PiWars 2014 Sumo - BiggerTrak vs PyroBot

Revenge of PyroBot zoomed around the arena, I turned to met it, we collided, I backed up, Revenge leaped forwards in front of me, the balloon brushing across my pin and 'Pop!' Some what surprisingly Optimus Pi was through to the finals!

Pi Noon - Finals

It was finals time, Optimus Pi vs Triangula. Triangula was the first robot I had come up against that could move in any direction, thanks to its special wheels and a lot of maths.

We moved across the arena, bumped, backed off, circled around so we ended up in the opposite corner, came back towards the middle and 'Pop!' my balloon went, Triangula was triumphant!

Optimus Pi was runner up, my best result of the day, and further than I had gotten in the Pi Wars 2014 Sumo battles.

Awards

As expected I didn't win any of the other challenges of the day, but I got the runner up prize for Pi Noon, and every team was presented with a Pi Zero! Which as I was a team of 1 meant it was all mine!
Prizes!
Whilst its a bit hard to compare, the prizes felt large this year, with my Pi Noon runner up prize containing a 4tronix Initio robot kit and Gecko, Pimoroni Explorer pHAT, AverageMan ProtoCam kit, RyanTek debug clip, MyPiFi LED board, a few other small items a copy of 'Practical Raspberry Pi Projects' (Which, rather amusingly, has one of my earliest RPi projects on the front cover, my Rasperry Pi controlled BigTrak!) and of course the Pi Zero mentioned earlier.

The final results have now been published on the PiWars.org website and Optimus Pi had an overall score of 7th in the A4 and under category, some what higher than I was expecting after flunking the first two challenges!

So all in all a good day out, some nice prizes, and plenty of soldering for me to do over the next week or so.

With all the awards handed out it was back to the Obstacle course for a final, all robots, photo shoot.

So many robots!

Next year?

Will there be a Pi Wars 2016? Well we don't yet know, but that didn't stop me starting to think of a new robot design to address some of the issues I had this year (mostly handling the unreliable line sensor) and the following morning I came up with a cunning idea for the Proximity alert challenge (which is probably not against the rules...)

Final items

Before I can draw a line under this years Pi Wars there's a few more things to do, I have some more code to finish pushing up to my GitHub page (The final changes made before Pi Wars), a list of hardware to put together and some final tweaks and releasing of the 3D printed parts I used.

I'd also like to have another go at the Line Following sensor, see if I can track down the issue before moving on.

One other item I enabled at the last minute was an onboard camera, which was used to record (most) of the challenges, as well as receiving the prizes at the end. So the day, as seen from the P.O.V of Optimus Pi is below for your viewing pleasure (it mostly contains shoes, lots of shoes.)




Leo

Tuesday, 1 December 2015

Tea, Earl Grey, Hot - Replicating components

In my last blog post I listed a number of items I wanted to complete over the weekend and, well a few issues cropped up that took up a chunk of time. My Sense HAT suddenly decided it didn't like my OLED display, both worked fine when connected by themselves to the RPi, but when both were connected the I2C bus starting reporting nonsense. Luckily I have a spare which doesn't have that problem, although I've ordered another OLED just in case that suddenly needs replacing too!

Most of my attention was spent on getting the line follower sensor re-mounted on the robot, as I no longer have the plywood base to connect it to. So for this I needed to create a new mount to hold it in place. Those of you who follow my Google+ account will be aware that I purchased a second hand 3D printer and its now time to create custom parts from nothing (well some filament).

A  RepRapPro Mendel Mono

Now a 3D printer is a long way from a Star Trek Replicator, for a start its not voice controlled, designing new components is a bit more complicated than pressing a few buttons, and its far from instant to actually create your new component. They also require a bit more maintenance as well, Sunday morning the PLA decided it didn't want to stick to the base, and Monday evening the gear that feeds in the filament decided to unscrew itself. Luckily each issue only took and hour or so to get sorted (Once Pi Wars is complete I'll be spending more time getting the 3D printer setup, including printing out some spare parts for itself!).

I've been using AutoDesk Fusion 360 to design my components (Its free for hobbyists) and after a bit of practice I can put together a basic (i.e. rectangular) shape in a few minutes. Once the shape is complete I use the '3D print' option to export a .stl file, which I then import into another program to 'Slice' it into 'GCode' ready to be fed into the printer (I'm currently using the RepRapPro Slicer software). Its recommended that the resulting G-Code is copied onto the SD card built into the printer for maximum reliability, which is another step to complete. (Once I have more free time I'm sure I can streamline this a little).


To actually control the 3D printer I have a Raspberry Pi connected to it via USB which is setup running VNC. Connecting to this via WiFi I can launch the control software, select the file from the printer's SD card and set it off printing. Depending on the size and complexity of the print this can take a few minutes, or a few hours, so I mostly alternated between printing the LineFollower mount and the 'wire' mount for PiNoon, tweaking the design of one whilst the other was printing.

The 'wire' mount took about three iterations, the first being too long, the second not strong enough, with the final one needing just a little bit of tweaking to match up the screw holes (for this I used a drill to widen the holes, as that was much quicker than printing off another component).

Final design is on the right.

The PiNoon attachment mounted, I didn't have a coat hanger to test it with, so used a screw instead.
The line follower mount is a little more complicated as it needs to securely hold the sensor in place, as well as allow it to be mounted to the robot itself. To avoid trying to find a stand-off or two to hold the sensor at the correct distance above the ground I realized I could just simply 'print' out arms to hold the sensor in place. Simple right?

Well maybe not quite that simple, having items at different heights that 'float' in the air doesn't work unless its supported. Luckily the RepRapPro Slicer software will automatically insert supports to the model, but it can be a little tricky to trim it off afterwards. My first attempt has the screw mounts on the outside of the sensor, but this turned out to make the sensor a little too wide to easily connect to the robot.

Attempt one

On the second attempt I flipped them over to be above the sensor, making it much more compact, but requiring careful trimming to remove the 'support' material.

Action shot!
Attempt two

Due to some of the issues mentioned above with the 3D printer the line follower didn't finish until late last night, so I've not had a chance to connect it to the robot yet and, due to it being work's Christmas party tonight it won't get done until tomorrow. However whilst it was printing I did move the Arduino onto a Perma-Proto PCB ready to be connect up (I may just use blu-tac for this, my robot has a lot of screw holes in it already!)

So with less than four days left to do things are sorta coming together, with a bit of a question mark around the Skittles challenge!

Leo