LaserScan.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of the Universite de Sherbrooke nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #ifndef CORELIB_INCLUDE_RTABMAP_CORE_LASERSCAN_H_
29 #define CORELIB_INCLUDE_RTABMAP_CORE_LASERSCAN_H_
30 
31 #include "rtabmap/core/RtabmapExp.h" // DLL export/import defines
32 
33 #include <rtabmap/core/Transform.h>
34 
35 namespace rtabmap {
36 
38 {
39 public:
40  enum Format{kUnknown=0,
41  kXY=1,
42  kXYI=2,
43  kXYNormal=3,
44  kXYINormal=4,
45  kXYZ=5,
46  kXYZI=6,
47  kXYZRGB=7,
48  kXYZNormal=8,
49  kXYZINormal=9,
50  kXYZRGBNormal=10};
51 
52  static std::string formatName(const Format & format);
53  static int channels(const Format & format);
54  static bool isScan2d(const Format & format);
55  static bool isScanHasNormals(const Format & format);
56  static bool isScanHasRGB(const Format & format);
57  static bool isScanHasIntensity(const Format & format);
58  static LaserScan backwardCompatibility(
59  const cv::Mat & oldScanFormat,
60  int maxPoints = 0,
61  int maxRange = 0,
62  const Transform & localTransform = Transform::getIdentity());
63  static LaserScan backwardCompatibility(
64  const cv::Mat & oldScanFormat,
65  float minRange,
66  float maxRange,
67  float angleMin,
68  float angleMax,
69  float angleInc,
70  const Transform & localTransform = Transform::getIdentity());
71 
72 public:
73  LaserScan();
74  LaserScan(const cv::Mat & data,
75  int maxPoints,
76  float maxRange,
77  Format format,
78  const Transform & localTransform = Transform::getIdentity());
79  LaserScan(const cv::Mat & data,
80  Format format,
81  float minRange,
82  float maxRange,
83  float angleMin,
84  float angleMax,
85  float angleIncrement,
86  const Transform & localTransform = Transform::getIdentity());
87 
88  const cv::Mat & data() const {return data_;}
89  Format format() const {return format_;}
90  std::string formatName() const {return formatName(format_);}
91  int channels() const {return data_.channels();}
92  int maxPoints() const {return maxPoints_;}
93  float rangeMin() const {return rangeMin_;}
94  float rangeMax() const {return rangeMax_;}
95  float angleMin() const {return angleMin_;}
96  float angleMax() const {return angleMax_;}
97  float angleIncrement() const {return angleIncrement_;}
98  Transform localTransform() const {return localTransform_;}
99 
100  bool empty() const {return data_.empty();}
101  bool isEmpty() const {return data_.empty();}
102  int size() const {return data_.cols;}
103  int dataType() const {return data_.type();}
104  bool is2d() const {return isScan2d(format_);}
105  bool hasNormals() const {return isScanHasNormals(format_);}
106  bool hasRGB() const {return isScanHasRGB(format_);}
107  bool hasIntensity() const {return isScanHasIntensity(format_);}
108  bool isCompressed() const {return !data_.empty() && data_.type()==CV_8UC1;}
109  LaserScan clone() const;
110 
111  int getIntensityOffset() const {return hasIntensity()?(is2d()?2:3):-1;}
112  int getRGBOffset() const {return hasRGB()?(is2d()?2:3):-1;}
113  int getNormalsOffset() const {return hasNormals()?(2 + (is2d()?0:1) + ((hasRGB() || hasIntensity())?1:0)):-1;}
114 
115  void clear() {data_ = cv::Mat();}
116 
117 private:
118  cv::Mat data_;
121  float rangeMin_;
122  float rangeMax_;
123  float angleMin_;
124  float angleMax_;
127 };
128 
129 }
130 
131 #endif /* CORELIB_INCLUDE_RTABMAP_CORE_LASERSCAN_H_ */
float rangeMin() const
Definition: LaserScan.h:93
int dataType() const
Definition: LaserScan.h:103
const cv::Mat & data() const
Definition: LaserScan.h:88
Format format() const
Definition: LaserScan.h:89
bool hasNormals() const
Definition: LaserScan.h:105
bool empty() const
Definition: LaserScan.h:100
int channels() const
Definition: LaserScan.h:91
int getRGBOffset() const
Definition: LaserScan.h:112
static Transform getIdentity()
Definition: Transform.cpp:380
float rangeMax() const
Definition: LaserScan.h:94
bool isEmpty() const
Definition: LaserScan.h:101
bool hasRGB() const
Definition: LaserScan.h:106
int maxPoints() const
Definition: LaserScan.h:92
int getNormalsOffset() const
Definition: LaserScan.h:113
bool is2d() const
Definition: LaserScan.h:104
int size() const
Definition: LaserScan.h:102
#define RTABMAP_EXP
Definition: RtabmapExp.h:38
float angleMin() const
Definition: LaserScan.h:95
bool isCompressed() const
Definition: LaserScan.h:108
float angleMax() const
Definition: LaserScan.h:96
Transform localTransform() const
Definition: LaserScan.h:98
float angleIncrement() const
Definition: LaserScan.h:97
std::string formatName() const
Definition: LaserScan.h:90
int getIntensityOffset() const
Definition: LaserScan.h:111
Transform localTransform_
Definition: LaserScan.h:126
bool hasIntensity() const
Definition: LaserScan.h:107


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Dec 14 2020 03:34:59