Tuesday 12 March 2019

A Little Hubble Trouble

Once the Pixy 2 camera was fitted I wrote some quick code to implement the Hubble Telescope Nebula Challenge.

I went for a very simple algorithm where the robot looks for the colours, remembers the positions and then attempts to move towards them in the correct order. There's a few backup bits of logic, so if it can't find the next colour after spinning to where it thinks it is it will look for it again.

Using bits of coloured paper in the kitchen We were able to test it out and fix the initial issues. Sometimes it worked - sometimes it didn't. It was difficult to filter out false matches from the background - but in the real test with black walls we were hoping to have less issues.

Also when moving towards the colours, we were using a timing mechanism so that when we reached the zone we reversed for the same time as we moved forward to get back to the centre. This was woefully inaccurate, so we had to come up with a new solution, and decided to use the distance sensors to help out.

Now when the start button is pressed, the robot will record the distance to the wall from the front sensor. Then when it reverses, it uses the front 45 degree mounted sensors to reverse to the same distance. This works extremely well.

Once the code was at least proved, we waited for another trip to Robot Club to try it out on the real thing.

Hubble Telescope Nebula Challenge at Robot Club



Another drive to Cambridge for the last Robot Club before the competition. There were surprisingly few teams there this time - although the Hubble course was a popular testing ground. We waited our turn and callibrated the camera to each of the colours in turn.

By connecting to Sputnik through remote desktop, it allows us to run PixyMon on the robot and see what the camera is seeing  in real time. We can then spin it to each colour and calibrate the signature in turn. The Pixy2 works by teaching it colour signatures and assigning each one to a number. When running, the API will give you a number of 'blocks' which contain the signature number it detects, the height and width, and x and y co-ordinates of where it is. This means it is very easy to write the code to detect each colour.

We put Sputnik in the middle of the course and ran it. Here's the result:


A perfect run first time. Job done we thought.

Unfortunately - that was the only successful run we had all day. On a few occasions it did run almost perfectly - but would miss out the blue zone. I thought of how the code was written and thought this was impossible.

However, looking at it carefully there was a timing issue with the zone detect button we had implemented. When the robot enters a colour zone it will either detect it has reached the zone using the distance sensors - or a button can be pressed to tell it it has reached the zone.

However - on the red zone, I kept forgetting to press the button until it was well into the zone. What was happening was Sputnik had already detected it had reached the zone before I pressed the button. Because of this the flag to say the button had been pressed was not being cleared. So it found the blue zone, started to move towards it but then saw the zone reached button had been pressed, so thought it was already there and moved onto yellow. Watching the video you can hear me explaining how the zone button works - I had no idea it was this that was causing the problem at the time.




But - the most annoying tests were when it just span around in the centre not detecting any colours at all. This is the issue we're yet to get to the bottom of. I suspect it is the parameters we're using to detect it's a real colour zone are too strict and it's missing the real colours.



Also at Robot club, the straight line speed test was not working perfectly. We kept crashing on the last bend. And the maze code was not quite as reliable as it once was - and again we're not sure why. So there's still a lot of work to be done - and not much time - and no more Robot Clubs.




No comments:

Post a Comment