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
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,
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
std::string timestamp()
SensorHeader fromAron(const arondto::SensorHeader &aronSensorHeader)
int64_t toAron(const armem::Time &timestamp)
armarx::core::time::DateTime Time
void fromAron(const T &dto, T &bo)
void toAron(T &dto, const T &bo)
Framework for converting ARON DTOs (Data Transfer Objects) to C++ BOs (Business Objects) and back.