The Pesky Hump

Recently I set about testing the line following code for Firefly in preparation for Lava Palava. 

First off, I reviewed the line-follower code I had written for the 2022 games.  I decided that the code was overly complicated since it can detect junctions and accept voice input directions.  So, I reinstated the code I had from 2020.  I tested this on a flat course, and it worked adequately.

I then constructed a hump (well two actually, because the first was too high for the robot!) and re-tested.  I ran into some problems.

The hump triggers the front range finder

The old code drives until the front facing time-of-flight (ToF) sensor detects an obstacle, and the hump is sufficient to trigger the sensor.  I left the front ToF sensor running, but with a very close trigger; this will hopefully still cut in just before the robot collides with anything but shouldn’t be triggered by the hump.

Robot loses line over hump brow

As might be expected, the robot loses sight of the line briefly as it goes over the brow of the speed bump.  The original code stops the robot if the line is lost, so I adjusted it to keep driving with constant heading in this case.  This worked to the extent that the robot continued to move, but it wasn’t uncommon during testing for the robot to deviate from course and loose the line.  It turns out that the robot was following false targets that were beyond the arena, targets that should have been out of view.

Gaze is lowered over the hill

The base code (the bit that’s common across all games) includes code to disregard the top section of the video feed from the front camera on the robot.  This top “crop” is set so that the robot ignores things beyond the edge of the arena.  There is a similar crop at the bottom of the image too.  The trouble is, this code is useless if the robot hull is pitched up (as happens on the speed bump).

Firefly has an IMU that is mainly used to calibrate turns, but it also reports pitch and roll too.  I added code to lower the crop edges when the robot pitches up.  In effect, the robot lowers it’s gaze as it drives up the side of the hump then raises it’s gaze as it drives down the other side.  The robot is no longer distracted by things above the arena and is more reliable as a result.  You can see this in action in the video below.  The two white horizontal lines show the top and bottom crops in the video stream; see how they adjust as the robot traverses the hump.

Gaze adjusts over the hump

Leave a comment