HokuyoAIST  3.0.2
scan_data.h
Go to the documentation of this file.
1 /* HokuyoAIST
2  *
3  * Header file for the scan data 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_SCAN_DATA_H__
30 #define INCLUDE_HOKUYOAIST_SCAN_DATA_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 <hokuyoaist/sensor_info.h>
48 
49 #include <string>
50 
55 namespace hokuyoaist {
56 
57 class Sensor;
58 
61 {
62  public:
63  friend class Sensor;
64 
67  ScanData();
84  ScanData(
85  uint32_t* const ranges_buffer,
86  unsigned int ranges_length,
87  uint32_t* const intensities_buffer = 0,
88  unsigned int intensities_length = 0);
90  ScanData(ScanData const& rhs);
91  ~ScanData();
92 
98  const uint32_t* ranges() const
99  { return ranges_; }
101  const uint32_t* intensities() const
102  { return intensities_; }
104  unsigned int ranges_length() const { return ranges_length_; }
106  unsigned int intensities_length() const { return intensities_length_; }
111  bool get_error_status() const { return error_; }
114  std::string error_code_to_string(uint32_t error_code);
118  unsigned int laser_time_stamp() const { return laser_time_; }
122  unsigned long long system_time_stamp() const { return system_time_; }
124  LaserModel model() const { return model_; }
126  bool buffers_provided() const { return buffers_provided_; }
127 
136  ScanData& operator=(ScanData const& rhs);
140  uint32_t operator[](unsigned int index);
141 
143  std::string as_string();
144 
146  void clean_up();
147 
148  protected:
149  uint32_t* ranges_;
150  uint32_t* intensities_;
151  unsigned int ranges_length_;
152  unsigned int intensities_length_;
153  bool error_;
154  unsigned int laser_time_;
155  unsigned long long system_time_;
158 
159  void allocate_data(unsigned int length,
160  bool include_intensities = false);
161  void write_range(unsigned int index, uint32_t value);
162  void write_intensity(unsigned int index, uint32_t value);
163 }; // class ScanData
164 
165 } // namespace hokuyoaist
166 
169 #endif // INCLUDE_HOKUYOAIST_SCAN_DATA_H__
unsigned int intensities_length() const
Get the number of intensity samples in the data.
Definition: scan_data.h:106
unsigned int intensities_length_
Definition: scan_data.h:152
LaserModel model_
Definition: scan_data.h:156
const uint32_t * intensities() const
Return a pointer to an array of intensity readings.
Definition: scan_data.h:101
unsigned int laser_time_stamp() const
Get the raw time stamp of the data in milliseconds.
Definition: scan_data.h:118
LaserModel model() const
Get the model of the laser that produced this scan.
Definition: scan_data.h:124
uint32_t * intensities_
Definition: scan_data.h:150
Structure to store data returned from the laser scanner.
Definition: scan_data.h:60
unsigned int laser_time_
Definition: scan_data.h:154
Hokuyo laser scanner class.
Definition: sensor.h:127
unsigned long long system_time_
Definition: scan_data.h:155
unsigned long long system_time_stamp() const
Get the system time stamp of the data in milliseconds.
Definition: scan_data.h:122
bool get_error_status() const
Indicates if one or more steps had an error.
Definition: scan_data.h:111
bool buffers_provided() const
Check if the buffers are being provided instead of automatic.
Definition: scan_data.h:126
const uint32_t * ranges() const
Return a pointer to array of range readings in millimetres.
Definition: scan_data.h:98
uint32_t * ranges_
Definition: scan_data.h:149
unsigned int ranges_length_
Definition: scan_data.h:151
LaserModel
Laser models.
Definition: sensor_info.h:57
unsigned int ranges_length() const
Get the number of range samples in the data.
Definition: scan_data.h:104
#define HOKUYOAIST_EXPORT
Definition: scan_data.h:44