HokuyoAIST
3.0.1
|
00001 /* HokuyoAIST 00002 * 00003 * Header file for the sensor information object. 00004 * 00005 * Copyright 2008-2011 Geoffrey Biggs geoffrey.biggs@aist.go.jp 00006 * RT-Synthesis Research Group 00007 * Intelligent Systems Research Institute, 00008 * National Institute of Advanced Industrial Science and Technology (AIST), 00009 * Japan 00010 * All rights reserved. 00011 * 00012 * This file is part of HokuyoAIST. 00013 * 00014 * HokuyoAIST is free software; you can redistribute it and/or modify it 00015 * under the terms of the GNU Lesser General Public License as published 00016 * by the Free Software Foundation; either version 2.1 of the License, 00017 * or (at your option) any later version. 00018 * 00019 * HokuyoAIST is distributed in the hope that it will be useful, but 00020 * WITHOUT ANY WARRANTY; without even the implied warranty of 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00022 * Lesser General Public License for more details. 00023 * 00024 * You should have received a copy of the GNU Lesser General Public 00025 * License along with HokuyoAIST. If not, see 00026 * <http://www.gnu.org/licenses/>. 00027 */ 00028 00029 #ifndef SENSOR_INFO_H__ 00030 #define SENSOR_INFO_H__ 00031 00032 #if defined(WIN32) 00033 typedef unsigned char uint8_t; 00034 typedef unsigned int uint32_t; 00035 #if defined(HOKUYOAIST_STATIC) 00036 #define HOKUYOAIST_EXPORT 00037 #elif defined(hokuyoaist_EXPORTS) 00038 #define HOKUYOAIST_EXPORT __declspec(dllexport) 00039 #else 00040 #define HOKUYOAIST_EXPORT __declspec(dllimport) 00041 #endif 00042 #else 00043 #include <stdint.h> 00044 #define HOKUYOAIST_EXPORT 00045 #endif 00046 00047 #include <cstring> 00048 #include <string> 00049 00054 namespace hokuyoaist 00055 { 00056 00058 enum LaserModel 00059 { 00060 MODEL_URG04LX, // Classic-URG 00061 MODEL_UBG04LXF01, // Rapid-URG 00062 MODEL_UHG08LX, // Hi-URG 00063 MODEL_UTM30LX, // Top-URG 00064 MODEL_UXM30LXE, // Tough-URG 00065 MODEL_UNKNOWN 00066 }; 00067 00068 00069 HOKUYOAIST_EXPORT inline char const* model_to_string(LaserModel model) 00070 { 00071 switch(model) 00072 { 00073 case MODEL_URG04LX: 00074 return "URG-04LX"; 00075 case MODEL_UBG04LXF01: 00076 return "UBG-04LX-F01"; 00077 case MODEL_UHG08LX: 00078 return "UHG-08LX"; 00079 case MODEL_UTM30LX: 00080 return "UTM-30LX"; 00081 case MODEL_UXM30LXE: 00082 return "UXM-30LX-E"; 00083 default: 00084 return "Unknown model"; 00085 } 00086 } 00087 00088 00089 HOKUYOAIST_EXPORT inline LaserModel string_to_model(char const* model) 00090 { 00091 if(strncmp(model, "URG-04LX", 8) == 0) 00092 return MODEL_URG04LX; 00093 else if(strncmp(model, "UBG-04LX-F01", 8) == 0) 00094 return MODEL_UBG04LXF01; 00095 else if(strncmp(model, "UHG-08LX", 8) == 0) 00096 return MODEL_UHG08LX; 00097 else if(strncmp(model, "UTM-30LX", 8) == 0) 00098 return MODEL_UTM30LX; 00099 else if(strncmp(model, "UXM-30LX-E", 8) == 0) 00100 return MODEL_UXM30LXE; 00101 else 00102 return MODEL_UNKNOWN; 00103 } 00104 00105 00107 enum RotationDirection 00108 { 00109 CLOCKWISE, 00110 COUNTERCLOCKWISE 00111 }; 00112 00113 00114 HOKUYOAIST_EXPORT inline char const* rot_dir_to_string(RotationDirection dir) 00115 { 00116 switch(dir) 00117 { 00118 case CLOCKWISE: 00119 return "Clockwise"; 00120 case COUNTERCLOCKWISE: 00121 return "Counter-clockwise"; 00122 default: 00123 return "Unknown"; 00124 } 00125 } 00126 00127 00128 // Forward declaration 00129 class Sensor; 00130 00131 00137 class HOKUYOAIST_EXPORT SensorInfo 00138 { 00139 public: 00140 friend class Sensor; 00141 00142 SensorInfo(); 00143 SensorInfo(SensorInfo const& rhs); 00144 00146 SensorInfo& operator=(SensorInfo const& rhs); 00147 00149 std::string as_string(); 00150 00151 // Version details. 00153 std::string vendor; 00155 std::string product; 00157 std::string firmware; 00159 std::string protocol; 00161 std::string serial; 00162 00163 // Specification details. 00165 std::string model; 00167 unsigned int min_range; 00169 unsigned int max_range; 00171 unsigned int steps; 00173 unsigned int first_step; 00175 unsigned int last_step; 00178 unsigned int front_step; 00180 unsigned int standard_speed; 00182 RotationDirection rot_dir; 00183 00184 // Status details. 00186 bool power; 00188 unsigned int speed; 00190 unsigned short speed_level; 00192 std::string measure_state; 00194 unsigned int baud; 00196 unsigned int time; 00198 std::string sensor_diagnostic; 00199 00200 // Calculated details 00203 double min_angle; 00206 double max_angle; 00208 double resolution; 00210 double time_resolution; 00212 unsigned int scanable_steps; 00214 unsigned int max_step; 00216 LaserModel detected_model; 00217 00218 private: 00219 void set_defaults(); 00220 void calculate_values(); 00221 }; // class SensorInfo 00222 00223 }; // namespace hokuyoaist 00224 00227 #endif // SENSOR_INFO_H__ 00228