IRDAR- Infrared Detection and Ranging with the Raspberry Pi

Having figured out how to set the angle of a servo, I was ready to start working on the next mini-porject: the IRDAR. IRDAR stands for InfraRed Detection And Ranging, and is similar in concept to RADAR (RAdio Detection And Ranging). The basic idea is simple: Mount an IR distance sensor to a servo, then continuously move the sensor back and forth while getting distance measurements. The end result is that I will be able to detect objects, and determine how far away they are.

While a similar device could be created using an acoustic sensor, I decided to use an IR sensor for a few reasons:

  • IR sensors supposedly have a narrower beam than sonar sensors
  • IR sensors are a bit cheaper than sonar sensors (~$15 vs $25+)
  • IR travels faster than sound! (more on this later)

The basic setup is quite simple. For the IR sensor, I replicated the setup described in Jeremy Blythe’s blog post. You just need a Sharp IR sensor (model GP2Y0A02YK) and a MCP3008 chip, and he has another post describing how to hook up the MCP3008 to the Raspberry Pi. He also has some code on his GitHub for reading values from the chip and calculating distances, but the code I wanted was combined with some code I didn’t want, so I refactored the code to get a function that just returns the distance. Once I confirmed that the IR sensor was working and the code was returning sensible values, I taped the sensor onto a servo.

The last step was to write some more code to continuously move the servo, record the distance, and repeat (the code is on GitHub). To show what the IRDAR was seeing, the program prints out a crude text-based visualization to the console. The image below is a screen shot of the text output. The vertical axis is the angle, and the horizontal axis is the distance. In this image, you can see 3 objects being picked up by the IRDAR; 2 of them at about 20cm away, and another at about 60cm. The IRDAR code also stores historical data, and in the screen shot below, the ‘@’ symbols show readings from the most recent scan, while the ‘#’ symbols show readings from the scan before that. In the video, you can see how displaying historical data can sort of visualize movement as well.

Screen Shot 2013-09-13 at 1.37.03 AM

While the early results are promising, there’s more work to be done before it’s really usable. In the video, I have the IRDAR scanning at full speed, and I found that there are significant problems with accuracy when it’s moving that fast. On the other hand, scanning slowly makes it less useful in tracking objects that move. In the next post, I’ll talk about strategies to address these issues.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s