15 September 2008

Orangutan - Sonar Struggles

I admit. My AI skills are lacking in both skill and quality. My attempt to make a ex-RC car into the super Hummer-bot has been less than successful (so far). After frickin' amazing success on the first fews days of using the shiny new LV168 Orangutan Robot Controller, I've come back to Earth and have been struggling.

My bot is a cyclops with a single sonar range finder mounted on front. I'm doing a very simple algorithm that drives straight until it detects an object closer than 24". It slows and does a random 15 degree turn to either right or left. If the object is still closer than 24", it continues to turn in the same direction. If the coast is clear, the wheels straighten and speed increases. Pretty simple. In mostly open areas, it works well. In my hallway, it's a deathtrap. Hummer-bot gets caught on the first or second corner and the car absolutely flips out, spinning wheels and turning back and forth until I rescue it.

For the first few days, the Sonar Range Finder appeared to work spot on. Now it needs a dog and a cane 'cause the damn thing can't see anything. Could be due to Hummer-bot smashing into the wall repeatedly during a spastic frenzy of very un-AI behaviour. My sonar acts either completely dead or randomly sends wild readings.

This is a code snip of the Analog-to-Digital Conversion (ADC) code for reading the sonar. I tried for an hour to setup the Google Syntax Highlighter so that the code would look pretty but I failed. Instead you get a screenshot.

As you see, the sonar reading code is simple. Most of it (all?) is stolen re-used from LV168 resources that are available on Pololu's great project pages.

The Maxbotix LV-MaxSonar- EZ1 Sonar Range Finder detects objects from 0 – 254 inches (6.45 meters) with 1-inch resolution for distances greater than 6 inches. My finder suddenly seems to only see objects in a 6-12 inch range and very sporadically.

I've tried different analog pins with the same results so I'm suspecting I have a damaged device. They're fairly cheap at $25 but I hate to buy the same thing. I may need a new shiny.

No comments: