Let's Make Robots!

Success! OSLRF (LIDAR) successfully Scanning and providing accurate results.


I've been working on getting the OSLRF01 providing Distance readings, using an Arduino Fio, running at 8Mhz.  My objective was to create a library to communicate with the OSLRF and make the interface easier for the end user.

 

After several iterations of my own, I exchanged emails with Tim Eckel, who wrote the NewPing Library, and have successfully created a version that will manage the signals from the OSLRF01.

 

Below are some images of multiple "pings" of the OSLRF sampled through the ADC of the Arduino.

 

 

At first, I had a problem with Ghost images.  This turned out to be a problem with the way I was managing my timers during interrupts.

 

Similarly, once I got a handle on the overall timing structure, I found I was still getting some sporadic samples...  Time to move away from "Arduino Code".  The "price" for digitalRead(PIN) and analogRead(PIN)  is many cycles...  Tim's NewPing code  cured this with converting to bitmasks, and doing bit manipulation of the ports.    Significantly faster....

 

 

 

So now, we have a 100 ADC samples of  41 iterations, all neatly stacked on top of one another. 

 

And here is an image of the "Zero" pulse (The outgoing Laser Pulse) superimposed on the Return Echo "Signal". 

This represents 64 "pings" of 59 ADC samples.   In here you can see I only had two bad samples, which are easy to remove with a median filter.

 

 

Now, using a slightly modified version of the NewPingExample Sketch 

 

// ---------------------------------------------------------------------------
// Example NewPing library sketch that does a ping about 20 times per second.
// ---------------------------------------------------------------------------

#include <NewPing.h>

#define SYNC_PIN  2  // Arduino pin tied to SYNC pin on the OSLRF01 RangeFinder.
#define ZERO_PIN     A1  // Arduino pin tied to Zero pin on the  OSLRF01 RangeFinder.
#define SIGNAL_PIN     A3  // Arduino pin tied to Signal pin on the  OSLRF01 RangeFinder.
#define MAX_DISTANCE 1000 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 900-1000cm.

NewPing oslrf(SYNC_PIN, ZERO_PIN,  SIGNAL_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
unsigned long int syncWidth;                  // Retrieve Sync PulseWidth - used for calculating Timebase
unsigned long int zeroRise;                      //  Retrieve Strating edge of outgoing Laser Pulse - Trigger...

void setup() {
  Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.
  syncWidth = oslrf.sync_width();
  zeroRise = oslrf.zero_rise();
}

void loop() {
  delay(50);                      // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
  unsigned int uS = oslrf.ping(); // Send ping, get ping time in microseconds (uS).
  Serial.print("Ping: ");
  Serial.print(uS / US_ROUNDTRIP_CM); // Convert ping time to distance in cm and print result (0 = outside set distance range)
  Serial.print("cm       "); 

We get the following result...  Very consistent and clean.  

=~=~=~=~=~= PuTTY log 2014.03.09 22:11:53 =~=~=~=~=~=~=~=
Ping: 129cm  
Ping: 82cm     
Ping: 78cm      
Ping: 82cm       
Ping: 82cm      
Ping: 82cm      
Ping: 82cm       
Ping: 82cm       
Ping: 82cm       
Ping: 82cm       
Ping: 82cm       
Ping: 82cm       
Ping: 83cm       
Ping: 82cm       
Ping: 83cm       
Ping: 82cm       
Ping: 82cm       
Ping: 82cm       
Ping: 82cm       
Ping: 82cm       
Ping: 82cm       
Ping: 82cm       
Ping: 82cm       
Ping: 82cm  
Ping: 82cm      
Ping: 82cm       
Ping: 82cm       
Ping: 82cm       
Ping: 82cm       
Ping: 82cm       
Ping: 82cm       
Ping: 83cm       
Ping: 82cm       
Ping: 83cm       
Ping: 82cm       
Ping: 82cm       
Ping: 82cm       
Ping: 82cm       
Ping: 82cm       
Ping: 82cm       
Ping: 82cm       
Ping: 82cm       
Ping: 82cm     

 

Tonight I will take all of my "commentary" out of the Library code, and push it up to Github for anyone else who wants to play with this Wonderful Laser Rangefinder!

 

Did I mention it's only $100USD  !!!

 

 

Next up:   Writing the code to retrieve and display Cartesian Coordinates of echo returns while scanning.

 

Next, Next up:   Re-work all of this to fit on an ATtiny84 so I can finish my daughterboard I2C version....  

 

 

 

 

 

 

 

References:

LightWare Optoelectronics ...

http://forum.arduino.cc/index.php?topic=213774.0

 NewPing Library


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Nice Work with the sensor and the library.  Now I just have to figure out how to fit the extra hardware on my bot!  Sadly I think a redesign will be necessary.  If you ever want to put a melexis thermal array on there, I have some arduino code that works.

Great work.  Thanks for the contribution to help move us all forward.

Cheers,

Martin

You don't want to add one layer higher?  LOL

Yes, for now, I've simply hung the OSLRF out front.. (letsmakerobots.com/node/39791)

Which Melexis Array are you working with?   I actually have a Melexis MLX90620 on it's way...  One thought being that I could use it's data to quickly identify "human body thermal mass" to gross pan the camera towards a person, then OpenCV to find face.  Take some of the work off the Pi.  

 

 

https://github.com/michaeljball/NewPingOSLRF

 

Needs a fair bit of cleaning, but useable...

 

The spot size is approximately 5cm diameter at 9m. The reason why it's approximate is because "white" targets reflect more of the edges of the beam than "black" targets, so the beam appears slightly narrower when measuring to a less reflective surface.

For SLAM applications this equates to an angular resolution of 0.3degrees. It gets interesting when doing both object avoidance and location mapping at the same time. For object avoidance, a wider beam is more likely to hit a narrow obstacle, whilst for mapping a narrower beam gives better resolution. It's an area for further research.

In the next few days we'll put the OSLRF-01 KIT on the lightware.co.za website. This has the PCB and optical pieces but no electronic components. It will sell for US$15.00. With this kit you can play around with the beam divergence and trade off the measuring range against the beam angle.

Very cool!  If this works pretty accurately to even 15-20' and with a relatively narrow beam (the manual says 9m for distance, but can't seem to find any reference to how much spread the laser has), this would make navigation and localization a lot easier.  This is actually affordable and a nice addition to the options available to us hobbyist robot builders.

Regards,

Bill