aron_conversions.cpp
Go to the documentation of this file.
1 #include "aron_conversions.h"
2 
6 
8 #include <armarx/navigation/core/aron/Trajectory.aron.generated.h>
10 #include <range/v3/range/conversion.hpp>
11 #include <range/v3/view/transform.hpp>
12 
14 {
15 
16 
17  void
18  toAron(arondto::GlobalTrajectoryPoint& dto, const GlobalTrajectoryPoint& bo)
19  {
20  dto.pose = bo.waypoint.pose.matrix();
21  dto.velocity = bo.velocity;
22  }
23 
24  void
25  fromAron(const arondto::GlobalTrajectoryPoint& dto, GlobalTrajectoryPoint& bo)
26  {
27  bo.waypoint.pose = core::Pose(dto.pose);
28  bo.velocity = dto.velocity;
29  }
30 
31  void
32  toAron(arondto::GlobalTrajectory& dto, const GlobalTrajectory& bo)
33  {
34  dto.points = bo.points() |
36  [](const GlobalTrajectoryPoint& boTp) -> arondto::GlobalTrajectoryPoint
37  {
38  arondto::GlobalTrajectoryPoint dtoTp;
39  toAron(dtoTp, boTp);
40  return dtoTp;
41  }) |
42  ranges::to_vector;
43  }
44 
45  void
46  fromAron(const arondto::GlobalTrajectory& dto, GlobalTrajectory& bo)
47  {
49  dto.points |
50  ranges::views::
51  transform( //static_cast<TrajectoryPoint (*)(const arondto::GlobalTrajectoryPoint&)>(&fromAron)
52  [](const arondto::GlobalTrajectoryPoint& dto) -> GlobalTrajectoryPoint
53  {
55  fromAron(dto, bo);
56  return bo;
57  }) |
58  ranges::to_vector);
59  }
60 
61 
62  void
63  toAron(arondto::LocalTrajectoryPoint& dto, const LocalTrajectoryPoint& bo)
64  {
65  dto.pose = bo.pose.matrix();
66  dto.timestamp = bo.timestamp;
67  }
68 
69  void
70  fromAron(const arondto::LocalTrajectoryPoint& dto, LocalTrajectoryPoint& bo)
71  {
72  bo.pose = core::Pose(dto.pose);
73  bo.timestamp = dto.timestamp;
74  }
75 
76  void
77  toAron(arondto::LocalTrajectory& dto, const LocalTrajectory& bo)
78  {
79  dto.points = bo.points() |
81  [](const LocalTrajectoryPoint& boTp) -> arondto::LocalTrajectoryPoint
82  {
83  arondto::LocalTrajectoryPoint dtoTp;
84  toAron(dtoTp, boTp);
85  return dtoTp;
86  }) |
87  ranges::to_vector;
88  }
89 
90  void
91  fromAron(const arondto::LocalTrajectory& dto, LocalTrajectory& bo)
92  {
93  bo =
94  dto.points |
96  transform( //static_cast<TrajectoryPoint (*)(const arondto::GlobalTrajectoryPoint&)>(&fromAron)
97  [](const arondto::LocalTrajectoryPoint& dto) -> LocalTrajectoryPoint
98  {
100  fromAron(dto, bo);
101  return bo;
102  }) |
103  ranges::to_vector;
104  }
105 
106  void
107  toAron(arondto::Twist& dto, const Twist& bo)
108  {
109  dto.linear = bo.linear;
110  dto.angular = bo.angular;
111  }
112 
113  void
114  fromAron(const arondto::Twist& dto, Twist& bo)
115  {
116  bo.linear = dto.linear;
117  bo.angular = dto.angular;
118  }
119 
120  void
121  toAron(armarx::navigation::core::arondto::PIDParams& dto,
123  {
124  aron::toAron(dto.Kp, bo.Kp);
125  aron::toAron(dto.Ki, bo.Ki);
126  aron::toAron(dto.Kd, bo.Kd);
127  }
128 
129 
130  void
131  fromAron(const armarx::navigation::core::arondto::PIDParams& dto,
133  {
134  aron::fromAron(dto.Kp, bo.Kp);
135  aron::fromAron(dto.Ki, bo.Ki);
136  aron::fromAron(dto.Kd, bo.Kd);
137  }
138 
139  void
140  toAron(armarx::navigation::core::arondto::TwistLimits& dto,
142  {
143  aron::toAron(dto.linear, bo.linear);
144  aron::toAron(dto.angular, bo.angular);
145  }
146 
147  void
148  fromAron(const armarx::navigation::core::arondto::TwistLimits& dto,
150  {
151  aron::fromAron(dto.linear, bo.linear);
152  aron::fromAron(dto.angular, bo.angular);
153  }
154 
155  void
156  toAron(armarx::navigation::core::arondto::GoalReachedEvent& dto,
158  {
159  aron::toAron(dto.pose, bo.pose);
160  }
161 
162  void
163  fromAron(const armarx::navigation::core::arondto::GoalReachedEvent& dto,
165  {
166  aron::fromAron(dto.pose, bo.pose.matrix());
167  }
168 
169  void
170  fromAron(const armarx::navigation::core::arondto::GlobalPlanningFailedEvent& dto,
172  {
173  aron::fromAron(dto.message, bo.message);
174  }
175 
176  void
177  toAron(armarx::navigation::core::arondto::GlobalPlanningFailedEvent& dto,
179  {
180  aron::toAron(dto.message, bo.message);
181  }
182 
183  void
184  toAron(armarx::navigation::core::arondto::MovementStartedEvent& dto,
186  {
187  aron::toAron(dto.startPose, bo.startPose.matrix());
188  }
189 
190  void
191  fromAron(const armarx::navigation::core::arondto::MovementStartedEvent& dto,
193  {
194  aron::fromAron(dto.startPose, bo.startPose.matrix());
195  }
196 
197  void
198  toAron(armarx::navigation::core::arondto::WaypointReachedEvent& dto,
200  {
201  aron::toAron(dto.pose, bo.pose);
202  aron::toAron(dto.waypointId, bo.waypointId);
203  }
204 
205  void
206  fromAron(const armarx::navigation::core::arondto::WaypointReachedEvent& dto,
208  {
209  aron::fromAron(dto.pose, bo.pose.matrix());
210  aron::fromAron(dto.waypointId, bo.waypointId);
211  }
212 
213  void
214  toAron(armarx::navigation::core::arondto::InternalErrorEvent& dto,
216  {
217  aron::toAron(dto.pose, bo.pose);
218  aron::toAron(dto.message, bo.message);
219  }
220 
221  void
222  fromAron(const armarx::navigation::core::arondto::InternalErrorEvent& dto,
224  {
225  aron::fromAron(dto.pose, bo.pose.matrix());
226  aron::fromAron(dto.message, bo.message);
227  }
228 
229  void
230  toAron(armarx::navigation::core::arondto::UserAbortTriggeredEvent& dto,
232  {
233  aron::toAron(dto.pose, bo.pose.matrix());
234  }
235 
236  void
237  fromAron(const armarx::navigation::core::arondto::UserAbortTriggeredEvent& dto,
239  {
240  aron::fromAron(dto.pose, bo.pose.matrix());
241  }
242 
243 
244  void
245  toAron(armarx::navigation::core::arondto::SafetyThrottlingTriggeredEvent& dto,
247  {
248  aron::toAron(dto.pose, bo.pose.matrix());
249  aron::toAron(dto.throttlingFactor, bo.throttlingFactor);
250  }
251 
252  void
253  fromAron(const armarx::navigation::core::arondto::SafetyThrottlingTriggeredEvent& dto,
255  {
256  aron::fromAron(dto.pose, bo.pose.matrix());
257  aron::fromAron(dto.throttlingFactor, bo.throttlingFactor);
258  }
259 
260  void
261  toAron(armarx::navigation::core::arondto::SafetyStopTriggeredEvent& dto,
263  {
264  aron::toAron(dto.pose, bo.pose.matrix());
265  }
266 
267  void
268  fromAron(const armarx::navigation::core::arondto::SafetyStopTriggeredEvent& dto,
270  {
271  aron::fromAron(dto.pose, bo.pose.matrix());
272  }
273 
274  void
275  fromAron(const armarx::navigation::core::arondto::LocalPlanningFailedEvent& dto,
277  {
278  aron::fromAron(dto.message, bo.message);
279  }
280 
281  void
282  toAron(armarx::navigation::core::arondto::LocalPlanningFailedEvent& dto,
284  {
285  aron::toAron(dto.message, bo.message);
286  }
287 
288 } // namespace armarx::navigation::core
armarx::navigation::core::GlobalTrajectory
Definition: Trajectory.h:68
armarx::navigation::core::PIDParams
Definition: types.h:84
armarx::navigation::core::Pose
Eigen::Isometry3f Pose
Definition: basic_types.h:31
armarx::navigation::core::fromAron
void fromAron(const arondto::GlobalTrajectoryPoint &dto, GlobalTrajectoryPoint &bo)
Definition: aron_conversions.cpp:25
armarx::navigation::core::InternalErrorEvent
Event describing the occurance of an internal unhandled error.
Definition: events.h:101
armarx::navigation::core::SafetyThrottlingTriggeredEvent
Event desciribing that a significant safety throttling factor was reached.
Definition: events.h:68
armarx::navigation::core
This file is part of ArmarX.
Definition: aron_conversions.cpp:13
armarx::navigation::core::toAron
void toAron(arondto::GlobalTrajectoryPoint &dto, const GlobalTrajectoryPoint &bo)
Definition: aron_conversions.cpp:18
armarx::navigation::core::GlobalTrajectoryPoint
Definition: Trajectory.h:35
armarx::navigation::core::Twist
Definition: basic_types.h:53
armarx::navigation::core::LocalTrajectoryPoint
Definition: Trajectory.h:152
armarx::navigation::core::SafetyStopTriggeredEvent
Event describing that for security reasons, the robot was stopped completely.
Definition: events.h:84
core.h
armarx::navigation::core::UserAbortTriggeredEvent
Event describing that the user aborted the current execution.
Definition: events.h:93
armarx::navigation::core::TwistLimits
Definition: types.h:91
armarx::navigation::core::LocalTrajectory
Definition: Trajectory.h:167
armarx::navigation::core::GlobalPlanningFailedEvent
Definition: events.h:31
armarx::navigation::core::GoalReachedEvent
Event describing that the targeted goal was successfully reached.
Definition: events.h:49
aron_conversions.h
Trajectory.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:74
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::core::WaypointReachedEvent
Event describing that a user-defined waypoint was successfully reached.
Definition: events.h:57
Trajectory.h
armarx::aron::fromAron
void fromAron(const T &dto, T &bo)
Definition: aron_conversions.h:79
types.h
armarx::navigation::core::LocalPlanningFailedEvent
Definition: events.h:36
armarx::aron::bo
const std::optional< BoT > & bo
Definition: aron_conversions.h:168
armarx::navigation::core::MovementStartedEvent
Definition: events.h:41