FeatureExtractor.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @author Fabian Reister ( fabian dot reister at kit dot edu )
17  * @date 2021
18  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19  * GNU General Public License
20  */
21 
22 #pragma once
23 
24 #include <optional>
25 
26 #include <pcl/point_types.h>
27 
28 #include <VirtualRobot/MathTools.h>
29 
31 
34 
35 #include <RobotComponents/interface/components/GraspingManager/RobotPlacementInterface.h>
36 
37 #include "EnclosingEllipsoid.h"
38 #include "ScanClustering.h"
39 
41 {
43 
44  struct Features
45  {
46  using Points = std::vector<Eigen::Vector2f>;
47  using Chain = Points;
48 
49  std::optional<VirtualRobot::MathTools::ConvexHull2D> convexHull;
50 
51  std::optional<Circle> circle;
52  std::optional<Ellipsoid> ellipsoid;
53 
54  std::optional<Chain> chain;
55 
57  std::vector<Ellipsoid> linesAsEllipsoids(float axisLength) const;
58  };
59 
61  {
62  public:
63  using Points = std::vector<Eigen::Vector2f>;
64 
65  FeatureExtractor(const ScanClustering::Params& scanClusteringParams,
66  const ChainApproximation::Params& chainApproximationParams);
67 
68  std::vector<Features> onData(const armem::laser_scans::LaserScanStamped& data);
69 
70  public:
71  static std::optional<VirtualRobot::MathTools::ConvexHull2D>
72  convexHull(const Points& points);
73  static std::optional<Ellipsoid>
74  ellipsoid(const std::optional<VirtualRobot::MathTools::ConvexHull2D>& hull);
75  static std::optional<Circle> circle(const Points& circle);
76  static std::optional<Points>
77  chainApproximation(const Points& points,
78  const std::optional<VirtualRobot::MathTools::ConvexHull2D>& convexHull,
79  const ChainApproximation::Params& params);
80 
81 
82  private:
83  std::vector<Features> features(const LaserScan& scan) const;
84 
85  std::vector<LaserScan> detectClusters(const LaserScan& scan) const;
86 
87  const ScanClustering::Params scanClusteringParams;
88  const ChainApproximation::Params chainApproximationParams;
89  };
90 } // namespace armarx::navigation::components::laser_scanner_feature_extraction
armarx::navigation::components::laser_scanner_feature_extraction::FeatureExtractor::onData
std::vector< Features > onData(const armem::laser_scans::LaserScanStamped &data)
Definition: FeatureExtractor.cpp:86
armarx::navigation::components::laser_scanner_feature_extraction::detail::ScanClusteringParams
Definition: ScanClustering.h:30
armarx::armem::laser_scans::LaserScanStamped
Definition: types.h:40
armarx::navigation::components::laser_scanner_feature_extraction::FeatureExtractor::convexHull
static std::optional< VirtualRobot::MathTools::ConvexHull2D > convexHull(const Points &points)
Definition: FeatureExtractor.cpp:128
armarx::detail::ChainApproximationParams
Definition: ChainApproximation.h:31
armarx::navigation::components::laser_scanner_feature_extraction::Features
Definition: FeatureExtractor.h:44
armarx::navigation::components::laser_scanner_feature_extraction::FeatureExtractor::chainApproximation
static std::optional< Points > chainApproximation(const Points &points, const std::optional< VirtualRobot::MathTools::ConvexHull2D > &convexHull, const ChainApproximation::Params &params)
Definition: FeatureExtractor.cpp:214
armarx::navigation::components::laser_scanner_feature_extraction::Circle
memory::Circle Circle
Definition: FeatureExtractor.h:42
types.h
armarx::navigation::components::laser_scanner_feature_extraction::Features::Chain
Points Chain
Definition: FeatureExtractor.h:47
armarx::navigation::components::laser_scanner_feature_extraction::Features::ellipsoid
std::optional< Ellipsoid > ellipsoid
Definition: FeatureExtractor.h:52
armarx::navigation::components::laser_scanner_feature_extraction::Features::chain
std::optional< Chain > chain
Definition: FeatureExtractor.h:54
EnclosingEllipsoid.h
armarx::navigation::components::laser_scanner_feature_extraction::FeatureExtractor::ellipsoid
static std::optional< Ellipsoid > ellipsoid(const std::optional< VirtualRobot::MathTools::ConvexHull2D > &hull)
Definition: FeatureExtractor.cpp:174
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
ScanClustering.h
armarx::navigation::memory::Circle
Definition: types.h:41
types.h
armarx::navigation::components::laser_scanner_feature_extraction::Features::convexHull
std::optional< VirtualRobot::MathTools::ConvexHull2D > convexHull
Definition: FeatureExtractor.h:49
ChainApproximation.h
armarx::navigation::components::laser_scanner_feature_extraction::FeatureExtractor::circle
static std::optional< Circle > circle(const Points &circle)
Definition: FeatureExtractor.cpp:195
armarx::navigation::components::laser_scanner_feature_extraction::FeatureExtractor
Definition: FeatureExtractor.h:60
armarx::navigation::components::laser_scanner_feature_extraction::Features::points
Points points
Definition: FeatureExtractor.h:56
armarx::navigation::components::laser_scanner_feature_extraction::FeatureExtractor::FeatureExtractor
FeatureExtractor(const ScanClustering::Params &scanClusteringParams, const ChainApproximation::Params &chainApproximationParams)
Definition: FeatureExtractor.cpp:78
armarx::navigation::components::laser_scanner_feature_extraction::Features::Points
std::vector< Eigen::Vector2f > Points
Definition: FeatureExtractor.h:46
armarx::navigation::components::laser_scanner_feature_extraction::FeatureExtractor::Points
std::vector< Eigen::Vector2f > Points
Definition: FeatureExtractor.h:63
armarx::navigation::components::laser_scanner_feature_extraction::Features::circle
std::optional< Circle > circle
Definition: FeatureExtractor.h:51
armarx::navigation::components::laser_scanner_feature_extraction::Features::linesAsEllipsoids
std::vector< Ellipsoid > linesAsEllipsoids(float axisLength) const
Definition: FeatureExtractor.cpp:45
armarx::navigation::components::laser_scanner_feature_extraction
Definition: ArVizDrawer.cpp:28