HokuyoAIST  3.0.2
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 INCLUDE_HOKUYOAIST_SENSOR_INFO_H__
30 #define INCLUDE_HOKUYOAIST_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 
58 {
59  MODEL_URG04LX, // Classic-URG
60  MODEL_UBG04LXF01, // Rapid-URG
61  MODEL_UHG08LX, // Hi-URG
62  MODEL_UTM30LX, // Top-URG
63  MODEL_UXM30LXE, // Tough-URG
65 };
66 
67 
68 HOKUYOAIST_EXPORT inline char const* model_to_string(LaserModel model)
69 {
70  switch (model) {
71  case MODEL_URG04LX:
72  return "URG-04LX";
73  case MODEL_UBG04LXF01:
74  return "UBG-04LX-F01";
75  case MODEL_UHG08LX:
76  return "UHG-08LX";
77  case MODEL_UTM30LX:
78  return "UTM-30LX";
79  case MODEL_UXM30LXE:
80  return "UXM-30LX-E";
81  default:
82  return "Unknown model";
83  }
84 }
85 
86 
87 HOKUYOAIST_EXPORT inline LaserModel string_to_model(char const* model)
88 {
89  if (strncmp(model, "URG-05LX", 8) == 0) {
90  return MODEL_URG04LX;
91  } else if (strncmp(model, "UBG-04LX-F01", 8) == 0) {
92  return MODEL_UBG04LXF01;
93  } else if (strncmp(model, "UHG-08LX", 8) == 0) {
94  return MODEL_UHG08LX;
95  } else if (strncmp(model, "UTM-30LX", 8) == 0) {
96  return MODEL_UTM30LX;
97  } else if (strncmp(model, "UXM-30LX-E", 8) == 0) {
98  return MODEL_UXM30LXE;
99  } else {
100  return MODEL_UNKNOWN;
101  }
102 }
103 
104 
107 {
110 };
111 
112 
114 {
115  switch (dir) {
116  case CLOCKWISE:
117  return "Clockwise";
118  case COUNTERCLOCKWISE:
119  return "Counter-clockwise";
120  default:
121  return "Unknown";
122  }
123 }
124 
125 
126 // Forward declaration
127 class Sensor;
128 
129 
136 {
137  public:
138  friend class Sensor;
139 
140  SensorInfo();
141  SensorInfo(SensorInfo const& rhs);
142 
144  SensorInfo& operator=(SensorInfo const& rhs);
145 
147  std::string as_string();
148 
149  // Version details.
151  std::string vendor;
153  std::string product;
155  std::string firmware;
157  std::string protocol;
159  std::string serial;
160 
161  // Specification details.
163  std::string model;
165  unsigned int min_range;
167  unsigned int max_range;
169  unsigned int steps;
171  unsigned int first_step;
173  unsigned int last_step;
176  unsigned int front_step;
178  unsigned int standard_speed;
181 
182  // Status details.
184  bool power;
186  unsigned int speed;
188  unsigned short speed_level;
190  std::string measure_state;
192  unsigned int baud;
194  unsigned int time;
196  std::string sensor_diagnostic;
197 
198  // Calculated details
201  double min_angle;
204  double max_angle;
206  double resolution;
210  unsigned int scanable_steps;
212  unsigned int max_step;
215 
216  private:
217  void set_defaults();
218  void calculate_values();
219 }; // class SensorInfo
220 
221 }; // namespace hokuyoaist
222 
225 #endif // INCLUDE_HOKUYOAIST_SENSOR_INFO_H__
unsigned int scanable_steps
Total number of steps in a full scan (lastStep - firstStep).
Definition: sensor_info.h:210
HOKUYOAIST_EXPORT char const * rot_dir_to_string(RotationDirection dir)
Definition: sensor_info.h:113
double max_angle
Maximum possible scan angle (radians).
Definition: sensor_info.h:204
std::string model
Sensor model number.
Definition: sensor_info.h:163
std::string serial
Serial number of this device.
Definition: sensor_info.h:159
HOKUYOAIST_EXPORT LaserModel string_to_model(char const *model)
Definition: sensor_info.h:87
HOKUYOAIST_EXPORT char const * model_to_string(LaserModel model)
Definition: sensor_info.h:68
std::string measure_state
Measurement state.
Definition: sensor_info.h:190
unsigned int time
Current sensor time (s).
Definition: sensor_info.h:194
LaserModel detected_model
Detected model of the laser.
Definition: sensor_info.h:214
unsigned int front_step
Step number that points forward (typically the centre of a full scan).
Definition: sensor_info.h:176
unsigned int speed
Current motor speed (rpm).
Definition: sensor_info.h:186
Hokuyo laser scanner class.
Definition: sensor.h:127
Sensor information.
Definition: sensor_info.h:135
unsigned int last_step
Last scanable step of a full scan.
Definition: sensor_info.h:173
double time_resolution
Time between two scan points (milliseconds).
Definition: sensor_info.h:208
unsigned int first_step
First scanable step of a full scan.
Definition: sensor_info.h:171
std::string product
Product name.
Definition: sensor_info.h:153
unsigned int standard_speed
Standard motor speed (rpm).
Definition: sensor_info.h:178
std::string firmware
Firmware version.
Definition: sensor_info.h:155
unsigned int max_step
Absolute maximum commandable step.
Definition: sensor_info.h:212
double resolution
Angle between two scan points (radians).
Definition: sensor_info.h:206
std::string vendor
Vendor name.
Definition: sensor_info.h:151
unsigned short speed_level
Speed level (0 for default)
Definition: sensor_info.h:188
unsigned int min_range
Minimum detectable range (mm).
Definition: sensor_info.h:165
std::string sensor_diagnostic
Diagnostic status string.
Definition: sensor_info.h:196
std::string protocol
Protocol version in use.
Definition: sensor_info.h:157
LaserModel
Laser models.
Definition: sensor_info.h:57
#define HOKUYOAIST_EXPORT
Definition: sensor_info.h:44
double min_angle
Minimum possible scan angle (radians).
Definition: sensor_info.h:201
bool power
Operational status - illuminated or not.
Definition: sensor_info.h:184
RotationDirection rot_dir
Rotation direction.
Definition: sensor_info.h:180
unsigned int max_range
Maximum detectable range (mm).
Definition: sensor_info.h:167
RotationDirection
Sensor direction of rotation.
Definition: sensor_info.h:106
unsigned int steps
Number of steps in a 360-degree scan.
Definition: sensor_info.h:169
unsigned int baud
Baud rate.
Definition: sensor_info.h:192