28#ifndef CORELIB_INCLUDE_RTABMAP_CORE_LASERSCAN_H_
29#define CORELIB_INCLUDE_RTABMAP_CORE_LASERSCAN_H_
31#include "rtabmap/core/rtabmap_core_export.h"
33#include <rtabmap/core/Transform.h>
73 static std::string formatName(
const Format & format);
74 static int channels(
const Format & format);
75 static bool isScan2d(
const Format & format);
76 static bool isScanHasNormals(
const Format & format);
77 static bool isScanHasRGB(
const Format & format);
78 static bool isScanHasIntensity(
const Format & format);
79 static bool isScanHasTime(
const Format & format);
80 static bool isScanHasRing(
const Format & format);
81 static float packRGB(
unsigned char r,
unsigned char g,
unsigned char b);
82 static void unpackRGB(
float rgb,
unsigned char & r,
unsigned char & g,
unsigned char & b);
88 const cv::Mat & oldScanFormat,
91 const Transform & localTransform = Transform::getIdentity());
97 const cv::Mat & oldScanFormat,
103 const Transform & localTransform = Transform::getIdentity());
114 const Transform & localTransform = Transform::getIdentity());
121 const Transform & localTransform = Transform::getIdentity());
126 const Transform & localTransform = Transform::getIdentity());
135 float angleIncrement,
136 const Transform & localTransform = Transform::getIdentity());
142 float angleIncrement,
143 const Transform & localTransform = Transform::getIdentity());
150 float angleIncrement,
151 const Transform & localTransform = Transform::getIdentity());
156 const cv::Mat & data()
const {
return data_;}
157 Format format()
const {
return format_;}
158 std::string formatName()
const {
return formatName(format_);}
159 int channels()
const {
return data_.channels();}
160 int maxPoints()
const {
return maxPoints_;}
161 float rangeMin()
const {
return rangeMin_;}
162 float rangeMax()
const {
return rangeMax_;}
163 float angleMin()
const {
return angleMin_;}
164 float angleMax()
const {
return angleMax_;}
165 float angleIncrement()
const {
return angleIncrement_;}
166 void setLocalTransform(
const Transform & t) {localTransform_ = t;}
167 Transform localTransform()
const {
return localTransform_;}
172 bool empty()
const {
return data_.empty();}
173 bool isEmpty()
const {
return data_.empty();}
174 int size()
const {
return static_cast<int>(data_.total());}
175 int dataType()
const {
return data_.type();}
176 bool is2d()
const {
return isScan2d(format_);}
177 bool hasNormals()
const {
return isScanHasNormals(format_);}
178 bool hasRGB()
const {
return isScanHasRGB(format_);}
179 bool hasIntensity()
const {
return isScanHasIntensity(format_);}
180 bool hasTime()
const {
return isScanHasTime(format_);}
181 bool hasRing()
const {
return isScanHasRing(format_);}
183 bool isCompressed()
const {
return !data_.empty() && data_.type()==CV_8UC1;}
184 bool isOrganized()
const {
return data_.rows > 1;}
185 LaserScan clone()
const;
186 LaserScan densify()
const;
191 int getIntensityOffset()
const {
return hasIntensity()?(is2d()?2:3):-1;}
192 int getRGBOffset()
const {
return hasRGB()?(is2d()?2:3):-1;}
193 int getNormalsOffset()
const {
return hasNormals()?(2 + (is2d()?0:1) + ((hasRGB() || hasIntensity())?1:0)):-1;}
194 int getRingOffset()
const {
return format_==kXYZIRT?4:-1;}
195 int getTimeOffset()
const {
return format_==kXYZIT?4:(format_==kXYZIRT?5:-1);}
204 float &
field(
unsigned int pointIndex,
unsigned int channelOffset);
222 void init(
const cv::Mat & data,
228 float angleIncrement,
230 const Transform & localTransform = Transform::getIdentity());
240 float angleIncrement_;
Represents 2D or 3D laser scan data with support for multiple point data formats.
RTABMAP_DEPRECATED LaserScan(const LaserScan &data, int maxPoints, float maxRange, Format format, const Transform &localTransform=Transform::getIdentity())
bool isCompressed() const
True if the scan is stored compressed (single-row CV_8UC1 blob) instead of raw points.
Format
Enumeration of possible formats for laser scan data.
float & field(unsigned int pointIndex, unsigned int channelOffset)
Access a specific field value of a point.
static LaserScan backwardCompatibility(const cv::Mat &oldScanFormat, float minRange, float maxRange, float angleMin, float angleMax, float angleInc, const Transform &localTransform=Transform::getIdentity())
Converts legacy scan format with additional metadata to a LaserScan.
RTABMAP_DEPRECATED LaserScan(const LaserScan &data, Format format, float minRange, float maxRange, float angleMin, float angleMax, float angleIncrement, const Transform &localTransform=Transform::getIdentity())
static LaserScan backwardCompatibility(const cv::Mat &oldScanFormat, int maxPoints=0, int maxRange=0, const Transform &localTransform=Transform::getIdentity())
Converts legacy scan format to a LaserScan object.
LaserScan operator+(const LaserScan &)
Concatenate scan's data (localTransform is ignored).
void clear()
Clear the scan data.
LaserScan & operator+=(const LaserScan &)
Concatenate scan's data (localTransform is ignored).