aron_conversions.cpp
Go to the documentation of this file.
1 #include "aron_conversions.h"
2 
3 #include <optional>
4 
6 
12 #include <armarx/navigation/global_planning/aron/AStarParams.aron.generated.h>
13 #include <armarx/navigation/global_planning/aron/GlobalPlannerParams.aron.generated.h>
14 #include <armarx/navigation/global_planning/aron/OrientationOptimizerParams.aron.generated.h>
15 #include <armarx/navigation/global_planning/aron/Point2PointParams.aron.generated.h>
16 #include <armarx/navigation/global_planning/aron/SPFAParams.aron.generated.h>
18 
20 {
21  void
22  toAron(arondto::GlobalPlannerParams& dto, const GlobalPlannerParams& bo)
23  {
24  }
25 
26  void
27  fromAron(const arondto::GlobalPlannerParams& dto, GlobalPlannerParams& bo)
28  {
29  }
30 
31  void
32  toAron(arondto::Point2PointParams& dto, const Point2PointParams& bo)
33  {
34  // fromAron(static_cast<const arondto::GlobalPlannerParams&>(dto), static_cast<const GlobalPlannerParams&>(bo));
35  aron::toAron(dto.includeStartPose, bo.includeStartPose);
36  aron::toAron(dto.velocity, bo.velocity);
37  }
38 
39  void
40  fromAron(const arondto::Point2PointParams& dto, Point2PointParams& bo)
41  {
42  // fromAron(static_cast<arondto::GlobalPlannerParams&>(dto), static_cast<GlobalPlannerParams&>(bo));
43  aron::fromAron(dto.includeStartPose, bo.includeStartPose);
44  aron::fromAron(dto.velocity, bo.velocity);
45  }
46 
47  void
48  toAron(arondto::AStarParams& dto, const AStarParams& bo)
49  {
50  // toAron(static_cast<arondto::GlobalPlannerParams&>(dto),
51  // static_cast<const GlobalPlannerParams&>(bo));
52 
53  aron::toAron(dto.linearVelocity, bo.linearVelocity);
54  aron::toAron(dto.resampleDistance, bo.resampleDistance);
55  }
56 
57  void
58  fromAron(const arondto::AStarParams& dto, AStarParams& bo)
59  {
60  // fromAron(static_cast<const arondto::GlobalPlannerParams&>(dto),
61  // static_cast<GlobalPlannerParams&>(bo));
62 
63  aron::fromAron(dto.linearVelocity, bo.linearVelocity);
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.linearVelocity, bo.linearVelocity);
74  aron::toAron(dto.resampleDistance, bo.resampleDistance);
75  algorithms::toAron(dto.algo, bo.algo);
76 
77  toAron(dto.optimizer, bo.optimizerParams);
78  }
79 
80  void
81  fromAron(const arondto::SPFAParams& dto, SPFAParams& bo)
82  {
83  // fromAron(static_cast<const arondto::GlobalPlannerParams&>(dto),
84  // static_cast<GlobalPlannerParams&>(bo));
85 
86  aron::fromAron(dto.linearVelocity, bo.linearVelocity);
87  aron::fromAron(dto.resampleDistance, bo.resampleDistance);
88 
89  algorithms::fromAron(dto.algo, bo.algo);
90 
91  fromAron(dto.optimizer, bo.optimizerParams);
92  }
93 
94  // std::optional
95  template <typename DtoT, typename BoT>
96  void
97  toAron(std::optional<DtoT>& dto, const std::optional<BoT>& bo)
98  {
99  if (bo.has_value())
100  {
101  dto = DtoT{};
102  toAron(*dto, *bo);
103  }
104  else
105  {
106  dto = std::nullopt;
107  }
108  }
109 
110  void
111  toAron(arondto::OrientationOptimizerParams& dto,
113  {
114  aron::toAron(dto.iterations, bo.iterations);
115  aron::toAron(dto.movementDirWeightStart, bo.movementDirWeightStart);
116  aron::toAron(dto.movementDirWeightEnd, bo.movementDirWeightEnd);
117 
118  aron::toAron(dto.smoothnessWeight, bo.smoothnessWeight);
119  aron::toAron(dto.smoothnessWeightStartGoal, bo.smoothnessWeightStartGoal);
120 
121  aron::toAron(dto.priorStartWeight, bo.priorStartWeight);
122  aron::toAron(dto.priorEndWeight, bo.priorEndWeight);
123 
124  aron::toAron(dto.startGoalDistanceThreshold, bo.startGoalDistanceThreshold);
125 
126  toAron(dto.predefinedRotationDirection, bo.predefinedRotationDirection);
127  }
128 
129  template <typename DtoT, typename BoT>
130  void
131  fromAron(const std::optional<DtoT>& dto, std::optional<BoT>& bo)
132  {
133  if (dto.has_value())
134  {
135  bo = BoT{};
136  fromAron(*dto, *bo);
137  }
138  else
139  {
140  bo = std::nullopt;
141  }
142  }
143 
144  void
145  fromAron(const arondto::OrientationOptimizerParams& dto,
147  {
148  aron::fromAron(dto.iterations, bo.iterations);
149  aron::fromAron(dto.movementDirWeightStart, bo.movementDirWeightStart);
150  aron::fromAron(dto.movementDirWeightEnd, bo.movementDirWeightEnd);
151 
152  aron::fromAron(dto.smoothnessWeight, bo.smoothnessWeight);
153  aron::fromAron(dto.smoothnessWeightStartGoal, bo.smoothnessWeightStartGoal);
154 
155  aron::fromAron(dto.priorStartWeight, bo.priorStartWeight);
156  aron::fromAron(dto.priorEndWeight, bo.priorEndWeight);
157 
158  aron::fromAron(dto.startGoalDistanceThreshold, bo.startGoalDistanceThreshold);
159 
160  fromAron(dto.predefinedRotationDirection, bo.predefinedRotationDirection);
161  }
162 
163  void
165  {
166  switch (bo)
167  {
169  dto.value = arondto::RotationDirection::CLOCK_WISE;
170  break;
172  dto.value = arondto::RotationDirection::COUNTER_CLOCK_WISE;
173  break;
174  }
175  }
176 
177  void
179  {
180  switch (dto.value)
181  {
182  case arondto::rotation_direction_details::Enum::CLOCK_WISE:
184  break;
185  case arondto::rotation_direction_details::Enum::COUNTER_CLOCK_WISE:
187  break;
188  }
189  }
190 
191 
192 } // namespace armarx::navigation::global_planning::aron_conv
SPFA.h
armarx::navigation::global_planning::AStarParams
Parameters for AStar.
Definition: AStar.h:36
aron_conversions.h
armarx::navigation::algorithms::fromAron
Costmap fromAron(const armem::wm::EntityInstance &entityInstance)
Definition: aron_conversions.cpp:74
OrientationOptimizer.h
armarx::navigation::global_planning::GlobalPlannerParams
Parameters for GlobalPlanner.
Definition: GlobalPlanner.h:47
aron_conversions.h
armarx::navigation::global_planning::aron_conv::toAron
void toAron(arondto::GlobalPlannerParams &dto, const GlobalPlannerParams &bo)
Definition: aron_conversions.cpp:22
armarx::navigation::global_planning::optimization::OrientationOptimizerParams
Definition: OrientationOptimizer.h:37
Point2Point.h
armarx::navigation::global_planning::optimization::RotationDirection::CounterClockwise
@ CounterClockwise
armarx::navigation::global_planning::aron_conv::fromAron
void fromAron(const arondto::GlobalPlannerParams &dto, GlobalPlannerParams &bo)
Definition: aron_conversions.cpp:27
armarx::navigation::global_planning::aron_conv
Definition: aron_conversions.cpp:19
armarx::navigation::algorithms::toAron
aron::data::NDArrayPtr toAron(const Costmap::Grid &grid)
Definition: aron_conversions.cpp:29
GlobalPlanner.h
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::navigation::global_planning::Point2PointParams
Parameters for Point2Point.
Definition: Point2Point.h:41
armarx::navigation::global_planning::optimization::RotationDirection::Clockwise
@ Clockwise
armarx::navigation::global_planning::optimization::RotationDirection
RotationDirection
Definition: OrientationOptimizer.h:31
armarx::aron::fromAron
void fromAron(const T &dto, T &bo)
Definition: aron_conversions.h:84
armarx::aron::bo
const std::optional< BoT > & bo
Definition: aron_conversions.h:174
armarx::navigation::global_planning::SPFAParams
Parameters for AStar.
Definition: SPFA.h:41
AStar.h