ice_conversions.cpp
Go to the documentation of this file.
1#include "ice_conversions.h"
2
3#include <algorithm>
4#include <iterator>
5
10
12
13#include <armarx/navigation/client/ice/NavigatorInterface.h>
17
19{
20
42
43 WaypointTarget
45 {
46 ARMARX_CHECK((not waypoint.locationId.empty()) or waypoint.pose)
47 << "Either `locationId` or `pose` has to be set.";
48
49 if (not waypoint.locationId.empty())
50 {
51 return WaypointTarget{
52 .locationId = waypoint.locationId, .strategy = defrost(waypoint.strategy)
53 // .config = defrost(waypoint.config)
54 };
55 }
56
57 if (waypoint.pose)
58 {
59 return WaypointTarget{
60 .pose = core::Pose(armarx::fromIce(waypoint.pose)),
61 .strategy = defrost(waypoint.strategy)
62 // .config = defrost(waypoint.config)
63 };
64 }
65
66 throw armarx::LocalException("Invalid use of client::detail::Waypoint: either `locationId` "
67 "or `pose` has to be set!");
68 }
69
72 {
74 targets.reserve(waypoints.size());
75
76 std::transform(waypoints.begin(),
77 waypoints.end(),
78 std::back_inserter(targets),
79 [](const auto& wp) { return defrost(wp); });
80
81 return targets;
82 }
83
86 {
88 .target = core::Pose(alternative.target),
89 .priority = alternative.priority,
90 };
91 }
92
93 std::vector<core::TargetAlternative>
95 {
96 std::vector<core::TargetAlternative> result;
97 result.reserve(alternatives.size());
98
99 std::transform(alternatives.begin(),
100 alternatives.end(),
101 std::back_inserter(result),
102 [](const auto& alt) { return defrost(alt); });
103
104 return result;
105 }
106
127
130 {
131 return client::detail::Waypoint{.locationId = target.locationId.value_or(""),
132 .pose =
133 target.pose ? toIce(target.pose->matrix()) : nullptr,
134 .strategy = freeze(target.strategy)};
135 }
136
139 {
141 waypoints.reserve(targets.size());
142
143 std::transform(targets.begin(),
144 targets.end(),
145 std::back_inserter(waypoints),
146 [](const auto& wp) { return freeze(wp); });
147
148 return waypoints;
149 }
150
152 freeze(const core::TargetAlternative& alternative)
153 {
155 .target = alternative.target.matrix(),
156 .priority = alternative.priority,
157 };
158 }
159
161 freeze(const std::vector<core::TargetAlternative>& alternatives)
162 {
164 result.reserve(alternatives.size());
165
166 std::transform(alternatives.begin(),
167 alternatives.end(),
168 std::back_inserter(result),
169 [](const auto& alt) { return freeze(alt); });
170
171 return result;
172 }
173
174} // namespace armarx::navigation::client
#define ARMARX_UNEXPECTED_ENUM_VALUE(EnumType, value)
Throw an UnexpectedEnumValueException.
Brief description of class targets.
Definition targets.h:39
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
Definition Logging.h:190
sequence< TargetAlternative > TargetAlternatives
This file is part of ArmarX.
client::detail::GlobalPlanningStrategy freeze(const client::GlobalPlanningStrategy &strategy)
client::GlobalPlanningStrategy defrost(const client::detail::GlobalPlanningStrategy &strategy)
std::vector< WaypointTarget > WaypointTargets
Eigen::Isometry3f Pose
Definition basic_types.h:31
void fromIce(const std::map< IceKeyT, IceValueT > &iceMap, boost::container::flat_map< CppKeyT, CppValueT > &cppMap)
void toIce(std::map< IceKeyT, IceValueT > &iceMap, const boost::container::flat_map< CppKeyT, CppValueT > &cppMap)