- 3.0.2 core module.
PlaneEstimator.h
Go to the documentation of this file.
1 /**********************************************************************************************************************
2 This file is part of the Control Toolbox (https://github.com/ethz-adrl/control-toolbox), copyright by ETH Zurich.
3 Licensed under the BSD-2 license (see LICENSE file in main directory)
4 **********************************************************************************************************************/
5 
6 #pragma once
7 
8 #include "Plane.h"
9 
10 namespace ct {
11 namespace core {
12 
14 
18 {
19 public:
20  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
21 
22  typedef std::vector<Eigen::Vector3d, Eigen::aligned_allocator<Eigen::Vector3d>> point_measurements_t;
23 
29 
37  Plane estimate(const point_measurements_t& points)
38  {
39  if (points.size() < 3)
40  throw std::runtime_error("Point measurement vector should contain at least 3 entries!");
41 
42  Eigen::MatrixXd A(points.size(), 3);
43  Eigen::MatrixXd d(points.size(), 1);
44  d.setOnes(); // d normalized to 1
45 
46  for (size_t i = 0; i < points.size(); i++)
47  {
48  A.row(i) = points[i];
49  }
50 
51  Eigen::Matrix<double, 4, 1> coefficients;
52  coefficients.head<3>() = A.colPivHouseholderQr().solve(d);
53  coefficients(3) = 1.0; // d normalized to 1
54 
55  return Plane(coefficients);
56  }
57 
58 private:
59 };
60 
61 } // namespace core
62 } // namespace ct
63 
64 #pragma once
Estimates a Plane from a number of 3D points using least squares.
Definition: PlaneEstimator.h:17
PlaneEstimator()
constructor
Definition: PlaneEstimator.h:25
for i
Plane estimate(const point_measurements_t &points)
estimate the plane
Definition: PlaneEstimator.h:37
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef std::vector< Eigen::Vector3d, Eigen::aligned_allocator< Eigen::Vector3d > > point_measurements_t
Definition: PlaneEstimator.h:22
Implements a geometrical 3D plane of type .
Definition: Plane.h:12
~PlaneEstimator()
destructor
Definition: PlaneEstimator.h:27