Caen Community Primary School coding club is full of enthusiastic students – though their ideas vary greatly, they learn to compromise, creating a master plan to win the next competition coming their way!
This year Caen Community Primary School has chosen to enter ‘Pi Wars’ 2018, and has inspired children to put their talent towards a good purpose. Pi wars encourages kids all over the UK to take part in an annual robotics competition. There are plenty of challenges to enter, such as the ‘straight line speed test’ and ‘the obstacle course’. To enter, you must visit the website (Pi Wars) and fill out the application form and, volia! If selected you are officially entered into the competition, taking part in challenges of your choice.
The competition is held in Cambridge, from the 21st-22nd of April, 2018, but I’d begin working on your robot now if I were you!
Club Update #1
This week we decided to test our driving skills. Using an RC Monster Truck we built a track in the playground covered with obstacles. Taking it in turns, we put our driving caps on and timed each other over the course.
There were some pleasant surprise and some really good times.
Club Update #2
If you keep up with our frequent blogs, you’ll know that Caen School is taking part in an annual competition known as – you know this by now – Pi wars! We are so excited to have this opportunity, and to just be a part of this challenge! Now onto last week’s news.
Last week, we had a go at ‘Python’- a programming language, which involves typing certain characters into the computer and creating a set of commands that you could even send to a raspberry pi!
Recently, I’ve had a look at the ‘hints for roboteers’ section on the pi wars page and we found some good tips for anyone taking part in the challenge:
- Start making your robot ASAP! It may be in April next year, but still, the New Year is racing toward us!
- I thought this was brilliant- allow others to drive your robot, they’ll immediately notice any faults in your robot- maybe try with more than one friend
So, we’ll sign off here- we have coding to do- but I’ll keep you updated. Bye!
Club Update #3
Well its been a long time since we did a club update (it’s now March!!). A lot has been happening. The basic chassis of the Robot has been built and we have had a go at driving (and crashing) it. We wrote off a camera in the process of doing some time trials to see who was the best driver. We also now have a Nerf Gun!!
Mr Harvey has split us into sub teams and has had us all working on the different challenge,s to try and come up with our own ideas to tackle some of the problems involved as well as designing various ‘add ons’ for the robot such as a Golf Ball guide and bracket to hold the Nerf Gun.
Club Update #4
We have all been busy working on our individual challenges and this week Mr Harvey got us to summarise what we have been doing. Here some examples.
We started to look at what to build for the competition and for starters decided to go with a couple of chassis designs for initial testing. Firstly a standard perspex chassis / motor kit available from eBay and Amazon. And secondly the CamJam Edukit #3 Robotics kit.
After checking our club funds we decided we had enough money to invest in a more robust and better motors. This would give us an altogether better robotic chassis with which to work. After doing some research we came across the PiBorg web site and on looking at the various robot chassis available we went for the best we could afford – The MonsterBorg. This is a beast of a kit with a aluminium chassis and 4 motors capable of 300 RPM!!
MonsterBorg – The Final Solution
On the 22nd of December the package arrived. As well as the basic chassis we had enough for a few other bits and pieces such as a raspberry Pi 3, Camera, Servo / Sensor Board and a couple of Battery Holders.
To build the MonsterBorg there are some fantastic ready made tutorials on the PiBorg site. First up you need to setup the SD card with all the required software examples. We will of course need to adapt these for our specific robot – more on that later.
The software setup guide is here.
One issue we encountered was that the MonsterBorg examples did not download correctly however that was fixed after asking a question on the MonsterBorg Forums
After successfully installing most of the required software it is time to assemble the chassis. The build guide is here.
After completing the build we were unhappy with the location of some of the components. The default build locates the Raspberry Pi, ThunderBorg Motor Driver Board and batteries on the underside of the robot, this restricts ground clearance under the robot. When in the default build status it is impossible to get at the all but one of the USB ports, this means that plugging in peripherals will be very difficult.
Relocating the Raspberry Pi to the top of the Robot was fairly simple and the ThunderBorg / Battery Lid fitted in place also very simply but after taking it for a test drive the main flaw in this configuration that was notable was that it cannot be driven upside down. It went down a step, flipped onto its top and disconnected the battery pack!! This may cause issues on the obstacle course as it may take the odd tumble.
Here is a pic of the Robot with all of the electronics relocated on top:
in the pic above I had not relocated the camera, with the Pi on top the camera needs to be moved unless you buy a longer cable.
After building the Robot we spotted a major problem. We bought this in haste without considering the size. On checking the rules whilst the length of the Robot is OK, it is too wide!! To resolve this the judges are considering this rule although I don’t want an over wide Robot to jeopardise our chances in any of the challenges (getting stuck etc). We may need to try and fit some narrower wheels / tyres.
In it’s default build state power is supplied by 10 AA batteries, this means that any software amendment / dry testing has to be done on valuable battery power. This became apparent during its first test, I had found that some of the example scripts had not been downloaded and to do so would waste power.
To solve this we posted a question on Twitter and received a reply from the builders. They believed that as long as the battery pack was switched off powering the Pi using a standard Pi mains PSU would be fine. This was also backed up with an answer on the PiBorg forums.
Running on non rechargeable batteries is very wasteful but converting to 10 x rechargeable AA is not cost effective. The choice needed to be a conversion to a suitable LiPo battery. I had a spare 3S 11.1v but to power the motors, servos and sensors it is recommended to increase this to a 4S 14.5v LiPo battery.
Here is a pic with the 11.1v LiPo battery mounted:
Download and flash a 16GB SD Card with the latest Raspbian OS, in our case this was Stretch. Next we setup some of the software needed for the MonsterBorg, namely the software required for the ThunderBorg motor driver board by following the guide on this page. This involves:
- Expanding the filesystem
- Setting up ssh and i2c communications for remote access and the ThunderBorg
- Setting joystick controls
- Setting up the Pi camera and associated software
- OpenCV – we skipped this as we would be following a separate install (may need to come back and run this though)
After installing OpenCV (details later on this page), we installed some of the additional software required by the ThunderBorg motor driver board.
We also needed the Python 3 version of the ThunderBorg.py module, details on where this can be downloaded or installed can be found here.
To help transferring files from our computer to the Raspberry Pi we installed Netatalk.
Before building the robot we had a look at some of the controlling options for the remote controlled challenges. First of all we thought using a ‘hacked’ RC controller from a charity shop. After some testing we found that two sets of connectors output a voltage when the joysticks were moved and thought that it would be easy ish to read these voltages using a Raspberry Pi. After some more research it turned out that reading analogue voltages with a Pi is not easy so looked for other options.
We found out that one of the easiest way would be to use a wireless controller. We ordered a controller from the Pi Hut, which pricewise was great value.
To get it all working we connected the motor controller board from the CamJam EduKit #3 to a Raspberry PiZeroW (That’s the smallest of the Raspberry Pi Models with WiFi and Bluetooth built in). We also connected two DC motors, also in the kit, to the respective connectors on the board as well as 4 x AA batteries using the battery box provided.
We booted up the Pi, switched on the controller and ran the CamJam EduKit controller python program :
sudo python3 camjamedukit3.py
After a brief delay a response was seen in the terminal window to say that the controller was ready and pressing the Left Hand Joystick forward the motors sprang into life. To be honest they were very responsive.
If you have not got any motors yet you can still test the joystick by entering ‘jstest’ in a terminal window.
The MonsterBorg comes with a couple of pre-written python remote control examples. One of these ‘monsterJoy.py’ worked fine with the Pi Hut Wireless Gamepad Controller. The controls take a bit of getting used to and in full speed the torque is a little too much to handle but we can customise the code to suit us.
Better Control Solutions
One problem that we encountered with the PiHut Gamepad Controller was that it intermittently cuts out. We were advised by PiBorg that this could be due to the limited power supplied to the Pi by 5v regulator on the UltraBorg. Anyway, we needed to find a more robust solution, to avoid embarrassment on the day. After doing some more research, we identified two options:
- RC Transmitter / Receiver
The more robust of the two would be a dedicated RC Transmitter / Receiver however interfacing these with the Pi to control the motors fitted to the UltraBorg, whilst not impossible, would take up far too much time as very little information is available on the subject. So we opted in the first instance to investigate BlueTooth.
BlueDot – Bluetooth
After asking the question on various Forums Jon Witts suggested trying out an Android App called BlueDot, written by Martin O’Hanlon.
PS3 – Bluetooth Solution
Duck Shoot – Weapons System
For the Duck Shoot challenge we need to be able to fire a soft projectile, such as a Nerf Dart, so why not add a Nerf Gun. We did some research and at first thought how complicated it would be rigging up servos to pull triggers etc, but then found that Nerf Guns cam with electric firing – Hack On!!!
Somewhere Over The Rainbow
Somewhere over the rainbow requires OpenCV for image recognition. Included on the page where the sample code can be found is a link to a really good guide on how to install it. This is the guide we followed. Be warned, the build of OpenCV is pretty technical and take a good few hours to complete, it is not for the faint hearted. It did not run without error and I had to re-run it a few times to correct (my errors).
Object and colour recognition is some pretty intense stuff and we have never had to tackle anything this complex before. This week (01 March 2018) however we had a breakthrough OpenCV has been installed and after a lot of head scratching and research our Robot can now recognise a Red Ball and stop when it is close. Finding it, let alone the other three coloured balls however is going to be an even bigger problem. Mind mapping and Pseudo Code / Algorithms needed before we start to code this one!!
Bibliography / Reference
MonsterBorg and ThunderBorg Setup
BlueDot Bluetooth App
Google Search For RPi / Arduino / RC Transmitter Receiver
Arduino / RC Receiver
RPi / ATTiny167 / RC Receiver
RPi / RC Receiver Solution Using Pololu RC Switch with Digital Output
Pololu RC Switch – https://www.pololu.com/product/2801
MonsterBorg PS3 Controller Bluetooth Solution
ThunderBorg Python 3
Raspberry Pi Camera Mount
Pan Tilt Mount
GPIO ZERO Robot Scripts
Somewhere Over The Rainbow – Sample Code
OpenCV Install Guide