<body bgcolor=#000033"><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener("load", function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <iframe src="http://www.blogger.com/navbar.g?targetBlogID=4830160160028833890&amp;blogName=DanShope.com&amp;publishMode=PUBLISH_MODE_FTP&amp;navbarType=BLUE&amp;layoutType=CLASSIC&amp;homepageUrl=http%3A%2F%2Fwww.danshope.com%2Fblog%2F&amp;blogLocale=en_US&amp;searchRoot=http%3A%2F%2Fblogsearch.google.com%2F" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" height="30px" width="100%" id="navbar-iframe" title="Blogger Navigation and Search"></iframe> <div></div>

Wednesday, June 24, 2009

Sharp IR Rangefinders and Arduino: Make your Robot Smarter

Adding distance or proximity sensors to your robot is a great way to start exploring your environment intelligently. Rangefinders allow a non-contact method of “seeing” obstacles and can be employed in mapping and maze solving as well.

The Sharp family of infrared (IR) rangefinders is very popular amongst hobby roboticists because they are low-cost and easy to interface with (Voltage, Ground, and Signal). These hook up to a single analog input pin on the Arduino or similar microcontroller systems. There are a few caveats to watch out for though.

If your application is very time sensitive and needs tightly controlled, you’ll want to find out how long polling your sensor(s) takes. The Sharp sensors output an analog value (as a voltage), but microcontrollers only understand digital values (1 or 0), so that analog value has to be converted. Analog to digital conversion is pretty fast, but it can introduce some delays.

The sensors are also very noisy, meaning the analog output signal has a lot of "jitter" -- 20cm does not always equal 280, etc. Your code will have to account for this jitter, so you'll need to collect some real-world values to build your sensor model. This problem is exacerbated by the next issue, but can be overcome with a little bit of thought and time. I don't provide you the solution here because it's really dependent on your application. There is, however, a tool to help you evaluate your sensors (see below).

Moving on, take a look at this graph:

You’ll notice something interesting here – the graph has a weird curve and isn’t linear at all. This becomes tricky when trying to teach the robot to understand distance from the analog output of the sensor.

There are a few ways to get around this. If all you want is a simple threshold say “nothing closer than 20cm” then you can simply run a few tests with an object placed 20cm away from the sensor, and then hardcode that value into your program. Generally it’s a bit more complicated, if you want the program to understand varying distance.

Method 1:
Approach: Find a best-fit curve (generally exponential or polynomial) using a statistics package (Excel, R, Minitab)
Pros: Easy to implement, gets you started fast.
Cons: Requires floating point math, which isn’t natively supported by most microcontrollers. You can still use floating point, but it’s slow and inefficient in most cases.

Method 2:
Approach: Gather some data points and create a look up table of values. Your code will linearly interpolate values between each data point (ie, 5cm=600, 10cm=300, etc).
Pros: Uses integer math which is fast and efficient
Cons: Takes up more memory and doesn’t give exact values

Method 2 is the preferred approach as most embedded system developers take great pains to avoid floating point math. You can have some floating point math on the Arduino and be alright. I have a large (6KB) program right now that has floating point littered all over the place (it’s necessary for this code) and execution time runs just fine.

To help with gathering your data for both method 2 and simple thresholding I wrote a quick little application that interfaces with the Arduino’s serial connection. This app will pull your data in and calculate some basic statistics such as standard deviation, mean average, and range of values. You can store the data for future computation and reference.

Download the IRanalzyer at http://www.danshope.com/calton/ir.html

To use the IRanalyzer you need to send values from the Arduino. Here’s a sample sketch to get you started:

#define SerialSpeed 115200 //typical values are 9600 or 115200
#define SampFrequency 10 //sampling frequency in Hz (cycles per second)
#define AnalogPIN 0 //define your pin here

int mDelay;

void setup()
mDelay = 1000/SampFrequency; //calculate delay for proper sampling rate

void loop()
delay(mDelay); //delay in milliseconds
Serial.println( analogRead(AnalogPIN) ); //reads the analog port and prints value over serial

Labels: , , , , , , , , , , , ,

Wednesday, June 3, 2009

Inside the $400 Colony Scout: Robot on a Budget

Now that I posted some videos of the Colony Scout in action, I’ll discuss the platform in a little more detail.

The basics: It’s a compact (4.75”x6”), four wheel-drive robot equipped with an array of IR distance sensors, automatic recharging capability, and other features yet to come. The current talk is to use an ARM7 based board running at 40MHz, paired with an unspecified ATMega for additional I/O.

Some background: The goal of the Colony project at the CMU Robotics Club is to develop a low cost swarm robotics platform capable of structured coordination to carry out tasks too difficult for a single machine.

Colony has been around for several years and has made great strides with a few robot upgrades along the way. The team is prepping the Scout as a potential replacement for the current ATMega 128L based robots.

The goal: The Scout is a deviation from the 2-wheel differential drive robots used in the past. While a common and versatile form factor, the two wheeled platform balked at any non-level terrain. Even driving up ramps or over wires can become an issue. Scout is designed to expand the exploration options beyond level and rectangular environments.

What’s new? Faster processors and an efficient code base will permit the Scout to actively respond to a complex environment. The new sensor array extends the current 5 IR sensors to 7 for additional range and cliff detection. A bump switch returns for the front bumper to detect obstacle collision (useful when purposely pushing objects).

Each of the Pololu wheels comes equipped with a quadrature encoder that gives ~3mm linear accuracy. The 10x12mm micro metal gearmotors are lighter, faster, and stronger than the Solarbotics GM8s on the current robots. Using four motors does draw more current, so the battery is upped from a 6V 2200mAh NiMH pack to a beefy 7.2V 4000mAh Li-Ion pack.

Conclusion: The Colony Scout is a tough little machine that can cross rough terrain while employing a multitude of sensors, all for a sub-$400 cost per robot. Plans are in place to make the robots “smarter” than ever before, and able to respond to the environment faster and in a more coordinated manner.

Summer 2009 is all about prototype testing – learning about the platform and its capabilities and limitations, so stay tuned – More videos and posts will be coming your way!

What do you think? What types of functionality, from line sensing to 3D mapping, do you think a cheap robot should have?

See http://www.danshope.com/blog/2009/05/putting-colony-scout-robot-through-its.html for more pics and vids on the Colony Scout.

Labels: , , , , , , ,

Subscribe to RSS Feed
Subscribe to DanShope.com
Who writes This Stuff?
Daniel Shope is the site owner and moderator of DanShope.com, a portal dedicated to robotics and engineering. Dan is currently a student at Carnegie Mellon University and is pursuing dual degrees in Mechanical and Biomedical engineering.

View Daniel Shope's profile on LinkedIn