New user, first time poster, I received a Sparki for Christmas, and I’ve been hacking away for most of a week.
My first project is a mash-up of object avoidance, random walk, and dead reckoning navigation.
Github source: https://github.com/shypiguy/sparki_explorer/
Place Sparki on a flat floor surrounded by good echo-location obstacles (with New Year’s Eve behind us, I used liquor bottles). Switch to “On” and after boot, Sparki lights the LED green to indicate he is in “atHome” state.
Press “1” on the IR remote, and the LED turns blue to indicate Sparki is in “exploring” state. Sparki repeatedly chooses a random heading in a 140 degree arc ahead of him, evaluates it for obstacles, and if it’s clear travels at that heading for up to 40 cm.
At any time, press “2” on the IR remote - the LED turns red, and Sparki works to return back to the spot where he started by checking if there’s a clear path to his origin, and if not, selecting some random heading and distance to try again.
When Sparki succeeds in finding the origin of his exploration, his LED lights green and he stays put.
At any time, press “3” on the remote to stop Sparki and set his current location as his new “home” or origin.
Things I learned:
[ul][li]The ultrasonic distance sensor reads -1 pretty often, and the program works better when Sparki takes multiple readings in a 20 degree arc and selects the most conservative reading.[/li]
[li]The moveForward(float cm) command is unreliable and will occasionally result in Sparki running off on his path forever, or until he collides with something - I replaced this with stepForward(unsigned long steps) to solve this issue.[/li][/ul]
How to make it fail:
[ul][li]Run it on carpet[/li]
[li]Use obstacles that don’t reflect well, or reflect at an angle[/li]
[li]Use obstacles that are very narrow, extremely low, or don’t present at the height of Sparki’s sensors[/li][/ul]
Cylinders would appear to be the perfect obstacle for Sparki to detect, especially metal cans.