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.

Committer:
jebradshaw
Date:
Fri Mar 04 16:17:36 2016 +0000
Revision:
0:a325ad337940
Example program for interfacing to the Hokuyo URG-04LX lidar (2D range finder)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jebradshaw 0:a325ad337940 1 // J Bradshaw 20160304
jebradshaw 0:a325ad337940 2 #include "mbed.h"
jebradshaw 0:a325ad337940 3
jebradshaw 0:a325ad337940 4 #ifndef HOKUYO_H
jebradshaw 0:a325ad337940 5 #define HOKUYO_H
jebradshaw 0:a325ad337940 6
jebradshaw 0:a325ad337940 7 #define MAXBUFSIZE 1024
jebradshaw 0:a325ad337940 8
jebradshaw 0:a325ad337940 9 /** A Hokuyo Lidar interface */
jebradshaw 0:a325ad337940 10 class Hokuyo {
jebradshaw 0:a325ad337940 11 public:
jebradshaw 0:a325ad337940 12 Hokuyo(PinName tx, PinName rx);
jebradshaw 0:a325ad337940 13
jebradshaw 0:a325ad337940 14 int lidar_read(char *str, int numchars, float timeoutDelay); //serial read function with timout (for large and non ASCII data strings)
jebradshaw 0:a325ad337940 15 int Read_Scan(float scan_deg, int clust_size); //send scan command and read data
jebradshaw 0:a325ad337940 16 int Init(void); //Initialize the Hokuyo lidar
jebradshaw 0:a325ad337940 17
jebradshaw 0:a325ad337940 18 int numPts; //total number of points scanned from Read_Scan function
jebradshaw 0:a325ad337940 19 float angle[MAXBUFSIZE]; //angle array
jebradshaw 0:a325ad337940 20 int dist_mm[MAXBUFSIZE]; //distance array
jebradshaw 0:a325ad337940 21 private:
jebradshaw 0:a325ad337940 22 Serial _hokuyo; //serial port connected to Hokuyo
jebradshaw 0:a325ad337940 23
jebradshaw 0:a325ad337940 24 };
jebradshaw 0:a325ad337940 25
jebradshaw 0:a325ad337940 26 #endif