iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nrt::ModelPlane Class Reference

#include <nrt/PointCloud2/SampleConcensus/Models/ModelPlane.H>

A model for performing plane fitting.

This model estimates a plane for a given set of points, optionally using point normals present as nrt::PointNormal to place additional constraints on the optimization

Definition at line 53 of file ModelPlane.H.

Inheritance diagram for nrt::ModelPlane:
nrt::ModelBase nrt::SourceCloud

Public Types

typedef Eigen::Hyperplane
< PointCloud2::BaseType, 3 > 
Plane
 A parameterized plane.
 
- Public Types inherited from nrt::ModelBase
typedef std::shared_ptr
< ModelBase
SharedPtr
 Convenience typedef for shared ptr to this.
 
typedef std::function< bool(Indices
const &)> 
SampleValidFunction
 A function that returns true if a set of points returns a valid sample. More...
 

Public Member Functions

ModelBase::SampleValidFunction createNonCollinearValidation () const
 A validation function that returns true if the points are not collinear.
 
 ModelPlane (PointCloud2 const source, Optional< ModelBase::SampleValidFunction > func=OptionalEmpty, double inlierThreshold=std::numeric_limits< double >::max(), Optional< double > normalWeight=OptionalEmpty, size_t sampleMaxIterations=1000, bool seedRandom=false)
 Constructor. More...
 
 ModelPlane (PointCloud2 const source, Indices const sourceIndices, Optional< ModelBase::SampleValidFunction > func=OptionalEmpty, double inlierThreshold=-std::numeric_limits< double >::max(), Optional< double > normalWeight=OptionalEmpty, size_t sampleMaxIterations=1000, bool seedRandom=false)
 Constructor with subsets. More...
 
virtual ~ModelPlane ()
 Virtual destructor.
 
virtual size_t getSampleSize () const
 Returns the minimum valid sample size for the model.
 
virtual VectorX computeModelCoefficients (Indices const sampleIndices) const
 Attempts to form a valid model from the points at the selected indices. More...
 
virtual VectorX optimizeModelCoefficients (Indices const inlierIndices, VectorX const &modelCoefficients) const
 Recomputes the model coefficients using the provided inlier indices. More...
 
virtual std::vector< double > getDistancesToModel (VectorX const &modelCoefficients) const
 Computes distances from transformed points to their correspondences.
 
virtual Indices selectWithinDistance (VectorX const &modelCoefficients) const
 
virtual int countWithinDistance (VectorX const &modelCoefficients) const
 Counts all of the points which respect the model coefficients that are inliers.
 
- Public Member Functions inherited from nrt::ModelBase
 ModelBase (PointCloud2 const source, SampleValidFunction func, double inlierThreshold=std::numeric_limits< double >::max(), size_t sampleMaxIterations=1000, bool seedRandom=false)
 Constructor with no subset. More...
 
 ModelBase (PointCloud2 const source, Indices const indices, SampleValidFunction func, double inlierThreshold=std::numeric_limits< double >::max(), size_t sampleMaxIterations=1000, bool seedRandom=false)
 Constructor with a subset. More...
 
virtual ~ModelBase ()
 Virtual destructor.
 
Indices getSamples () const
 
- Public Member Functions inherited from nrt::SourceCloud
 SourceCloud ()
 Initializes with no data.
 
 SourceCloud (PointCloud2 const cloud)
 Initializes with a point cloud and no subset.
 
 SourceCloud (PointCloud2 const cloud, Indices const indices)
 Initializes with a point cloud and a specific subset.
 
size_t getWorkingSize () const
 Returns the current working size of the Source. More...
 

Protected Member Functions

bool isValid (VectorX const &coefs) const
 Check if some set of coefficients is valid to use.
 

Additional Inherited Members

- Public Attributes inherited from nrt::SourceCloud
PointCloud2 cloud
 The source point cloud.
 
Indices indices
 The optional indices.
 
bool useSubset
 Whether we use a subset or not.
 
- Protected Attributes inherited from nrt::ModelBase
PointCloud2 itsCloud
 The input point cloud.
 
SampleValidFunction itsIsSampleValidFunction
 Evaluates whether a set of indices is valid.
 
const double itsInlierThreshold
 used during sample selection
 
const size_t itsSampleMaxIterations
 distance threshold for selection and counting
 
std::mt19937 itsRNG
 The random number generator.
 

Constructor & Destructor Documentation

nrt::ModelPlane::ModelPlane ( PointCloud2 const  source,
Optional< ModelBase::SampleValidFunction func = OptionalEmpty,
double  inlierThreshold = std::numeric_limits< double >::max(),
Optional< double >  normalWeight = OptionalEmpty,
size_t  sampleMaxIterations = 1000,
bool  seedRandom = false 
)

Constructor.

Parameters
sourceThe source cloud
funcThe optional evaluation function. Should return true if a plane can be created from the set of points provided.
inlierThresholdDistance threshold to use for select and countWithinDistance()
normalWeightThe weighting to apply to normals. If non-empty, the input point cloud must have normals in the form of nrt::PointNormal. This will place an additional constraint on the optimization such that the inliers have some maximum angular deviation between the plane's normal and the inlier point normals. In the range [0 1].
sampleMaxIterationsMaximum number of iterations to use during sample selection
seedRandomIf true, the random number generator will be seeded with the current time, otherwise it will always receive the same default seed
nrt::ModelPlane::ModelPlane ( PointCloud2 const  source,
Indices const  sourceIndices,
Optional< ModelBase::SampleValidFunction func = OptionalEmpty,
double  inlierThreshold = -std::numeric_limits< double >::max(),
Optional< double >  normalWeight = OptionalEmpty,
size_t  sampleMaxIterations = 1000,
bool  seedRandom = false 
)

Constructor with subsets.

Parameters
sourceThe source cloud
sourceIndicesThe subset of the input to consider
funcThe optional evaluation function. Should return true if a plane can be created from the set of points provided.
normalWeightThe weighting to apply to normals. If non-zero, the input point cloud must have normals in the form of nrt::PointNormal. This will place an additional constraint on the optimization such that the inliers have some maximum angular deviation between the plane's normal and the inlier point normals.
inlierThresholdDistance threshold to use for select and countWithinDistance()
sampleMaxIterationsMaximum number of iterations to use during sample selection
seedRandomIf true, the random number generator will be seeded with the current time, otherwise it will always receive the same default seed

Member Function Documentation

virtual VectorX nrt::ModelPlane::computeModelCoefficients ( Indices const  sampleIndices) const
virtual

Attempts to form a valid model from the points at the selected indices.

Parameters
sampleIndicesThe valid indices (check with isSampleValid() ) to use
Returns
The coefficients for the model

Implements nrt::ModelBase.

virtual VectorX nrt::ModelPlane::optimizeModelCoefficients ( Indices const  inlierIndices,
VectorX const &  modelCoefficients 
) const
virtual

Recomputes the model coefficients using the provided inlier indices.

This can be called after inliers have been computed to refine a solution

Parameters
inlierIndicesThe inlier indices
modelCoefficientsThe coefficients found via computeModelCoefficients()
Returns
The optimized set of model coefficients

Implements nrt::ModelBase.

virtual Indices nrt::ModelPlane::selectWithinDistance ( VectorX const &  modelCoefficients) const
virtual

Selects all points from the input data set that are inliers under the model according to some threshold

Implements nrt::ModelBase.


The documentation for this class was generated from the following file: