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 LaserScan & data,
75  int maxPoints,
76  float maxRange,
77  const Transform & localTransform = Transform::getIdentity());
79  int maxPoints,
80  float maxRange,
81  Format format,
82  const Transform & localTransform = Transform::getIdentity()), "Use version without \"format\" argument.");
83  LaserScan(const cv::Mat & data,
84  int maxPoints,
85  float maxRange,
86  Format format,
87  const Transform & localTransform = Transform::getIdentity());
89  Format format,
90  float minRange,
91  float maxRange,
92  float angleMin,
93  float angleMax,
94  float angleIncrement,
95  const Transform & localTransform = Transform::getIdentity()), "Use version without \"format\" argument.");
96  LaserScan(const LaserScan & data,
97  float minRange,
98  float maxRange,
99  float angleMin,
100  float angleMax,
101  float angleIncrement,
102  const Transform & localTransform = Transform::getIdentity());
103  LaserScan(const cv::Mat & data,
104  Format format,
105  float minRange,
106  float maxRange,
107  float angleMin,
108  float angleMax,
109  float angleIncrement,
110  const Transform & localTransform = Transform::getIdentity());
111 
112  const cv::Mat & data() const {return data_;}
113  Format format() const {return format_;}
114  std::string formatName() const {return formatName(format_);}
115  int channels() const {return data_.channels();}
116  int maxPoints() const {return maxPoints_;}
117  float rangeMin() const {return rangeMin_;}
118  float rangeMax() const {return rangeMax_;}
119  float angleMin() const {return angleMin_;}
120  float angleMax() const {return angleMax_;}
121  float angleIncrement() const {return angleIncrement_;}
122  Transform localTransform() const {return localTransform_;}
123 
124  bool empty() const {return data_.empty();}
125  bool isEmpty() const {return data_.empty();}
126  int size() const {return data_.cols;}
127  int dataType() const {return data_.type();}
128  bool is2d() const {return isScan2d(format_);}
129  bool hasNormals() const {return isScanHasNormals(format_);}
130  bool hasRGB() const {return isScanHasRGB(format_);}
131  bool hasIntensity() const {return isScanHasIntensity(format_);}
132  bool isCompressed() const {return !data_.empty() && data_.type()==CV_8UC1;}
133  LaserScan clone() const;
134 
135  int getIntensityOffset() const {return hasIntensity()?(is2d()?2:3):-1;}
136  int getRGBOffset() const {return hasRGB()?(is2d()?2:3):-1;}
137  int getNormalsOffset() const {return hasNormals()?(2 + (is2d()?0:1) + ((hasRGB() || hasIntensity())?1:0)):-1;}
138 
139  float & field(unsigned int pointIndex, unsigned int channelOffset);
140 
141  void clear() {data_ = cv::Mat();}
142 
146  LaserScan & operator+=(const LaserScan &);
150  LaserScan operator+(const LaserScan &);
151 
152 private:
153  void init(const cv::Mat & data,
154  Format format,
155  float minRange,
156  float maxRange,
157  float angleMin,
158  float angleMax,
159  float angleIncrement,
160  int maxPoints,
161  const Transform & localTransform = Transform::getIdentity());
162 
163 private:
164  cv::Mat data_;
167  float rangeMin_;
168  float rangeMax_;
169  float angleMin_;
170  float angleMax_;
173 };
174 
175 }
176 
177 #endif /* CORELIB_INCLUDE_RTABMAP_CORE_LASERSCAN_H_ */
int maxPoints() const
Definition: LaserScan.h:116
int channels() const
Definition: LaserScan.h:115
float angleMin() const
Definition: LaserScan.h:119
def init(descriptorDim, matchThreshold, iterations, cuda, model_path)
static Transform getIdentity()
Definition: Transform.cpp:401
const cv::Mat & data() const
Definition: LaserScan.h:112
Format format() const
Definition: LaserScan.h:113
int getNormalsOffset() const
Definition: LaserScan.h:137
bool isEmpty() const
Definition: LaserScan.h:125
bool is2d() const
Definition: LaserScan.h:128
RTABMAP_DEPRECATED(typedef SensorData Image, "rtabmap::Image class is renamed to rtabmap::SensorData, use the last one instead.")
float rangeMax() const
Definition: LaserScan.h:118
bool hasRGB() const
Definition: LaserScan.h:130
#define RTABMAP_EXP
Definition: RtabmapExp.h:38
bool hasNormals() const
Definition: LaserScan.h:129
bool empty() const
Definition: LaserScan.h:124
float rangeMin() const
Definition: LaserScan.h:117
int getRGBOffset() const
Definition: LaserScan.h:136
int getIntensityOffset() const
Definition: LaserScan.h:135
float angleMax() const
Definition: LaserScan.h:120
bool isCompressed() const
Definition: LaserScan.h:132
Transform localTransform_
Definition: LaserScan.h:172
bool hasIntensity() const
Definition: LaserScan.h:131
RegEx operator+(const RegEx &ex1, const RegEx &ex2)
float angleIncrement() const
Definition: LaserScan.h:121
std::string formatName() const
Definition: LaserScan.h:114
int dataType() const
Definition: LaserScan.h:127
Transform localTransform() const
Definition: LaserScan.h:122
int size() const
Definition: LaserScan.h:126


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Jan 23 2023 03:37:28