INTRODUCTION Overview Download and Install Documentation Publications REPOSITORY Libraries DEVELOPER Dev Guide Dashboard PEOPLE Contributors Users Project Download Mailing lists
|
urg_nz.h00001 /* 00002 * Hokuyo URG laser scanner driver class. 00003 * Originally written by Toby Collett for the Player project. 00004 */ 00005 00006 #include <stdio.h> 00007 #include <inttypes.h> 00008 00009 #include <string> 00010 00015 namespace urg_nz 00016 { 00017 00019 const unsigned int MAX_READINGS = 769; 00021 const unsigned int URG_ERR_READPOLL = 0; 00023 const unsigned int URG_ERR_READTIMEOUT = 1; 00025 const unsigned int URG_ERR_READ = 2; 00027 const unsigned int URG_ERR_PROTOCOL = 3; 00029 const unsigned int URG_ERR_CHANGEBAUD = 4; 00031 const unsigned int URG_WARN_CHANGEBAUD = 5; 00033 const unsigned int URG_ERR_BADBAUDRATE = 6; 00035 const unsigned int URG_ERR_OPEN_FAILED = 7; 00037 const unsigned int URG_ERR_CONNECT_FAILED = 8; 00039 const unsigned int URG_ERR_CLOSE_FAILED = 9; 00041 const unsigned int URG_ERR_NODESTINATION = 10; 00043 const unsigned int URG_ERR_NOPORT = 11; 00045 const unsigned int URG_ERR_BADFIRMWARE = 12; 00047 const unsigned int URG_ERR_SCIPVERSION = 13; 00049 const unsigned int URG_ERR_LASERERROR = 14; 00050 00052 typedef struct urg_nz_laser_readings 00053 { 00056 unsigned short Readings[MAX_READINGS]; 00057 } urg_nz_laser_readings_t; 00058 00060 typedef struct urg_nz_laser_config 00061 { 00063 float min_angle; 00065 float max_angle; 00067 float resolution; 00069 float max_range; 00070 } urg_nz_laser_config_t; 00071 00073 class urg_nz_exception 00074 { 00075 public: 00080 urg_nz_exception (unsigned int code, std::string desc) 00081 : error_code (code), error_desc (desc) 00082 {} 00083 00085 unsigned int error_code; 00087 std::string error_desc; 00088 }; 00089 00098 class urg_laser 00099 { 00100 public: 00102 urg_laser (void); 00103 00105 ~urg_laser (void); 00106 00114 int ReadUntil (int fd, unsigned char *buf, int len, int timeout); 00115 00122 int ReadUntil_nthOccurence (int file, int n, char c); 00123 00132 void Open (const char *port_name, bool use_serial, int baud); 00133 00135 void Close (void); 00136 00140 bool PortOpen (void); 00141 00151 int ChangeBaud (int curr_baud, int new_baud); 00152 00162 void SetTimeOut (int timeout) { poll_timeout = timeout; } 00163 00176 unsigned int GetReadings (urg_nz_laser_readings_t *readings, unsigned int min_i = 0, unsigned int max_i = MAX_READINGS); 00177 00181 int GetIDInfo (void); 00182 00186 void GetSensorConfig (urg_nz_laser_config_t *cfg); 00187 00194 int GetSCIPVersion (void); 00195 00199 void SetVerbose (bool verbose_mode) { verbose = verbose_mode; } 00200 private: 00202 int SCIP_Version; 00203 00205 FILE *laser_port; 00206 00208 bool verbose; 00209 00211 int poll_timeout; 00212 }; 00213 00214 }; // namespace urg_nz 00215 |