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