features.cpp
Go to the documentation of this file.
1#include "features.h"
2
3#include <vector>
4
5#include <SimoxUtility/algorithm/apply.hpp>
6
9
10namespace armarx::conversions
11{
13
15 transformFeature(const Features& feature, const Eigen::Isometry3f& transformation)
16 {
17 const auto transformPoint =
18 [](const Eigen::Vector2f& point, const Eigen::Isometry3f& global_T_frame)
19 { return to2D(global_T_frame * to3D(point)); };
20
21 const auto transformPoints =
22 [&](const std::vector<Eigen::Vector2f>& points, const Eigen::Isometry3f& global_T_frame)
23 {
24 return simox::alg::apply(points,
25 [&](const Eigen::Vector2f& point)
26 { return transformPoint(point, global_T_frame); });
27 };
28
29 Features transformed;
30
31 if (feature.convexHull)
32 {
33 transformed.convexHull = {
34 .vertices = transformPoints(feature.convexHull->vertices, transformation),
35 .segments = feature.convexHull->segments};
36 }
37 if (feature.circle)
38 {
39 transformed.circle = {.center = transformPoint(feature.circle->center, transformation),
40 .radius = feature.circle->radius};
41 }
42 if (feature.ellipsoid)
43 {
44 transformed.ellipsoid = {.pose = transformation * feature.ellipsoid->pose,
45 .radii = feature.ellipsoid->radii};
46 }
47 if (feature.chain)
48 {
49 transformed.chain = transformPoints(feature.chain.value(), transformation);
50 }
51 transformed.points = transformPoints(feature.points, transformation);
52
53 return transformed;
54 }
55
56} // namespace armarx::conversions
armarx::navigation::components::laser_scanner_feature_extraction::Features Features
Definition features.cpp:12
std::vector< Eigen::Vector3f > to3D(const std::vector< Eigen::Vector2f > &v)
Definition eigen.cpp:11
Eigen::Vector2f to2D(const Eigen::Vector3f &v2)
Definition eigen.h:33
Features transformFeature(const Features &feature, const Eigen::Isometry3f &transformation)
Definition features.cpp:15
std::optional< VirtualRobot::MathTools::ConvexHull2D > convexHull