HokuyoAIST  3.0.1
sensor_info.h
Go to the documentation of this file.
1 /* HokuyoAIST
2  *
3  * Header file for the sensor information object.
4  *
5  * Copyright 2008-2011 Geoffrey Biggs geoffrey.biggs@aist.go.jp
6  * RT-Synthesis Research Group
7  * Intelligent Systems Research Institute,
8  * National Institute of Advanced Industrial Science and Technology (AIST),
9  * Japan
10  * All rights reserved.
11  *
12  * This file is part of HokuyoAIST.
13  *
14  * HokuyoAIST is free software; you can redistribute it and/or modify it
15  * under the terms of the GNU Lesser General Public License as published
16  * by the Free Software Foundation; either version 2.1 of the License,
17  * or (at your option) any later version.
18  *
19  * HokuyoAIST is distributed in the hope that it will be useful, but
20  * WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22  * Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public
25  * License along with HokuyoAIST. If not, see
26  * <http://www.gnu.org/licenses/>.
27  */
28 
29 #ifndef SENSOR_INFO_H__
30 #define SENSOR_INFO_H__
31 
32 #if defined(WIN32)
33  typedef unsigned char uint8_t;
34  typedef unsigned int uint32_t;
35  #if defined(HOKUYOAIST_STATIC)
36  #define HOKUYOAIST_EXPORT
37  #elif defined(hokuyoaist_EXPORTS)
38  #define HOKUYOAIST_EXPORT __declspec(dllexport)
39  #else
40  #define HOKUYOAIST_EXPORT __declspec(dllimport)
41  #endif
42 #else
43  #include <stdint.h>
44  #define HOKUYOAIST_EXPORT
45 #endif
46 
47 #include <cstring>
48 #include <string>
49 
54 namespace hokuyoaist
55 {
56 
59 {
60  MODEL_URG04LX, // Classic-URG
61  MODEL_UBG04LXF01, // Rapid-URG
62  MODEL_UHG08LX, // Hi-URG
63  MODEL_UTM30LX, // Top-URG
64  MODEL_UXM30LXE, // Tough-URG
66 };
67 
68 
69 HOKUYOAIST_EXPORT inline char const* model_to_string(LaserModel model)
70 {
71  switch(model)
72  {
73  case MODEL_URG04LX:
74  return "URG-04LX";
75  case MODEL_UBG04LXF01:
76  return "UBG-04LX-F01";
77  case MODEL_UHG08LX:
78  return "UHG-08LX";
79  case MODEL_UTM30LX:
80  return "UTM-30LX";
81  case MODEL_UXM30LXE:
82  return "UXM-30LX-E";
83  default:
84  return "Unknown model";
85  }
86 }
87 
88 
89 HOKUYOAIST_EXPORT inline LaserModel string_to_model(char const* model)
90 {
91  if(strncmp(model, "URG-04LX", 8) == 0)
92  return MODEL_URG04LX;
93  else if(strncmp(model, "UBG-04LX-F01", 8) == 0)
94  return MODEL_UBG04LXF01;
95  else if(strncmp(model, "UHG-08LX", 8) == 0)
96  return MODEL_UHG08LX;
97  else if(strncmp(model, "UTM-30LX", 8) == 0)
98  return MODEL_UTM30LX;
99  else if(strncmp(model, "UXM-30LX-E", 8) == 0)
100  return MODEL_UXM30LXE;
101  else
102  return MODEL_UNKNOWN;
103 }
104 
105 
108 {
111 };
112 
113 
115 {
116  switch(dir)
117  {
118  case CLOCKWISE:
119  return "Clockwise";
120  case COUNTERCLOCKWISE:
121  return "Counter-clockwise";
122  default:
123  return "Unknown";
124  }
125 }
126 
127 
128 // Forward declaration
129 class Sensor;
130 
131 
138 {
139  public:
140  friend class Sensor;
141 
142  SensorInfo();
143  SensorInfo(SensorInfo const& rhs);
144 
146  SensorInfo& operator=(SensorInfo const& rhs);
147 
149  std::string as_string();
150 
151  // Version details.
153  std::string vendor;
155  std::string product;
157  std::string firmware;
159  std::string protocol;
161  std::string serial;
162 
163  // Specification details.
165  std::string model;
167  unsigned int min_range;
169  unsigned int max_range;
171  unsigned int steps;
173  unsigned int first_step;
175  unsigned int last_step;
178  unsigned int front_step;
180  unsigned int standard_speed;
183 
184  // Status details.
186  bool power;
188  unsigned int speed;
190  unsigned short speed_level;
192  std::string measure_state;
194  unsigned int baud;
196  unsigned int time;
198  std::string sensor_diagnostic;
199 
200  // Calculated details
203  double min_angle;
206  double max_angle;
208  double resolution;
212  unsigned int scanable_steps;
214  unsigned int max_step;
217 
218  private:
219  void set_defaults();
220  void calculate_values();
221 }; // class SensorInfo
222 
223 }; // namespace hokuyoaist
224 
227 #endif // SENSOR_INFO_H__
228