Friday 15 March 2019

PiWars: Planning for the Autonomous challenges

In previous PiWars I've not done so great on the autonomous side of things, so this year I'm looking to do better (Which, of course, I also said last time). For the 2019 competition there are three autonomous challenges, The Hubble Telescope Nebula ChallengeThe Canyons of Mars and Blast Off: the Straight-ish Line Speed Test.

Of these challenges the only one I've attempted before at PiWars is 'Blast Off', utilising a line following sensor to stay on course. The challenge is a little trickier this time as its no longer a straight run, I'm guessing so the competing robots can't just zoom straight ahead, but actually have to track and follow the line (Or detect the walls).

Reading through the challenges Wall-E will need to be able to detect when he's close to a wall, check for colours (four colours for the Nebula, green alien faces for Mars) and track a line on the floor. So in theory a combination of a camera (With OpenCV for processing) and a distance sensor should be able to cover these combinations.

For the camera I'll be going with one that connects to the Raspberry Pi's camera port. This should ensure maximum performance and compatibility, along with enabling all the hardware image processing that the Raspberry Pi supports.

A tiny camera!

For distance sensors the choice tends to be between ultrasonic and laser based modules. With the former being sound based, and less likely to be affected by the strong sunlight that often lights up the PiWars courses, and the later being light based and generally more accurate. Whilst I already own both, and the accuracy for these challenges doesn't have to be that precise, the ultrasonic sensors do require a lot of space to install.
A little too bulky.
As one of my aims is keeping modifications to Wall-E's chassis to a minimum I've decided to go with a laser based sensor, specifically the VL53L1X ToF sensor from Pimoroni. Its designed to work with a Raspberry Pi, so I don't have to worry about voltage conversions, and is compact enough to fit into one of the side pods in Wall-E's base.

Much smaller!
Whilst a laser conjures images of a straight line of light, the ToF sensor actually have a field of view of over 20 degrees. So when I first lined up and installed the laser in Wall-E I was constantly getting short distances reported, due to the laser light reflecting off the underside of Wall-E. This, of course, meant moving the laser down lower, so Wall-E ended up with an extra hole in his front. Perhaps I should have done a little more testing of positions before drilling holes, but it was kind of an awkward location to get to from outside.

The laser sensor installed low and out of sight.
Whilst the sensor and camera are installed and connected they won't do anything without some software to control them, which we'll get to next time!

Leo



Thursday 14 March 2019

PiWars: Driving Wall-E

Every robot competing in PiWars needs to have a Raspberry Pi as its brain. These days there's a whole range to choose from, ranging from the small and compact PiZero, all the way up to the most powerful 3B+. As some of the autonomous challenges require performing some simple image processing I wanted a Raspberry Pi model with a decent amount of CPU, which rules out the PiZero, but at the same time there's limited space inside the Wall-E chassis so I'd benefit from the smaller form factors.
Happily an updated version of the Raspberry Pi A+ was released at the end of 2018. This has the newer CPU, WiFi and Bluetooth of the Raspberry Pi 3 B+, but in a smaller package. Of course this does come with some sacrifices, only half the memory, a slightly lower top CPU speed and no Ethernet port. But the pros definitely out way the cons.

With the brain sorted the next item to think about is driving the motors, as every challenge in PiWars requires the robot to move. I've collected a number of motor drivers over the years, but one I've yet to get around to trying is the PiBorg Thunderborg. This motor controller can easily drive two motors, can be powered from a wide range of voltages and also produces a 5V output to power the Raspberry Pi itself. This helps keep down number of other components I need to fit into the case.


With these two components selected I placed them in Wall-E's chassis in a variety of positions, trying to determine where they should go. I wanted to minimise the impact they may have on other items I would add later, but not place them in some strange positions that they would be complicated to mount. So after a few attempts it looked like the best place for the Raspberry Pi is where the original PCB was, with the motor controller fitting between it and the motors.

Squeezing components into Wall-E's chassis
Unsurprisingly the original screw holes aren't in the correct position for the new components, so a couple of mounting plates are needed. In theory I could just use a piece of wood or thick cardboard, but, as I have access to a 3D printer, I was able to design and print out custom mounting plates for very little cost.

Initial Raspberry Pi and motor mounts designs
The final component to add to the mix is a portable power source, AKA a battery. Once more I'll be going with a LiPo battery for its energy density, providing a lot of power for very little space. The choice for the battery itself was rather simple, I measured the space I had left inside the chassis and looked for a battery to fit it.
It fits!
Putting all this together, slapping on a little bit of python, and I was able to take Wall-E out for a spin.  As one of the new challenges involves 'uneven terrain' I wanted to see how he handled over a non-smooth surface. Turns out he's a little top heavy, but already he's reached the point where he could tackle the manually controlled challenges. (Not necessarily do well, but at least enter), and we can always make improvements.
Going out for a drive.

Leo

Tuesday 12 March 2019

PiWars - Opening up Wall-E and making him move.

With the Wall-E toy selected as my PiWars entry the next step was to open it up and discover how much space I had to work with. Luckily for me Wall-E is relatively easy to dismantle, with no glue or clips locking the chassis into place and most of the screws easily accessible. The exceptions were the four screws on the back, partly covered by the battery compartment and requiring a triangular screw bit to undo, as well as the screws that hold the axles in place.

Triangular screws!
The first time I removed the tracks it was with a lot of physical force, pulling on the tracks hard until they came free. I didn't realise at the time but they only came loose after the plastic gear on the axle had cracked, allowing the axle to move within the gearbox. When I finally tried to work out how to remove the axles properly I turned back to the various Wall-E conversions documented on the internet until I found the answer. The axles are held in place by a screw that is hidden underneath the 'B&L' logo and, armed with this knowledge, it only took a few seconds with a drill to finally uncover and remove them.

Hidden screw!
With the tracks, base and back unscrewed the main body can be pulled up and away. This took a little force the first time, but came away cleanly. The insides have wires running from the top half to the base, so these have to be disconnected to free the two sections. As I didn't know if I'd be needing these connections again in future I tried to unplug them where possible, and if I needed to cut a cable I'd trim it close to the PCB to ensure I had the longest length of wire remaining to work with in future.
Original PCB and green gearbox!
At this stage my focus is in validating that Wall-E could be driven sufficiently well to attempt the challenges, so the section with the arms and head was put to one side for future considerations.

The original Wall-E gearbox uses a single motor that allows it to drive forwards or reverse with a turn. Obviously this limited amount of control is insufficient to get through the PiWars challenges, so that needed to be replaced. Along with the gearbox I also removed the existing PCB as it didn't look very reusable, plus the competition requires a Raspberry Pi to be the brains. The speaker, however, I kept as I wanted Wall-E to be able to talk.

Considering ways of making Wall-E move I wanted to keep the weight low to increase stability, so I tried to find a motor that would fit in the side areas of the base. Hunting around I managed to find such a motor, but just couldn't get the axle and shaft to line up. It took quite a bit of time, and various iterations of potential gearboxes, before I finally came to the conclusion it was a lost cause and switched to mounting the motor directly above the axle.
It fits, but doesn't line up.
It took a bit of hunting around on the internet to find a way of transferring power from the motor shaft to the axle in a compact enough form to fit but eventually, after trying out a variety of gears, I purchased a set of bevel gears off ebay that got the job done. To get them to mesh correctly I designed a gear box in Fusion 360, based on measurements from the original, that I could create on my 3D printer. It took numerous iterations and tweaks but I finally produced a 3D printed gearbox to hold everything in place.

Some of the iterations!
With one gearbox completed and installed it was time to see if  Wall-E would move. Now in theory I could have thrown together a motor driver, RPi Zero and a few lines of python to drive the motor, but it was much quicker, and easier, to just wedge a battery into the base and connect the motor directly to it. So that is what I did, making sure the track was moving freely before placing everything on the floor and watching it spin in circles.


Now that I had proof this was a viable approach I printed out the second gearbox (which ended up requiring some slight modifications, as the base wasn't an exact mirror) and moved on to driving the motors in a more controlled way.

Leo

Wednesday 6 March 2019

PiWars 2019 - An adventure in spaaaaaace!

PiWars 2019, the Raspberry Pi robotics challenge competition, is returning at the end of this month and,  after a years break, I'll be returning as a competitor. Alas I'm a tad behind on my blogging this time around, I did start writing this entry in 2018 but never quite finished it!

Too small!
PiWars 2019 is based around a space theme, to celebrate 50 years of space exploration, and as such I was looking at robot designs that fit into this theme. My initial thoughts were to do another 3D printed robot chassis, this time based around NASA's Lunar Roving Vehicle. But after reviewing images of it, and reading through the manual, I came to the conclusion that the LRV's design is too minimal to successfully incorporate the Raspberry Pi, motor driver and sensors. At least at the scale needed to conform to the competition's size restrictions.


Too large!
My first forays into Raspberry Pi based robots was around modifying toys, and I have built up a collection over the years that I've been planning on converting. Amongst these were a couple that met the space theme criteria.
One was far too long and the other I initially thought was too wide, but, after double checking the rules, I realised that the accepted width is actually slightly larger than an A4 sheet and my choice was made!


Just right!
So for PiWars 2019 I will be converting a Wall-E toy, specifically the 10" U-Command Wall-E, removing the existing electronics and replacing them with a Raspberry Pi, plus any sensors required to complete the courses. A quick search on the internet finds numerous projects that involve modifying this Wall-E toy, which can provide much in the way in inspiration, as well as knowledge on how to open up and dismantle the toy without irreversible damaging it.

The initial list of requirements I came up with are as follows
Built around a Raspberry Pi 3A+.
This provides the built-in WiFi/Bluetooth and CPU power of the 3B, but in a smaller package that will help maximise the available space inside Wall-E.

Minimise external changes to the chassis
Quite a few of the existing Wall-E conversions found online make large, visible changes to the body. Such as cutting away the motor housings to install servos. Ideally I'd like an end result where you have to look closely to spot the modifications

Install a laser ToF sensor
Several challenges require detecting how far away from a wall a robot is. A laser sensor will provide this ability in the smallest package.

Install a Raspberry Pi camera
A number of the autonomous challenges require some level of visual processing. So the installation of a camera is a must. Ideally this will be in Wall-E's head, but failing that on the front of the body.

Install an LCD/OLED to replace the battery usage
Having a UI on the robot is often useful for launching challenge specific scripts and check on his status, without having to carry around a laptop. To keep this in theme I'd want to replace the battery level screen for this. 
The first step is, of course, opening up Wall-E and working out how to fit everything inside. Which I will cover in my next update!.

Leo