HokuyoAIST  3.0.1
scan_data.h
Go to the documentation of this file.
00001 /* HokuyoAIST
00002  *
00003  * Header file for the scan data object.
00004  *
00005  * Copyright 2008-2011 Geoffrey Biggs geoffrey.biggs@aist.go.jp
00006  *     RT-Synthesis Research Group
00007  *     Intelligent Systems Research Institute,
00008  *     National Institute of Advanced Industrial Science and Technology (AIST),
00009  *     Japan
00010  *     All rights reserved.
00011  *
00012  * This file is part of HokuyoAIST.
00013  *
00014  * HokuyoAIST is free software; you can redistribute it and/or modify it
00015  * under the terms of the GNU Lesser General Public License as published
00016  * by the Free Software Foundation; either version 2.1 of the License,
00017  * or (at your option) any later version.
00018  *
00019  * HokuyoAIST is distributed in the hope that it will be useful, but
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00022  * Lesser General Public License for more details.
00023  *
00024  * You should have received a copy of the GNU Lesser General Public
00025  * License along with HokuyoAIST. If not, see
00026  * <http://www.gnu.org/licenses/>.
00027  */
00028 
00029 #ifndef SCAN_DATA_H__
00030 #define SCAN_DATA_H__
00031 
00032 #if defined(WIN32)
00033     typedef unsigned char           uint8_t;
00034     typedef unsigned int            uint32_t;
00035     #if defined(HOKUYOAIST_STATIC)
00036         #define HOKUYOAIST_EXPORT
00037     #elif defined(hokuyoaist_EXPORTS)
00038         #define HOKUYOAIST_EXPORT       __declspec(dllexport)
00039     #else
00040         #define HOKUYOAIST_EXPORT       __declspec(dllimport)
00041     #endif
00042 #else
00043     #include <stdint.h>
00044     #define HOKUYOAIST_EXPORT
00045 #endif
00046 
00047 #include <hokuyoaist/sensor_info.h>
00048 
00049 #include <string>
00050 
00055 namespace hokuyoaist
00056 {
00057 
00058 class Sensor;
00059 
00061 class HOKUYOAIST_EXPORT ScanData
00062 {
00063     public:
00064         friend class Sensor;
00065 
00068         ScanData();
00085         ScanData(uint32_t* const ranges_buffer,
00086                 unsigned int ranges_length,
00087                 uint32_t* const intensities_buffer=0,
00088                 unsigned int intensities_length=0);
00090         ScanData(ScanData const& rhs);
00091         ~ScanData();
00092 
00098         const uint32_t* ranges() const
00099             { return ranges_; }
00101         const uint32_t* intensities() const
00102             { return intensities_; }
00104         unsigned int ranges_length() const { return ranges_length_; }
00106         unsigned int intensities_length() const { return intensities_length_; }
00111         bool get_error_status() const { return error_; }
00114         std::string error_code_to_string(uint32_t error_code);
00118         unsigned int laser_time_stamp() const { return laser_time_; }
00122         unsigned long long system_time_stamp() const { return system_time_; }
00124         LaserModel model() const { return model_; }
00126         bool buffers_provided() const { return buffers_provided_; }
00127 
00136         ScanData& operator=(ScanData const& rhs);
00140         uint32_t operator[](unsigned int index);
00141 
00143         std::string as_string();
00144 
00146         void clean_up();
00147 
00148     protected:
00149         uint32_t* ranges_;
00150         uint32_t* intensities_;
00151         unsigned int ranges_length_;
00152         unsigned int intensities_length_;
00153         bool error_;
00154         unsigned int laser_time_;
00155         unsigned long long system_time_;
00156         LaserModel model_;
00157         bool buffers_provided_;
00158 
00159         void allocate_data(unsigned int length,
00160                 bool include_intensities = false);
00161         void write_range(unsigned int index, uint32_t value);
00162         void write_intensity(unsigned int index, uint32_t value);
00163 }; // class ScanData
00164 
00165 } // namespace hokuyoaist
00166 
00169 #endif // SCAN_DATA_H__
00170