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 SCAN_DATA_H__
30#define 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
48
49#include <string>
50
54
55namespace hokuyoaist
56{
57
58class Sensor;
59
62{
63 public:
64 friend class Sensor;
65
85 ScanData(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);
92
98 const uint32_t* ranges() const
99 { return ranges_; }
100
101 const uint32_t* intensities() const
102 { return intensities_; }
103
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
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_;
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
168
169#endif // SCAN_DATA_H__
170
unsigned long long system_time_
Definition scan_data.h:155
std::string error_code_to_string(uint32_t error_code)
Return a string representing the error for the given error code.
ScanData & operator=(ScanData const &rhs)
Assignment operator.
uint32_t * intensities_
Definition scan_data.h:150
const uint32_t * ranges() const
Return a pointer to array of range readings in millimetres.
Definition scan_data.h:98
unsigned int laser_time_stamp() const
Get the raw time stamp of the data in milliseconds.
Definition scan_data.h:118
ScanData(ScanData const &rhs)
This copy constructor performs a deep copy of present data.
unsigned int intensities_length() const
Get the number of intensity samples in the data.
Definition scan_data.h:106
void write_intensity(unsigned int index, uint32_t value)
void write_range(unsigned int index, uint32_t value)
LaserModel model() const
Get the model of the laser that produced this scan.
Definition scan_data.h:124
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
ScanData(uint32_t *const ranges_buffer, unsigned int ranges_length, uint32_t *const intensities_buffer=0, unsigned int intensities_length=0)
This constructor uses a provided data buffer rather than allocating automatically.
void clean_up()
Force the data to clean up.
const uint32_t * intensities() const
Return a pointer to an array of intensity readings.
Definition scan_data.h:101
unsigned int intensities_length_
Definition scan_data.h:152
std::string as_string()
Format the entire object into a string.
uint32_t operator[](unsigned int index)
Subscript operator.
unsigned int laser_time_
Definition scan_data.h:154
unsigned int ranges_length() const
Get the number of range samples in the data.
Definition scan_data.h:104
void allocate_data(unsigned int length, bool include_intensities=false)
friend class Sensor
Definition scan_data.h:64
unsigned int ranges_length_
Definition scan_data.h:151
unsigned long long system_time_stamp() const
Get the system time stamp of the data in milliseconds.
Definition scan_data.h:122
ScanData()
This constructor creates an empty ScanData with no data currently allocated.
#define HOKUYOAIST_EXPORT
LaserModel
Laser models.
Definition sensor_info.h:59