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 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 
143  SensorInfo(SensorInfo const& rhs);
144 
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 
hokuyoaist::SensorInfo::min_range
unsigned int min_range
Minimum detectable range (mm).
Definition: sensor_info.h:167
hokuyoaist::SensorInfo::product
std::string product
Product name.
Definition: sensor_info.h:155
hokuyoaist::SensorInfo::measure_state
std::string measure_state
Measurement state.
Definition: sensor_info.h:192
hokuyoaist::SensorInfo::protocol
std::string protocol
Protocol version in use.
Definition: sensor_info.h:159
hokuyoaist::SensorInfo::power
bool power
Operational status - illuminated or not.
Definition: sensor_info.h:186
hokuyoaist::string_to_model
HOKUYOAIST_EXPORT LaserModel string_to_model(char const *model)
Definition: sensor_info.h:89
hokuyoaist::SensorInfo::last_step
unsigned int last_step
Last scanable step of a full scan.
Definition: sensor_info.h:175
hokuyoaist::SensorInfo::as_string
std::string as_string()
Format the entire object into a string.
hokuyoaist::SensorInfo::model
std::string model
Sensor model number.
Definition: sensor_info.h:165
hokuyoaist::MODEL_UHG08LX
@ MODEL_UHG08LX
Definition: sensor_info.h:62
hokuyoaist::SensorInfo::detected_model
LaserModel detected_model
Detected model of the laser.
Definition: sensor_info.h:216
hokuyoaist::RotationDirection
RotationDirection
Sensor direction of rotation.
Definition: sensor_info.h:108
hokuyoaist::SensorInfo::standard_speed
unsigned int standard_speed
Standard motor speed (rpm).
Definition: sensor_info.h:180
hokuyoaist::Sensor
Hokuyo laser scanner class.
Definition: sensor.h:131
hokuyoaist::MODEL_UBG04LXF01
@ MODEL_UBG04LXF01
Definition: sensor_info.h:61
hokuyoaist::CLOCKWISE
@ CLOCKWISE
Definition: sensor_info.h:109
hokuyoaist::SensorInfo::operator=
SensorInfo & operator=(SensorInfo const &rhs)
Assignment operator.
hokuyoaist::SensorInfo::rot_dir
RotationDirection rot_dir
Rotation direction.
Definition: sensor_info.h:182
hokuyoaist::SensorInfo::speed
unsigned int speed
Current motor speed (rpm).
Definition: sensor_info.h:188
hokuyoaist::SensorInfo::baud
unsigned int baud
Baud rate.
Definition: sensor_info.h:194
hokuyoaist::SensorInfo::max_step
unsigned int max_step
Absolute maximum commandable step.
Definition: sensor_info.h:214
hokuyoaist
Definition: hokuyo_errors.h:54
hokuyoaist::MODEL_UXM30LXE
@ MODEL_UXM30LXE
Definition: sensor_info.h:64
hokuyoaist::model_to_string
HOKUYOAIST_EXPORT char const * model_to_string(LaserModel model)
Definition: sensor_info.h:69
HOKUYOAIST_EXPORT
#define HOKUYOAIST_EXPORT
Definition: sensor_info.h:44
hokuyoaist::MODEL_UNKNOWN
@ MODEL_UNKNOWN
Definition: sensor_info.h:65
hokuyoaist::SensorInfo::vendor
std::string vendor
Vendor name.
Definition: sensor_info.h:153
hokuyoaist::SensorInfo::time_resolution
double time_resolution
Time between two scan points (milliseconds).
Definition: sensor_info.h:210
hokuyoaist::SensorInfo::serial
std::string serial
Serial number of this device.
Definition: sensor_info.h:161
hokuyoaist::COUNTERCLOCKWISE
@ COUNTERCLOCKWISE
Definition: sensor_info.h:110
hokuyoaist::SensorInfo::first_step
unsigned int first_step
First scanable step of a full scan.
Definition: sensor_info.h:173
hokuyoaist::SensorInfo::max_range
unsigned int max_range
Maximum detectable range (mm).
Definition: sensor_info.h:169
hokuyoaist::SensorInfo::SensorInfo
SensorInfo(SensorInfo const &rhs)
hokuyoaist::LaserModel
LaserModel
Laser models.
Definition: sensor_info.h:59
hokuyoaist::SensorInfo::steps
unsigned int steps
Number of steps in a 360-degree scan.
Definition: sensor_info.h:171
hokuyoaist::SensorInfo::time
unsigned int time
Current sensor time (s).
Definition: sensor_info.h:196
hokuyoaist::MODEL_URG04LX
@ MODEL_URG04LX
Definition: sensor_info.h:60
hokuyoaist::SensorInfo::firmware
std::string firmware
Firmware version.
Definition: sensor_info.h:157
hokuyoaist::SensorInfo::max_angle
double max_angle
Maximum possible scan angle (radians).
Definition: sensor_info.h:206
hokuyoaist::MODEL_UTM30LX
@ MODEL_UTM30LX
Definition: sensor_info.h:63
hokuyoaist::SensorInfo::SensorInfo
SensorInfo()
hokuyoaist::SensorInfo::scanable_steps
unsigned int scanable_steps
Total number of steps in a full scan (lastStep - firstStep).
Definition: sensor_info.h:212
hokuyoaist::SensorInfo::min_angle
double min_angle
Minimum possible scan angle (radians).
Definition: sensor_info.h:203
hokuyoaist::SensorInfo::speed_level
unsigned short speed_level
Speed level (0 for default)
Definition: sensor_info.h:190
hokuyoaist::SensorInfo
Sensor information.
Definition: sensor_info.h:138
hokuyoaist::rot_dir_to_string
HOKUYOAIST_EXPORT char const * rot_dir_to_string(RotationDirection dir)
Definition: sensor_info.h:114
hokuyoaist::SensorInfo::front_step
unsigned int front_step
Step number that points forward (typically the centre of a full scan).
Definition: sensor_info.h:178
hokuyoaist::SensorInfo::sensor_diagnostic
std::string sensor_diagnostic
Diagnostic status string.
Definition: sensor_info.h:198
hokuyoaist::SensorInfo::resolution
double resolution
Angle between two scan points (radians).
Definition: sensor_info.h:208