aron_conversions.cpp
Go to the documentation of this file.
1 #include "aron_conversions.h"
2 
3 #include <algorithm>
4 #include <cstdint>
5 #include <iterator>
6 
7 #include <RobotAPI/interface/units/LaserScannerUnit.h>
9 #include <RobotAPI/libraries/armem_laser_scans/aron/LaserScan.aron.generated.h>
12 
13 #include "types.h"
14 
16 {
17 
18  /************ fromAron ************/
20  fromAron(const arondto::SensorHeader& aronSensorHeader)
21  {
22  return {.agent = aronSensorHeader.agent,
23  .frame = aronSensorHeader.frame,
24  .timestamp = aron::fromAron<Time>(aronSensorHeader.timestamp)};
25  }
26 
27  void
28  fromAron(const arondto::LaserScanStamped& aronLaserScan, LaserScanStamped& laserScan)
29  {
30  laserScan.header = fromAron(aronLaserScan.header);
31  // laserScan.data = fromAron(aronLaserScan.data);
32  }
33 
34  void
35  fromAron(const arondto::LaserScanStamped& aronLaserScan,
36  LaserScan& laserScan,
37  std::int64_t& timestamp,
38  std::string& frame,
39  std::string& agentName)
40  {
41  const auto header = fromAron(aronLaserScan.header);
42 
43  // laserScan = fromAron(aronLaserScan.data);
44 
45  timestamp = header.timestamp.toMicroSecondsSinceEpoch();
46  frame = header.frame;
47  agentName = header.agent;
48  }
49 
50  /************ toAron ************/
51 
52  // auto toAron(const LaserScan& laserScan, aron::LaserScan& aronLaserScan)
53  // {
54  // aronLaserScan.scan = toAron(laserScan);
55  // }
56 
57  int64_t
58  toAron(const armem::Time& timestamp)
59  {
60  return timestamp.toMicroSecondsSinceEpoch();
61  }
62 
63  arondto::SensorHeader
64  toAron(const SensorHeader& sensorHeader)
65  {
66  arondto::SensorHeader aronSensorHeader;
67 
68  aronSensorHeader.agent = sensorHeader.agent;
69  aronSensorHeader.frame = sensorHeader.frame;
70  aron::toAron(aronSensorHeader.timestamp, sensorHeader.timestamp);
71 
72  return aronSensorHeader;
73  }
74 
75  void
76  toAron(const LaserScanStamped& laserScanStamped,
77  arondto::LaserScanStamped& aronLaserScanStamped)
78  {
79  aronLaserScanStamped.header = toAron(laserScanStamped.header);
80  // toAron(laserScanStamped.data, aronLaserScanStamped.data);
81  }
82 
83  void
84  toAron(const LaserScan& laserScan,
85  const armem::Time& timestamp,
86  const std::string& frame,
87  const std::string& agentName,
88  arondto::LaserScanStamped& aronLaserScanStamped)
89  {
90  const SensorHeader header{.agent = agentName, .frame = frame, .timestamp = timestamp};
91 
92  const LaserScanStamped laserScanStamped{.header = header, .data = laserScan};
93 
94  toAron(laserScanStamped, aronLaserScanStamped);
95  }
96 
97 
98 } // namespace armarx::armem::laser_scans
armarx::armem::laser_scans::LaserScanStamped
Definition: types.h:40
armarx::armem::laser_scans::SensorHeader::timestamp
armem::Time timestamp
Definition: types.h:37
types.h
armarx::armem::laser_scans::SensorHeader::frame
std::string frame
Definition: types.h:36
armarx::armem::laser_scans::SensorHeader
Definition: types.h:33
armarx::armem::laser_scans::fromAron
SensorHeader fromAron(const arondto::SensorHeader &aronSensorHeader)
Definition: aron_conversions.cpp:20
armarx::core::time::DateTime::toMicroSecondsSinceEpoch
std::int64_t toMicroSecondsSinceEpoch() const
Definition: DateTime.cpp:87
armarx::armem::laser_scans::toAron
int64_t toAron(const armem::Time &timestamp)
Definition: aron_conversions.cpp:58
aron_conversions.h
aron_conversions.h
armarx::core::time::DateTime
Represents a point in time.
Definition: DateTime.h:24
armarx::armem::laser_scans::SensorHeader::agent
std::string agent
Definition: types.h:35
armarx::aron::toAron
void toAron(T &dto, const T &bo)
Framework for converting ARON DTOs (Data Transfer Objects) to C++ BOs (Business Objects) and back.
Definition: aron_conversions.h:77
armarx::armem::laser_scans::LaserScanStamped::header
SensorHeader header
Definition: types.h:42
armarx::armem::laser_scans
Definition: aron_conversions.cpp:15
NDArray.h