Hi, folks. I unpacked my new Sparki over the weekend to entertain a loved one who’s been laid up following surgery, and we spent a unch of time experimenting with writing our own wall avoidance and edge finding code from scratch.
Getting the robot up and running was a little bumpy at first – in particular, it’s not always clear when I need to hit reset to get my new code to boot, and sometimes I have to upload the code multiple times before it’ll take. But, minor quirks aside, our experience has been pretty fun overall.
At this point, we’ve got the little robot tooling around the coffee table, steering around soda cans and its own carton, backing up when it gets into corners, as well as stopping before it tips off the edge of the table. So far so good.
However, eventually Sparki runs into my Macbook Air, which, sitting closed on the table, is a couple centimeters high, so it’s low enough that the sonic rangefinder doesn’t see it, but high enough that Sparki won’t drive over it. So the robot sits there, spinning its wheels, thinking it’s moving forward, when in actuality it’s totally stuck.
How can we use the sensors onboard to detect this condition? I thought about using the accelerometer, but it doesn’t seem to provide meaningful values in the Y axis from one moment to the next – which makes sense, because acceleration in the Y axis ought to be nearly zero when moving at a constant velocity or not moving at all.
It seems like a 3-axis gyroscope might be a solution to this problem, but then we’d have to buy an extra board, solder on connectors, use up one or several of the precious analog input pins on the expansion port, and figure out how to mount the gyro board on Sparki’s chassis. Seems like a lot of work. Was there any reason why a gyro wasn’t part of the included kit?
The other idea I had was to use the sonic rangefinder to ping periodically at 0º, apply a smoothing function to the returned range, and , if the robot thinks it’s moving but the range to a dead-ahead obstacle hasn’t changed, then conclude that it’s stuck and act accordingly.
Anyone have any thoughts on this? It seems like the final piece to having a Sparki that will wander contentedly around a office or home, poking into corners and scaring the cat, but otherwise keeping out of trouble.