Class Library for Hokuyo URG-04LX Range Finder (using SCIP1 communication specification)

Dependents:   mbed_Hokuyo_Example

This library interfaces the mbed to the Hokuyo 2D scanning laser range finder. The interface assumes the user has properly level shifted the serial communication lines to TTL (3.3 volt or 5 volt) levels from the Hokuyo URG-04LX RS-232 level UART. It should also be noted that the device requires about an amp of current on startup, then drops to a little less then a half amp when running. A sufficient 5 volt switching supply is my recommended power source. I am currently working on a function to auto detect the baud rate on initialization and change it to 750000. The heart of the library is a serial read function with timeout, which allows for capturing large data strings (non-ASCII or otherwise) of maximum length by using a state machine without having to alter the MODSERIAL library internal buffer sizes.

hokuyo.h

Committer:
jebradshaw
Date:
2016-03-04
Revision:
0:a325ad337940

File content as of revision 0:a325ad337940:

// J Bradshaw 20160304
#include "mbed.h"

#ifndef HOKUYO_H
#define HOKUYO_H

#define MAXBUFSIZE 1024

/**  A Hokuyo Lidar interface */
class Hokuyo {
public:
    Hokuyo(PinName tx, PinName rx);
    
    int lidar_read(char *str, int numchars, float timeoutDelay);    //serial read function with timout (for large and non ASCII data strings)
    int Read_Scan(float scan_deg, int clust_size);                  //send scan command and read data
    int Init(void);                                                 //Initialize the Hokuyo lidar
    
    int numPts;                                                     //total number of points scanned from Read_Scan function
    float angle[MAXBUFSIZE];                                        //angle array
    int dist_mm[MAXBUFSIZE];                                        //distance array
private:
    Serial _hokuyo;                                                 //serial port connected to Hokuyo
    
};

#endif