aron_conversions.cpp
Go to the documentation of this file.
1#include "aron_conversions.h"
2
3#include <optional>
4
6
13#include <armarx/navigation/global_planning/aron/AStarParams.aron.generated.h>
14#include <armarx/navigation/global_planning/aron/GlobalPlannerParams.aron.generated.h>
15#include <armarx/navigation/global_planning/aron/OrientationOptimizerParams.aron.generated.h>
16#include <armarx/navigation/global_planning/aron/Point2PointParams.aron.generated.h>
17#include <armarx/navigation/global_planning/aron/SPFAParams.aron.generated.h>
18#include <armarx/navigation/global_planning/aron/AStarWithOrientationParams.aron.generated.h>
20
22{
23 void
24 toAron(arondto::GlobalPlannerParams& dto, const GlobalPlannerParams& bo)
25 {
26 ARMARX_ERROR << "Trying to convert GlobalPlannerParams. This is probably not what you want";
27 }
28
29 void
30 fromAron(const arondto::GlobalPlannerParams& dto, GlobalPlannerParams& bo)
31 {
32 ARMARX_ERROR << "Trying to convert GlobalPlannerParams. This is probably not what you want";
33 }
34
35 void
36 toAron(arondto::Point2PointParams& dto, const Point2PointParams& bo)
37 {
38 // fromAron(static_cast<const arondto::GlobalPlannerParams&>(dto), static_cast<const GlobalPlannerParams&>(bo));
39 aron::toAron(dto.includeStartPose, bo.includeStartPose);
40 }
41
42 void
43 fromAron(const arondto::Point2PointParams& dto, Point2PointParams& bo)
44 {
45 // fromAron(static_cast<arondto::GlobalPlannerParams&>(dto), static_cast<GlobalPlannerParams&>(bo));
46 aron::fromAron(dto.includeStartPose, bo.includeStartPose);
47 }
48
49 void
50 toAron(arondto::AStarParams& dto, const AStarParams& bo)
51 {
52 // toAron(static_cast<arondto::GlobalPlannerParams&>(dto),
53 // static_cast<const GlobalPlannerParams&>(bo));
54
55 aron::toAron(dto.resampleDistance, bo.resampleDistance);
56 }
57
58 void
59 fromAron(const arondto::AStarParams& dto, AStarParams& bo)
60 {
61 // fromAron(static_cast<const arondto::GlobalPlannerParams&>(dto),
62 // static_cast<GlobalPlannerParams&>(bo));
63
64 aron::fromAron(dto.resampleDistance, bo.resampleDistance);
65 }
66
67 void
68 toAron(arondto::SPFAParams& dto, const SPFAParams& bo)
69 {
70 // toAron(static_cast<arondto::GlobalPlannerParams&>(dto),
71 // static_cast<const GlobalPlannerParams&>(bo));
72
73 aron::toAron(dto.resampleDistance, bo.resampleDistance);
74 algorithms::toAron(dto.algo, bo.algo);
75
76 toAron(dto.optimizer, bo.optimizerParams);
77 }
78
79 void
80 fromAron(const arondto::SPFAParams& dto, SPFAParams& bo)
81 {
82 // fromAron(static_cast<const arondto::GlobalPlannerParams&>(dto),
83 // static_cast<GlobalPlannerParams&>(bo));
84
85 aron::fromAron(dto.resampleDistance, bo.resampleDistance);
86
87 algorithms::fromAron(dto.algo, bo.algo);
88
89 fromAron(dto.optimizer, bo.optimizerParams);
90 }
91
92 // std::optional
93 template <typename DtoT, typename BoT>
94 void
95 toAron(std::optional<DtoT>& dto, const std::optional<BoT>& bo)
96 {
97 if (bo.has_value())
98 {
99 dto = DtoT{};
100 toAron(*dto, *bo);
101 }
102 else
103 {
104 dto = std::nullopt;
105 }
106 }
107
108 void
109 toAron(arondto::OrientationOptimizerParams& dto,
111 {
112 aron::toAron(dto.iterations, bo.iterations);
113 aron::toAron(dto.movementDirWeightStart, bo.movementDirWeightStart);
114 aron::toAron(dto.movementDirWeightEnd, bo.movementDirWeightEnd);
115
116 aron::toAron(dto.smoothnessWeight, bo.smoothnessWeight);
117 aron::toAron(dto.smoothnessWeightStartGoal, bo.smoothnessWeightStartGoal);
118
119 aron::toAron(dto.priorStartWeight, bo.priorStartWeight);
120 aron::toAron(dto.priorEndWeight, bo.priorEndWeight);
121
122 aron::toAron(dto.startGoalDistanceThreshold, bo.startGoalDistanceThreshold);
123
124 toAron(dto.predefinedRotationDirection, bo.predefinedRotationDirection);
125 }
126
127 template <typename DtoT, typename BoT>
128 void
129 fromAron(const std::optional<DtoT>& dto, std::optional<BoT>& bo)
130 {
131 if (dto.has_value())
132 {
133 bo = BoT{};
134 fromAron(*dto, *bo);
135 }
136 else
137 {
138 bo = std::nullopt;
139 }
140 }
141
142 void
143 fromAron(const arondto::OrientationOptimizerParams& dto,
145 {
146 aron::fromAron(dto.iterations, bo.iterations);
147 aron::fromAron(dto.movementDirWeightStart, bo.movementDirWeightStart);
148 aron::fromAron(dto.movementDirWeightEnd, bo.movementDirWeightEnd);
149
150 aron::fromAron(dto.smoothnessWeight, bo.smoothnessWeight);
151 aron::fromAron(dto.smoothnessWeightStartGoal, bo.smoothnessWeightStartGoal);
152
153 aron::fromAron(dto.priorStartWeight, bo.priorStartWeight);
154 aron::fromAron(dto.priorEndWeight, bo.priorEndWeight);
155
156 aron::fromAron(dto.startGoalDistanceThreshold, bo.startGoalDistanceThreshold);
157
158 fromAron(dto.predefinedRotationDirection, bo.predefinedRotationDirection);
159 }
160
161 void
162 toAron(arondto::RotationDirection& dto, const optimization::RotationDirection& bo)
163 {
164 switch (bo)
165 {
167 dto.value = arondto::RotationDirection::ANY;
168 break;
170 dto.value = arondto::RotationDirection::CLOCK_WISE;
171 break;
173 dto.value = arondto::RotationDirection::COUNTER_CLOCK_WISE;
174 break;
175 default:
176 ARMARX_ERROR << "Error converting RotationDirection: switch-case not comprehensive!";
177 }
178 }
179
180 void
181 fromAron(const arondto::RotationDirection& dto, optimization::RotationDirection& bo)
182 {
183 switch (dto.value)
184 {
185 case arondto::rotation_direction_details::Enum::ANY:
187 break;
188 case arondto::rotation_direction_details::Enum::CLOCK_WISE:
190 break;
191 case arondto::rotation_direction_details::Enum::COUNTER_CLOCK_WISE:
193 break;
194 default:
195 ARMARX_ERROR << "Error converting RotationDirection: switch-case not comprehensive!";
196 }
197 }
198
199 void
200 toAron(arondto::AStarWithOrientationParams& dto, const AStarWithOrientationParams& bo)
201 {
202
203 }
204
205 void
206 fromAron(const arondto::AStarWithOrientationParams& dto, AStarWithOrientationParams& bo)
207 {
208 }
209
210
211} // namespace armarx::navigation::global_planning::aron_conv
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
Definition Logging.h:196
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.
armarx::aron::data::DictPtr toAron(const Costmap &bo)
Costmap fromAron(const armem::wm::EntityInstance &entityInstance)
void toAron(arondto::GlobalPlannerParams &dto, const GlobalPlannerParams &bo)
void fromAron(const arondto::GlobalPlannerParams &dto, GlobalPlannerParams &bo)
optimization::OrientationOptimizerParams optimizerParams
Definition SPFA.h:54
algorithms::spfa::ShortestPathFasterAlgorithm::Parameters algo
Definition SPFA.h:52