69 std::vector<unsigned int>
uVars;
81 std::vector<unsigned int>
uVars;
98 virtual void reserve(
size_t newLength) = 0;
104 virtual void resize(
size_t newLength) = 0;
110 virtual void setSize(
size_t newLength) = 0;
113 virtual void setPointFast(
size_t index,
float x,
float y,
float z)=0;
116 virtual void insertPointFast(
float x,
float y,
float z = 0 ) = 0;
119 virtual void copyFrom(
const CPointsMap &obj) = 0;
125 virtual void getPointAllFieldsFast(
const size_t index, std::vector<float> & point_data )
const = 0;
131 virtual void setPointAllFieldsFast(
const size_t index,
const std::vector<float> & point_data ) = 0;
136 virtual void addFrom_classSpecific(
const CPointsMap &anotherMap,
const size_t nPreviousPoints) = 0;
146 virtual float squareDistanceToClosestCorrespondence(
151 return squareDistanceToClosestCorrespondence(static_cast<float>(p0.
x),static_cast<float>(p0.
y));
194 void loadFromConfigFile(
196 const std::string §ion);
222 virtual void addFrom(
const CPointsMap &anotherMap);
227 this->addFrom(anotherMap);
235 void insertAnotherMap(
254 bool load2Dor3D_from_text_file(
const std::string &file,
const bool is_3D);
259 bool save2D_to_text_file(
const std::string &file)
const;
264 bool save3D_to_text_file(
const std::string &file)
const;
269 const std::string &filNamePrefix
272 std::string fil( filNamePrefix + std::string(
".txt") );
273 save3D_to_text_file( fil );
277 virtual bool savePCDFile(
const std::string &filename,
bool save_as_binary)
const;
280 virtual bool loadPCDFile(
const std::string &filename);
312 virtual bool saveLASFile(
const std::string &filename,
const LAS_WriteParams & params = LAS_WriteParams() )
const;
317 virtual bool loadLASFile(
const std::string &filename, LAS_HeaderInfo &out_headerInfo,
const LAS_LoadParams ¶ms = LAS_LoadParams() );
324 inline size_t size()
const {
return x.size(); }
331 unsigned long getPoint(
size_t index,
float &x,
float &y,
float &z)
const;
333 unsigned long getPoint(
size_t index,
float &x,
float &y)
const;
335 unsigned long getPoint(
size_t index,
double &x,
double &y,
double &z)
const;
337 unsigned long getPoint(
size_t index,
double &x,
double &y)
const;
347 virtual void getPoint(
size_t index,
float &x,
float &y,
float &z,
float &R,
float &G,
float &B )
const
349 getPoint(index,x,y,z);
355 inline void getPointFast(
size_t index,
float &x,
float &y,
float &z)
const { x=this->x[index]; y=this->y[index]; z=this->z[index]; }
363 inline void setPoint(
size_t index,
float x,
float y,
float z) {
365 setPointFast(index,x,y,z);
375 virtual void setPoint(
size_t index,
float x,
float y,
float z,
float R,
float G,
float B)
378 setPoint(index,x,y,z);
392 void getPointsBuffer(
size_t &outPointsCount,
const float *&xs,
const float *&ys,
const float *&zs )
const;
406 template <
class VECTOR>
407 void getAllPoints( VECTOR &xs, VECTOR &ys, VECTOR &zs,
size_t decimation = 1 )
const
411 const size_t Nout = x.size() / decimation;
415 size_t idx_in, idx_out;
416 for (idx_in=0,idx_out=0;idx_out<Nout;idx_in+=decimation,++idx_out)
418 xs[idx_out]=x[idx_in];
419 ys[idx_out]=y[idx_in];
420 zs[idx_out]=z[idx_in];
425 inline void getAllPoints(std::vector<mrpt::math::TPoint3D> &ps,
size_t decimation=1)
const {
426 std::vector<float> dmy1,dmy2,dmy3;
427 getAllPoints(dmy1,dmy2,dmy3,decimation);
428 ps.resize(dmy1.size());
429 for (
size_t i=0;i<dmy1.size();i++) {
430 ps[i].x=
static_cast<double>(dmy1[i]);
431 ps[i].y=
static_cast<double>(dmy2[i]);
432 ps[i].z=
static_cast<double>(dmy3[i]);
440 void getAllPoints( std::vector<float> &xs, std::vector<float> &ys,
size_t decimation = 1 )
const;
442 inline void getAllPoints(std::vector<mrpt::math::TPoint2D> &ps,
size_t decimation=1)
const {
443 std::vector<float> dmy1,dmy2;
444 getAllPoints(dmy1,dmy2,decimation);
445 ps.resize(dmy1.size());
446 for (
size_t i=0;i<dmy1.size();i++) {
447 ps[i].x=
static_cast<double>(dmy1[i]);
448 ps[i].y=
static_cast<double>(dmy2[i]);
455 inline void insertPoint(
float x,
float y,
float z=0 ) { insertPointFast(x,y,z); mark_as_modified(); }
459 virtual void insertPoint(
float x,
float y,
float z,
float R,
float G,
float B )
468 template <
typename VECTOR>
471 const size_t N = X.size();
473 ASSERT_(Z.size()==0 || Z.size()==X.size())
475 const bool z_valid = !Z.empty();
476 if (z_valid)
for (
size_t i=0;i<N;i++) { this->setPointFast(i,X[i],Y[i],Z[i]); }
477 else for (
size_t i=0;i<N;i++) { this->setPointFast(i,X[i],Y[i],0); }
482 inline void setAllPoints(
const std::vector<float> &X,
const std::vector<float> &Y,
const std::vector<float> &Z) {
483 setAllPointsTemplate(X,Y,Z);
487 inline void setAllPoints(
const std::vector<float> &X,
const std::vector<float> &Y) {
488 setAllPointsTemplate(X,Y);
496 getPointAllFieldsFast(index,point_data);
505 setPointAllFieldsFast(index,point_data);
511 void clipOutOfRangeInZ(
float zMin,
float zMax);
520 void applyDeletionMask(
const std::vector<bool> &mask );
523 virtual void determineMatching2D(
531 virtual void determineMatching3D(
539 float compute3DMatchingRatio(
542 float maxDistForCorr = 0.10f,
543 float maxMahaDistForCorr = 2.0f
559 void compute3DDistanceToMesh(
562 float maxDistForCorrespondence,
564 float &correspondencesRatio );
579 virtual void loadFromRangeScan(
592 virtual void loadFromRangeScan(
608 float minDistForFuse = 0.02f,
609 std::vector<bool> *notFusedPoints = NULL);
625 virtual bool isEmpty()
const;
628 inline bool empty()
const {
return isEmpty(); }
634 virtual void getAs3DObject ( mrpt::opengl::CSetOfObjectsPtr &outObj )
const;
644 float getLargestDistanceFromOrigin()
const;
648 output_is_valid = m_largestDistanceFromOriginIsUpdated;
649 return m_largestDistanceFromOrigin;
655 void boundingBox(
float &min_x,
float &max_x,
float &min_y,
float &max_y,
float &min_z,
float &max_z )
const;
658 float dmy1,dmy2,dmy3,dmy4,dmy5,dmy6;
659 boundingBox(dmy1,dmy2,dmy3,dmy4,dmy5,dmy6);
686 inline void setHeightFilterLevels(
const double _z_min,
const double _z_max) { m_heightfilter_z_min=_z_min; m_heightfilter_z_max=_z_max; }
688 inline void getHeightFilterLevels(
double &_z_min,
double &_z_max)
const { _z_min=m_heightfilter_z_min; _z_max=m_heightfilter_z_max; }
715 template <
class POINTCLOUD>
718 const size_t nThis = this->
size();
722 cloud.is_dense =
false;
723 cloud.points.resize(cloud.width * cloud.height);
724 for (
size_t i = 0; i < nThis; ++i) {
725 cloud.points[i].x =this->x[i];
726 cloud.points[i].y =this->y[i];
727 cloud.points[i].z =this->z[i];
741 template <
class POINTCLOUD>
744 const size_t N = cloud.points.size();
747 for (
size_t i=0;i<N;++i)
748 this->insertPointFast(cloud.points[i].x,cloud.points[i].y,cloud.points[i].z);
761 if (dim==0)
return this->x[idx];
762 else if (dim==1)
return this->y[idx];
763 else if (dim==2)
return this->z[idx];
else return 0;
771 const float d0 = p1[0]-x[idx_p2];
772 const float d1 = p1[1]-y[idx_p2];
777 const float d0 = p1[0]-x[idx_p2];
778 const float d1 = p1[1]-y[idx_p2];
779 const float d2 = p1[2]-z[idx_p2];
780 return d0*d0+d1*d1+d2*d2;
787 template <
typename BBOX>
792 bb[0].low, bb[0].high,
793 bb[1].low, bb[1].high,
796 bb[2].low = min_z; bb[2].high = max_z;
805 std::vector<float> x,y,
z;
820 mutable float m_bb_min_x,m_bb_max_x, m_bb_min_y,m_bb_max_y,
m_bb_min_z,m_bb_max_z;
826 m_largestDistanceFromOriginIsUpdated=
false;
827 m_boundingBoxIsUpdated =
false;
828 kdtree_mark_as_outdated();
835 bool internal_insertObservation(
858 virtual size_t PLY_export_get_vertex_count()
const;
866 virtual void PLY_export_get_vertex(
892 namespace global_settings
911 static const int HAS_RGB = 0;
912 static const int HAS_RGBf = 0;
913 static const int HAS_RGBu8 = 0;
918 inline size_t size()
const {
return m_obj.
size(); }
923 template <
typename T>
924 inline void getPointXYZ(
const size_t idx, T &x,T &y, T &z)
const {
928 inline void setPointXYZ(
const size_t idx,
const coords_t x,
const coords_t y,
const coords_t z) {
#define ASSERT_EQUAL_(__A, __B)
mrpt::maps::CPointsMap & m_obj
void setPoint(size_t index, mrpt::math::TPoint3D &p)
void setFromPCLPointCloud(const POINTCLOUD &cloud)
Loads a PCL point cloud into this MRPT class (note: this method ignores potential RGB information...
MAPS_IMPEXP float POINTSMAPS_3DOBJECT_POINTSIZE
The size of points when exporting with getAs3DObject() (default=3.0) Affects to:
void setAllPointsTemplate(const VECTOR &X, const VECTOR &Y, const VECTOR &Z=VECTOR())
Set all the points at once from vectors with X,Y and Z coordinates (if Z is not provided, it will be set to all zeros).
bool isPlanarMap
If set to true, only HORIZONTAL (in the XY plane) measurements will be inserted in the map (Default v...
float kdtree_get_pt(const size_t idx, int dim) const
Returns the dim'th component of the idx'th point in the class:
virtual void getPoint(size_t index, float &x, float &y, float &z, float &R, float &G, float &B) const
Access to a given point from map, and its colors, if the map defines them (othersise, R=G=B=1.0).
void boundingBox(mrpt::math::TPoint3D &pMin, mrpt::math::TPoint3D &pMax) const
bool m_heightfilter_enabled
Whether or not (default=not) filter the input points by height.
void getAllPoints(std::vector< mrpt::math::TPoint2D > &ps, size_t decimation=1) const
const mrpt::obs::CObservation2DRangeScan & rangeScan
const mrpt::obs::CObservation3DRangeScan & rangeScan
void getPointAllFields(const size_t index, std::vector< float > &point_data) const
Get all the data fields for one point as a vector: depending on the implementation class this can be ...
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
A helper base class for those PointCloudAdapter<> which do not handle RGB data; it declares needed in...
void setAllPoints(const std::vector< float > &X, const std::vector< float > &Y)
Set all the points at once from vectors with X and Y coordinates (Z=0).
size_t size() const
Get number of points.
size_t kdtree_get_point_count() const
Must return the number of data points.
float getLargestDistanceFromOriginNoRecompute(bool &output_is_valid) const
Like getLargestDistanceFromOrigin() but returns in output_is_valid = false if the distance was not al...
bool isFilterByHeightEnabled() const
Return whether filter-by-height is enabled.
#define ASSERT_BELOW_(__A, __B)
virtual void setPointFast(size_t index, float x, float y, float z)=0
Changes the coordinates of the given point (0-based index), without checking for out-of-bounds and wi...
virtual bool hasColorPoints() const
Returns true if the point map has a color field for each point.
virtual size_t PLY_export_get_face_count() const
In a base class, return the number of faces.
Declares a class derived from "CObservation" that encapsules a 3D range scan measurement (e...
static float COLOR_3DSCENE_R
The color [0,1] of points when extracted from getAs3DObject (default=blue)
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans. ...
static float COLOR_3DSCENE_G
const std::vector< float > & getPointsBufferRef_x() const
Provides a direct access to a read-only reference of the internal point buffer.
void insertPoint(float x, float y, float z=0)
Provides a way to insert (append) individual points into the map: the missing fields of child classes...
void setPointXYZ(const size_t idx, const coords_t x, const coords_t y, const coords_t z)
Set XYZ coordinates of i'th point.
double z
X,Y,Z coordinates.
bool m_boundingBoxIsUpdated
const std::vector< float > & getPointsBufferRef_y() const
Provides a direct access to a read-only reference of the internal point buffer.
virtual unsigned int getPointWeight(size_t index) const
Gets the point weight, which is ignored in all classes (defaults to 1) but in those which actually st...
float maxDistForInterpolatePoints
The maximum distance between two points to interpolate between them (ONLY when also_interpolate=true)...
float scan_z
In internal_loadFromRangeScan3D_prepareOneRange, these are the local coordinates of the scan points b...
void mark_as_modified() const
Called only by this class or children classes, set m_largestDistanceFromOriginIsUpdated=false and suc...
This class allows loading and storing values and vectors of different types from a configuration text...
#define DEFINE_VIRTUAL_SERIALIZABLE(class_name)
This declaration must be inserted in virtual CSerializable classes definition:
A generic adaptor class for providing Approximate Nearest Neighbors (ANN) (via the nanoflann library)...
void setPointAllFields(const size_t index, const std::vector< float > &point_data)
Set all the data fields for one point as a vector: depending on the implementation class this can be ...
With this struct options are provided to the observation insertion process.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans or other sensors...
A numeric matrix of compile-time fixed size.
bool insertInvalidPoints
Points with x,y,z coordinates set to zero will also be inserted.
TLaserRange3DInsertContext(const mrpt::obs::CObservation3DRangeScan &_rangeScan)
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
Lightweight 3D point (float version).
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
std::vector< unsigned int > uVars
bool kdtree_get_bbox(BBOX &bb) const
double sigma_dist
Sigma (standard deviation, in meters) of the exponential used to model the likelihood (default= 0...
void setAllPoints(const std::vector< float > &X, const std::vector< float > &Y, const std::vector< float > &Z)
Set all the points at once from vectors with X,Y and Z coordinates.
A smart look-up-table (LUT) of sin/cos values for 2D laser scans.
std::vector< float > z
The point coordinates.
mrpt::math::CMatrixDouble44 HM
Homog matrix of the local sensor pose within the robot.
std::vector< T1 > & operator+=(std::vector< T1 > &a, const std::vector< T2 > &b)
a+=b (element-wise sum)
float coords_t
The type of each point XYZ coordinates.
void setPoint(size_t index, float x, float y)
bool m_largestDistanceFromOriginIsUpdated
Auxiliary variables used in "getLargestDistanceFromOrigin".
EIGEN_STRONG_INLINE void setSize(size_t row, size_t col)
Changes the size of matrix, maintaining its previous content as possible and padding with zeros where...
TLaserRange2DInsertContext(const mrpt::obs::CObservation2DRangeScan &_rangeScan)
std::vector< float > fVars
Extra variables to be used as desired by the derived class.
virtual void setPointWeight(size_t index, unsigned long w)
Sets the point weight, which is ignored in all classes but those which actually store that field (Not...
void getPointXYZ(const size_t idx, T &x, T &y, T &z) const
Get XYZ coordinates of i'th point.
bool load2D_from_text_file(const std::string &file)
Load from a text file.
A virtual base class that implements the capability of importing 3D point clouds and faces from a fil...
void saveMetricMapRepresentationToFile(const std::string &filNamePrefix) const
This virtual method saves the map to a file "filNamePrefix"+< some_file_extension >...
float m_largestDistanceFromOrigin
Auxiliary variables used in "getLargestDistanceFromOrigin".
virtual void PLY_import_set_face_count(const size_t N)
In a base class, reserve memory to prepare subsequent calls to PLY_import_set_face.
Optional settings for saveLASFile()
std::vector< float > fVars
Extra variables to be used as desired by the derived class.
const std::vector< float > & getPointsBufferRef_z() const
Provides a direct access to a read-only reference of the internal point buffer.
unsigned long getPoint(size_t index, mrpt::math::TPoint2D &p) const
virtual void setPoint(size_t index, float x, float y, float z, float R, float G, float B)
void setHeightFilterLevels(const double _z_min, const double _z_max)
Set the min/max Z levels for points to be actually inserted in the map (only if enableFilterByHeight(...
virtual ~TLikelihoodOptions()
bool also_interpolate
If set to true, far points (<1m) are interpolated with samples at "minDistSqrBetweenLaserPoints" inte...
void getAllPoints(std::vector< mrpt::math::TPoint3D > &ps, size_t decimation=1) const
mrpt::obs::CSinCosLookUpTableFor2DScans m_scans_sincos_cache
Cache of sin/cos values for the latest 2D scan geometries.
void getPCLPointCloud(POINTCLOUD &cloud) const
Use to convert this MRPT point cloud object into a PCL point cloud object (PointCloud
).
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
static float COLOR_3DSCENE_B
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
virtual void resize(size_t newLength)=0
Resizes all point buffers so they can hold the given number of points: newly created points are set t...
bool addToExistingPointsMap
Applicable to "loadFromRangeScan" only! If set to false, the points from the scan are loaded...
bool fuseWithExisting
If set to true (default=false), inserted points are "fused" with previously existent ones...
std::vector< uint8_t > bVars
TLikelihoodOptions likelihoodOptions
bool load3D_from_text_file(const std::string &file)
Load from a text file.
void getPointFast(size_t index, float &x, float &y, float &z) const
Just like getPoint() but without checking out-of-bound index and without returning the point weight...
float kdtree_distance(const float *p1, const size_t idx_p2, size_t size) const
Returns the distance between the vector "p1[0:size-1]" and the data point with index "idx_p2" stored ...
void setPoint(size_t index, float x, float y, float z)
Changes a given point from map, with Z defaulting to 0 if not provided.
size_t size(const MATRIXLIKE &m, int dim)
Declares a virtual base class for all metric maps storage classes.
A class used to store a 2D pose.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Declares a class that represents any robot's observation.
Options used when evaluating "computeObservationLikelihood" in the derived classes.
void getAllPoints(VECTOR &xs, VECTOR &ys, VECTOR &zs, size_t decimation=1) const
Returns a copy of the 2D/3D points as a std::vector of float coordinates.
virtual void insertPoint(float x, float y, float z, float R, float G, float B)
unsigned long getPoint(size_t index, mrpt::math::TPoint3D &p) const
std::vector< uint8_t > bVars
size_t size() const
Returns the number of stored points in the map.
float horizontalTolerance
The tolerance in rads in pitch & roll for a laser scan to be considered horizontal, considered only when isPlanarMap=true (default=0).
A RGB color - floats in the range [0,1].
virtual mrpt::maps::CSimplePointsMap * getAsSimplePointsMap()
PointCloudAdapter(const mrpt::maps::CPointsMap &obj)
Constructor (accept a const ref for convenience)
Helper struct used for internal_loadFromRangeScan3D_prepareOneRange()
virtual const mrpt::maps::CSimplePointsMap * getAsSimplePointsMap() const
If the map is a simple points map or it's a multi-metric map that contains EXACTLY one simple points ...
TInsertionOptions insertionOptions
The options used when inserting observations in the map.
double max_corr_distance
Maximum distance in meters to consider for the numerator divided by "sigma_dist", so that each point ...
bool empty() const
STL-like method to check whether the map is empty:
void enableFilterByHeight(bool enable=true)
Enable/disable the filter-by-height functionality.
An adapter to different kinds of point cloud object.
uint32_t decimation
Speed up the likelihood computation by considering only one out of N rays (default=10) ...
Parameters for the determination of matchings between point clouds, etc.
mrpt::math::CMatrixDouble44 HM
Homog matrix of the local sensor pose within the robot.
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
A virtual base class that implements the capability of exporting 3D point clouds and faces to a file ...
bool disableDeletion
If set to false (default=true) points in the same plane as the inserted scan and inside the free spac...
void getHeightFilterLevels(double &_z_min, double &_z_max) const
Get the min/max Z levels for points to be actually inserted in the map.
void setPoint(size_t index, mrpt::math::TPoint2D &p)
void insertPoint(const mrpt::math::TPoint3D &p)
float squareDistanceToClosestCorrespondenceT(const mrpt::math::TPoint2D &p0) const
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...
Helper struct used for internal_loadFromRangeScan2D_prepareOneRange()
void resize(const size_t N)
Set number of points (to uninitialized values)
double m_heightfilter_z_min
The minimum and maximum height for a certain laser scan to be inserted into this map.
float minDistBetweenLaserPoints
The minimum distance between points (in 3D): If two points are too close, one of them is not inserted...
Optional settings for loadLASFile()
std::vector< unsigned int > uVars