Sunday, 6 June 2021

Up The Garden Path

So - we've managed to film the 'Up The Garden Path' challenge. It took a couple of days to get a good run which, considering we've never tested this challenge in full before, was quite something. 

Up The Garden Path Course
The course laid out for the first time.


After spending over a week trying to get the 'Tidy The Toys' challenge working before we could film a run, I was very apprehensive about this one.

The approach we're using is line following using the camera with voice commands to help out when we get to a junction. 

Voice Recognition

For voice recognition we are using the "Vosk" application. Neil Stevenson gave an excellent talk on voice recognition at the Pi Wars 2021 Conference and the link on his website meant that setting it up was a breeze. It is fairly accurate - some words are easier to recognise than others - but we could quickly integrate it into the robot code. We did have to include some substitutes - for example for the word 'Left' we also accept 'Let', 'Laugh', 'Yeah' and 'Beth'! 

We would have loved to have spent more time on this - perhaps training it ourselves for more accuracy - but it worked pretty well, and we decided to use the time for other things.  

For the voice input we're using a bluetooth headset. 

When stopped at a junction the robot will respond to the following commands:


Also, at any point when the robot is following the line we can give the command 'Stop' to stop the robot. We use this at the end once we've reached the 'garden shed'. We had planned to use the distance sensor to give us an indication of when we had reached the end, but, as explained below, we had to angle Nanny McPi's nose down which meant that the distance sensing was no longer effective. 

Line Following 


We had already written the code to detect and follow lines, and had tested on some short lines which worked OK but had never setup and attempted to run against the full course. 

The image detection works by converting the camera image to black and white, and then scanning from the bottom up looking for black lines against the white. By scanning at several intervals we can see where they start and what angle they're at. This will return a list of angles in the range -90 to +90 that indicate which direction the robot should turn to follow a particular line. 

Line Detection



The line following code then adjust the speed of the wheels to try and turn to the required direction. 

If we hit a junction, the robot will stop and wait for a voice command, until it gets the 'Go' command and continues following the line. 

So we set up the course and immediately came up against a few issues. The kinks in the line were fine - but when it got to a sharp bend - such as the semi-circular turns, it would either lose the line, or turn far too early and leave the line. This was due to the fact that camera is pointing straight ahead, so the section of line we're looking at is actually quite some way ahead. 

There didn't seem a way of countering this easily in the software, so in the end we decided that we would have to angle the nose of the robot down a little so that the camera is detecting the line much earlier. 

Nanny's Bent Nose
Nanny McPi's Nose Bent A Little Out Of Shape



For the bends we had to put in some code where, if the line is lost completely, it will turn in the direction it last saw the line to try and find it again, but it worked much better and the robot stayed on the lines. Angling the nose did mean that the distance sensor was now useless, but we don't really need it for this challenge. At the end of the challenge we shout 'Stop' to end the challenge. 

The Eyes 


This challenge was where we used Nanny McPi's eyes to their full potential. When line following a single line, the eyes will light up yellow and turn in the direction of the line. If she loses the line, or comes across a junction, the eyes will change to red, and will be crossed to indicate she doesn't know which way to go. 

Nanny McPi Lost
Which Way Now?

After issuing some voice commands, if a single line is detected again the eyes will go back to yellow and face the line it has detected. This gives us a lot of confidence to issue the 'Go' command and get Nanny on her way. 



No comments:

Post a Comment