CableClusterFilter.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 * @package Navigation::ArmarXObjects::LaserScannerFeatureExtraction
17 * @author Niklas Arlt ( niklas dot arlt at student dot kit dot edu )
18 * @date 2026
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23#pragma once
24
25#include <cstddef>
26#include <functional>
27#include <vector>
28
29#include <Eigen/Core>
30
31#include <VirtualRobot/MathTools.h>
32
34{
35
36 /**
37 * @brief Detects the laser scan cluster caused by the robot's charging cable.
38 *
39 * The cable is plugged in at a fixed point on the robot, so its points can
40 * only appear within an angular window emanating from the plug-in point,
41 * stay close to the robot hull, and form a very thin cluster. The plug-in
42 * point is placed inside the robot outline; the filter region is the part
43 * of the angular window between the robot outline and the max-distance
44 * band around it. A cluster is a cable candidate iff all of its points (in
45 * the robot root frame) pass the angular window and distance-to-hull tests
46 * and the cluster as a whole is thin enough.
47 */
49 {
50 public:
51 struct Params
52 {
53 /// Plug-in point of the charging cable in the robot root frame [mm].
54 /// Should lie inside the robot outline; the filter region is clipped
55 /// at the outline.
56 Eigen::Vector2f plugPosition = Eigen::Vector2f::Zero();
57
58 /// Full opening angle [rad] of the angular window. The window has its
59 /// apex at the plug-in point and is centered on the outward direction
60 /// from the robot origin through the plug-in point.
61 float windowAngle = 0.F;
62
63 /// Maximum distance [mm] of cable points from the robot hull boundary.
64 float maxDistanceToHull = 0.F;
65
66 /// Maximum cluster extent [mm] along its minor principal axis.
67 float maxThickness = 0.F;
68 };
69
70 /// Distance from a point (robot root frame) to the robot hull boundary; 0 if inside.
71 using DistanceToHullFn = std::function<float(const Eigen::Vector2f&)>;
72
73 CableClusterFilter(const Params& params, DistanceToHullFn distanceToHull);
74
75 /// Whether the cluster fulfills all cable criteria. Points must be given
76 /// in the robot root frame.
77 bool isCandidate(const std::vector<Eigen::Vector2f>& clusterPoints) const;
78
79 /// Extent of the point set along its minor principal axis (PCA).
80 static float thickness(const std::vector<Eigen::Vector2f>& points);
81
82 /// Sampled boundary polygon of the filter region (robot root frame) for
83 /// visualization: the outer arc of the angular window on the max-distance
84 /// boundary followed by the inner arc along the robot outline.
85 std::vector<Eigen::Vector2f> regionPolygon(std::size_t numArcSamples = 24) const;
86
87 private:
88 Params params;
89 DistanceToHullFn distanceToHull;
90
91 /// Unit direction from the robot origin through the plug-in point.
92 Eigen::Vector2f outward;
93 /// False if the plug-in point coincides with the robot origin (no
94 /// well-defined outward direction); the angular test is skipped then.
95 bool angularTestValid = false;
96 };
97
98 /// Distance from a point to the boundary of a convex hull; 0 if the point is inside.
99 float distanceToConvexHullBoundary(const Eigen::Vector2f& pt,
100 const VirtualRobot::MathTools::ConvexHull2D& hull);
101
102} // namespace armarx::navigation::components::laser_scanner_feature_extraction
#define float
Definition 16_Level.h:22
std::vector< Eigen::Vector2f > regionPolygon(std::size_t numArcSamples=24) const
Sampled boundary polygon of the filter region (robot root frame) for visualization: the outer arc of ...
std::function< float(const Eigen::Vector2f &)> DistanceToHullFn
Distance from a point (robot root frame) to the robot hull boundary; 0 if inside.
static float thickness(const std::vector< Eigen::Vector2f > &points)
Extent of the point set along its minor principal axis (PCA).
bool isCandidate(const std::vector< Eigen::Vector2f > &clusterPoints) const
Whether the cluster fulfills all cable criteria.
float distanceToConvexHullBoundary(const Eigen::Vector2f &pt, const VirtualRobot::MathTools::ConvexHull2D &hull)
Distance from a point to the boundary of a convex hull; 0 if the point is inside.
float maxDistanceToHull
Maximum distance [mm] of cable points from the robot hull boundary.
float maxThickness
Maximum cluster extent [mm] along its minor principal axis.
Eigen::Vector2f plugPosition
Plug-in point of the charging cable in the robot root frame [mm].