elch.h
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2011, Willow Garage, Inc.
* Copyright (c) 2012-, Open Perception, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the copyright holder(s) nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $Id$
*
*/
#ifndef PCL_ELCH_H_
#define PCL_ELCH_H_
#include <pcl/pcl_base.h>
#include <pcl/point_types.h>
#include <pcl/point_cloud.h>
#include <pcl/registration/registration.h>
#include <pcl/registration/boost.h>
#include <pcl/registration/eigen.h>
#include <pcl/registration/icp.h>
#include <pcl/registration/boost_graph.h>
namespace pcl
{
namespace registration
{
/** \brief @b ELCH (Explicit Loop Closing Heuristic) class
* \author Jochen Sprickerhof
* \ingroup registration
*/
template <typename PointT>
class ELCH : public PCLBase<PointT>
{
public:
typedef boost::shared_ptr< ELCH<PointT> > Ptr;
typedef boost::shared_ptr< const ELCH<PointT> > ConstPtr;
typedef pcl::PointCloud<PointT> PointCloud;
typedef typename PointCloud::Ptr PointCloudPtr;
typedef typename PointCloud::ConstPtr PointCloudConstPtr;
struct Vertex
{
Vertex () : cloud () {}
PointCloudPtr cloud;
Eigen::Affine3f transform;
};
/** \brief graph structure to hold the SLAM graph */
typedef boost::adjacency_list<
boost::listS, boost::eigen_vecS, boost::undirectedS,
Vertex,
boost::no_property>
LoopGraph;
typedef boost::shared_ptr< LoopGraph > LoopGraphPtr;
typedef typename pcl::Registration<PointT, PointT> Registration;
typedef typename Registration::Ptr RegistrationPtr;
typedef typename Registration::ConstPtr RegistrationConstPtr;
/** \brief Empty constructor. */
ELCH () :
loop_graph_ (new LoopGraph),
loop_start_ (0),
loop_end_ (0),
reg_ (new pcl::IterativeClosestPoint<PointT, PointT>),
loop_transform_ (),
compute_loop_ (true),
vd_ ()
{};
/** \brief Empty destructor */
virtual ~ELCH () {}
/** \brief Add a new point cloud to the internal graph.
* \param[in] cloud the new point cloud
*/
inline void
addPointCloud (PointCloudPtr cloud)
{
typename boost::graph_traits<LoopGraph>::vertex_descriptor vd = add_vertex (*loop_graph_);
(*loop_graph_)[vd].cloud = cloud;
if (num_vertices (*loop_graph_) > 1)
add_edge (vd_, vd, *loop_graph_);
vd_ = vd;
}
/** \brief Getter for the internal graph. */
inline LoopGraphPtr
getLoopGraph ()
{
return (loop_graph_);
}
/** \brief Setter for a new internal graph.
* \param[in] loop_graph the new graph
*/
inline void
setLoopGraph (LoopGraphPtr loop_graph)
{
loop_graph_ = loop_graph;
}
/** \brief Getter for the first scan of a loop. */
inline typename boost::graph_traits<LoopGraph>::vertex_descriptor
getLoopStart ()
{
return (loop_start_);
}
/** \brief Setter for the first scan of a loop.
* \param[in] loop_start the scan that starts the loop
*/
inline void
setLoopStart (const typename boost::graph_traits<LoopGraph>::vertex_descriptor &loop_start)
{
loop_start_ = loop_start;
}
/** \brief Getter for the last scan of a loop. */
inline typename boost::graph_traits<LoopGraph>::vertex_descriptor
getLoopEnd ()
{
return (loop_end_);
}
/** \brief Setter for the last scan of a loop.
* \param[in] loop_end the scan that ends the loop
*/
inline void
setLoopEnd (const typename boost::graph_traits<LoopGraph>::vertex_descriptor &loop_end)
{
loop_end_ = loop_end;
}
/** \brief Getter for the registration algorithm. */
inline RegistrationPtr
getReg ()
{
return (reg_);
}
/** \brief Setter for the registration algorithm.
* \param[in] reg the registration algorithm used to compute the transformation between the start and the end of the loop
*/
inline void
setReg (RegistrationPtr reg)
{
reg_ = reg;
}
/** \brief Getter for the transformation between the first and the last scan. */
inline Eigen::Matrix4f
getLoopTransform ()
{
return (loop_transform_);
}
/** \brief Setter for the transformation between the first and the last scan.
* \param[in] loop_transform the transformation between the first and the last scan
*/
inline void
setLoopTransform (const Eigen::Matrix4f &loop_transform)
{
loop_transform_ = loop_transform;
compute_loop_ = false;
}
/** \brief Computes new poses for all point clouds by closing the loop
* between start and end point cloud. This will transform all given point
* clouds for now!
*/
void
compute ();
protected:
using PCLBase<PointT>::deinitCompute;
/** \brief This method should get called before starting the actual computation. */
virtual bool
initCompute ();
private:
/** \brief graph structure for the internal optimization graph */
typedef boost::adjacency_list<
boost::listS, boost::vecS, boost::undirectedS,
boost::no_property,
boost::property< boost::edge_weight_t, double > >
LOAGraph;
/**
* graph balancer algorithm computes the weights
* @param[in] g the graph
* @param[in] f index of the first node
* @param[in] l index of the last node
* @param[out] weights array for the weights
*/
void
loopOptimizerAlgorithm (LOAGraph &g, double *weights);
/** \brief The internal loop graph. */
LoopGraphPtr loop_graph_;
/** \brief The first scan of the loop. */
typename boost::graph_traits<LoopGraph>::vertex_descriptor loop_start_;
/** \brief The last scan of the loop. */
typename boost::graph_traits<LoopGraph>::vertex_descriptor loop_end_;
/** \brief The registration object used to close the loop. */
RegistrationPtr reg_;
/** \brief The transformation between that start and end of the loop. */
Eigen::Matrix4f loop_transform_;
bool compute_loop_;
/** \brief previously added node in the loop_graph_. */
typename boost::graph_traits<LoopGraph>::vertex_descriptor vd_;
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};
}
}
#include <pcl/registration/impl/elch.hpp>
#endif // PCL_ELCH_H_
pcl::registration::ELCH::LoopGraph
boost::adjacency_list< boost::listS, boost::eigen_vecS, boost::undirectedS, Vertex, boost::no_property > LoopGraph
graph structure to hold the SLAM graph
Definition: elch.h:84
pcl::registration::ELCH::setLoopEnd
void setLoopEnd(const typename boost::graph_traits< LoopGraph >::vertex_descriptor &loop_end)
Setter for the last scan of a loop.
Definition: elch.h:162
pcl::registration::ELCH::~ELCH
virtual ~ELCH()
Empty destructor.
Definition: elch.h:104
pcl::Registration< PointT, PointT >::ConstPtr
boost::shared_ptr< const Registration< PointT, PointT, float > > ConstPtr
Definition: registration.h:73
pcl::registration::ELCH::PointCloud
pcl::PointCloud< PointT > PointCloud
Definition: elch.h:68
pcl::registration::ELCH::getLoopTransform
Eigen::Matrix4f getLoopTransform()
Getter for the transformation between the first and the last scan.
Definition: elch.h:185
pcl::registration::ELCH::PointCloudConstPtr
PointCloud::ConstPtr PointCloudConstPtr
Definition: elch.h:70
pcl
Definition: cloud_iterator.h:46
pcl::registration::ELCH::compute
void compute()
Computes new poses for all point clouds by closing the loop between start and end point cloud...
Definition: elch.hpp:218
pcl::registration::ELCH::setLoopGraph
void setLoopGraph(LoopGraphPtr loop_graph)
Setter for a new internal graph.
Definition: elch.h:130
pcl::Registration::Ptr
boost::shared_ptr< Registration< PointSource, PointTarget, Scalar > > Ptr
Definition: registration.h:72
pcl::registration::ELCH::getReg
RegistrationPtr getReg()
Getter for the registration algorithm.
Definition: elch.h:169
pcl::registration::ELCH::setLoopStart
void setLoopStart(const typename boost::graph_traits< LoopGraph >::vertex_descriptor &loop_start)
Setter for the first scan of a loop.
Definition: elch.h:146
pcl::registration::ELCH::Vertex::Vertex
Vertex()
Definition: elch.h:74
pcl::PointCloud::Ptr
boost::shared_ptr< PointCloud< PointT > > Ptr
Definition: point_cloud.h:428
pcl::registration::ELCH::Vertex
Definition: elch.h:72
pcl::registration::ELCH
ELCH (Explicit Loop Closing Heuristic) class
Definition: elch.h:62
pcl::registration::ELCH::Vertex::cloud
PointCloudPtr cloud
Definition: elch.h:75
pcl::registration::ELCH::setReg
void setReg(RegistrationPtr reg)
Setter for the registration algorithm.
Definition: elch.h:178
pcl::PCLBase
PCL base class.
Definition: pcl_base.h:68
pcl::registration::ELCH::LoopGraphPtr
boost::shared_ptr< LoopGraph > LoopGraphPtr
Definition: elch.h:86
pcl::registration::ELCH::Registration
pcl::Registration< PointT, PointT > Registration
Definition: elch.h:88
pcl::registration::ELCH::getLoopEnd
boost::graph_traits< LoopGraph >::vertex_descriptor getLoopEnd()
Getter for the last scan of a loop.
Definition: elch.h:153
pcl::registration::ELCH::getLoopStart
boost::graph_traits< LoopGraph >::vertex_descriptor getLoopStart()
Getter for the first scan of a loop.
Definition: elch.h:137
pcl::PointCloud::ConstPtr
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
Definition: point_cloud.h:429
pcl::IterativeClosestPoint
IterativeClosestPoint provides a base implementation of the Iterative Closest Point algorithm...
Definition: icp.h:94
pcl::registration::ELCH::ConstPtr
boost::shared_ptr< const ELCH< PointT > > ConstPtr
Definition: elch.h:66
pcl::registration::ELCH::initCompute
virtual bool initCompute()
This method should get called before starting the actual computation.
Definition: elch.hpp:158
pcl::Registration< PointT, PointT >
pcl::PointCloud
PointCloud represents the base class in PCL for storing collections of 3D points. ...
Definition: projection_matrix.h:53
pcl::registration::ELCH::RegistrationConstPtr
Registration::ConstPtr RegistrationConstPtr
Definition: elch.h:90
pcl::registration::ELCH::PointCloudPtr
PointCloud::Ptr PointCloudPtr
Definition: elch.h:69
pcl::registration::ELCH::Ptr
boost::shared_ptr< ELCH< PointT > > Ptr
Definition: elch.h:65
pcl::registration::ELCH::Vertex::transform
Eigen::Affine3f transform
Definition: elch.h:76
pcl::registration::ELCH::setLoopTransform
void setLoopTransform(const Eigen::Matrix4f &loop_transform)
Setter for the transformation between the first and the last scan.
Definition: elch.h:194
pcl::PointXYZRGB
A point structure representing Euclidean xyz coordinates, and the RGB color.
Definition: point_types.hpp:594
pcl::registration::ELCH::ELCH
ELCH()
Empty constructor.
Definition: elch.h:93
pcl::registration::ELCH::addPointCloud
void addPointCloud(PointCloudPtr cloud)
Add a new point cloud to the internal graph.
Definition: elch.h:110
pcl::registration::ELCH::getLoopGraph
LoopGraphPtr getLoopGraph()
Getter for the internal graph.
Definition: elch.h:121
boost::eigen_vecS
Definition: boost_graph.h:50
pcl::registration::ELCH::RegistrationPtr
Registration::Ptr RegistrationPtr
Definition: elch.h:89