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


Very cool! If this works

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

Spot size at 9m

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.