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#include <vector>
26
27#include <VirtualRobot/MathTools.h>
28
29#include <RobotAPI/interface/units/LaserScannerUnit.h>
31
34
35#include "EnclosingEllipsoid.h"
36#include "ScanClustering.h"
37
39{
41
42 struct Features
43 {
44 using Points = std::vector<Eigen::Vector2f>;
45 using Chain = Points;
46
47 std::optional<VirtualRobot::MathTools::ConvexHull2D> convexHull;
48
49 std::optional<Circle> circle;
50 std::optional<Ellipsoid> ellipsoid;
51
52 std::optional<Chain> chain;
53
55 std::vector<Ellipsoid> linesAsEllipsoids(float axisLength) const;
56 };
57
59 {
60 public:
61 using Points = std::vector<Eigen::Vector2f>;
62
63 FeatureExtractor(const ScanClustering::Params& scanClusteringParams,
64 const ChainApproximation::Params& chainApproximationParams);
65
66 std::vector<Features> onData(const armem::laser_scans::LaserScanStamped& data);
67
68 public:
69 static std::optional<VirtualRobot::MathTools::ConvexHull2D>
70 convexHull(const Points& points);
71 static std::optional<Ellipsoid>
72 ellipsoid(const std::optional<VirtualRobot::MathTools::ConvexHull2D>& hull);
73 static std::optional<Circle> circle(const Points& circle);
74 static std::optional<Points>
75 chainApproximation(const Points& points,
76 const std::optional<VirtualRobot::MathTools::ConvexHull2D>& convexHull,
77 const ChainApproximation::Params& params);
78
79
80 private:
81 std::vector<Features> features(const LaserScan& scan) const;
82
83 std::vector<LaserScan> detectClusters(const LaserScan& scan) const;
84
85 const ScanClustering::Params scanClusteringParams;
86 const ChainApproximation::Params chainApproximationParams;
87 };
88} // namespace armarx::navigation::components::laser_scanner_feature_extraction
detail::ChainApproximationParams Params
static std::optional< Ellipsoid > ellipsoid(const std::optional< VirtualRobot::MathTools::ConvexHull2D > &hull)
static std::optional< VirtualRobot::MathTools::ConvexHull2D > convexHull(const Points &points)
static std::optional< Points > chainApproximation(const Points &points, const std::optional< VirtualRobot::MathTools::ConvexHull2D > &convexHull, const ChainApproximation::Params &params)
FeatureExtractor(const ScanClustering::Params &scanClusteringParams, const ChainApproximation::Params &chainApproximationParams)
std::vector< Features > onData(const armem::laser_scans::LaserScanStamped &data)
std::optional< VirtualRobot::MathTools::ConvexHull2D > convexHull