aron_conversions.cpp
Go to the documentation of this file.
1 #include "aron_conversions.h"
2 
4 #include <armarx/navigation/human/aron/Human.aron.generated.h>
6 #include <range/v3/range/conversion.hpp>
7 #include <range/v3/view/transform.hpp>
8 
10 {
11  void
12  toAron(arondto::Human& dto, const Human& bo)
13  {
14  dto.pose = conv::to3D(bo.pose).matrix();
15  dto.linearVelocity = conv::to3D(bo.linearVelocity);
16  dto.detectionTime = bo.detectionTime;
17  }
18 
19  void
20  fromAron(const arondto::Human& dto, Human& bo)
21  {
22  bo.pose = conv::to2D(core::Pose(dto.pose));
23  bo.linearVelocity = conv::to2D(dto.linearVelocity);
24  bo.detectionTime = dto.detectionTime;
25  }
26 
27 
28  void
29  toAron(arondto::HumanGroup& dto, const HumanGroup& bo)
30  {
31  dto.shape = bo.shape.vertices |
32  ranges::views::transform([](const Eigen::Vector2f& boVer) -> Eigen::Vector3f
33  { return conv::to3D(boVer); }) |
34  ranges::to_vector;
35 
36  dto.humans = bo.humans |
38  [](const Human& boHuman) -> arondto::Human
39  {
40  arondto::Human dtoHuman;
41  toAron(dtoHuman, boHuman);
42  return dtoHuman;
43  }) |
44  ranges::to_vector;
45  dto.detectionTime = bo.detectionTime;
46  }
47 
48  void
49  fromAron(const arondto::HumanGroup& dto, HumanGroup& bo)
50  {
51  bo.shape.vertices =
52  dto.shape |
53  ranges::views::transform([](const Eigen::Vector3f& dtoVer) -> Eigen::Vector2f
54  { return conv::to2D(dtoVer); }) |
55  ranges::to_vector;
56 
57  bo.humans = dto.humans |
59  [](const arondto::Human& dtoHuman) -> Human
60  {
61  Human boHuman;
62  fromAron(dtoHuman, boHuman);
63  return boHuman;
64  }) |
65  ranges::to_vector;
66  bo.detectionTime = dto.detectionTime;
67  }
68 
69 } // namespace armarx::navigation::human
armarx::navigation::human::HumanGroup
Definition: types.h:48
armarx::navigation::human::Human
Definition: types.h:33
armarx::navigation::core::Pose
Eigen::Isometry3f Pose
Definition: basic_types.h:31
types.h
armarx::navigation::human
This file is part of ArmarX.
Definition: aron_conversions.cpp:9
armarx::navigation::human::toAron
void toAron(arondto::Human &dto, const Human &bo)
Definition: aron_conversions.cpp:12
aron_conversions.h
armarx::navigation::human::fromAron
void fromAron(const arondto::Human &dto, Human &bo)
Definition: aron_conversions.cpp:20
armarx::navigation::conv::to2D
std::vector< Eigen::Vector2f > to2D(const std::vector< Eigen::Vector3f > &v)
Definition: eigen.cpp:26
armarx::transform
auto transform(const Container< InputT, Alloc > &in, OutputT(*func)(InputT const &)) -> Container< OutputT, typename std::allocator_traits< Alloc >::template rebind_alloc< OutputT > >
Convenience function (with less typing) to transform a container of type InputT into the same contain...
Definition: algorithm.h:315
armarx::navigation::conv::to3D
std::vector< Eigen::Vector3f > to3D(const std::vector< Eigen::Vector2f > &v)
Definition: eigen.cpp:11
eigen.h
armarx::aron::bo
const std::optional< BoT > & bo
Definition: aron_conversions.h:168