ice_conversions.cpp
Go to the documentation of this file.
1 #include "ice_conversions.h"
2 
7 
9 
11 
13 {
14 
17  {
19 
20  switch (strategy)
21  {
23  ARMARX_IMPORTANT << "Free navigation";
25  break;
27  ARMARX_IMPORTANT << "Point2Point navigation";
29  break;
30  default:
32  }
33 
34  return strgy;
35  }
36  WaypointTarget
38  {
39  ARMARX_CHECK((not waypoint.locationId.empty()) or waypoint.pose)
40  << "Either `locationId` or `pose` has to be set.";
41 
42  if (not waypoint.locationId.empty())
43  {
44  return WaypointTarget{
45  .locationId = waypoint.locationId, .strategy = defrost(waypoint.strategy)
46  // .config = defrost(waypoint.config)
47  };
48  }
49 
50  if (waypoint.pose)
51  {
52  return WaypointTarget{
53  .pose = core::Pose(armarx::fromIce(waypoint.pose)),
54  .strategy = defrost(waypoint.strategy)
55  // .config = defrost(waypoint.config)
56  };
57  }
58 
59  throw armarx::LocalException("Invalid use of client::detail::Waypoint: either `locationId` "
60  "or `pose` has to be set!");
61  }
64  {
65  WaypointTargets targets;
66  targets.reserve(waypoints.size());
67 
68  std::transform(waypoints.begin(),
69  waypoints.end(),
70  std::back_inserter(targets),
71  [](const auto& wp) { return defrost(wp); });
72 
73  return targets;
74  }
75 
78  {
81 
82  switch (strategy)
83  {
86  break;
89  break;
90  default:
92  }
93 
94  return strgy;
95  }
96 
99  {
100  return client::detail::Waypoint{.locationId = target.locationId.value_or(""),
101  .pose =
102  target.pose ? toIce(target.pose->matrix()) : nullptr,
103  .strategy = freeze(target.strategy)};
104  }
105 
108  {
109  client::detail::Waypoints waypoints;
110  waypoints.reserve(targets.size());
111 
112  std::transform(targets.begin(),
113  targets.end(),
114  std::back_inserter(waypoints),
115  [](const auto& wp) { return freeze(wp); });
116 
117  return waypoints;
118  }
119 } // namespace armarx::navigation::client
ice_conversions.h
armarx::navigation::client::detail::Free
@ Free
Definition: NavigatorInterface.ice:45
armarx::navigation::client::detail::GlobalPlanningStrategy
GlobalPlanningStrategy
Definition: NavigatorInterface.ice:43
ARMARX_UNEXPECTED_ENUM_VALUE
#define ARMARX_UNEXPECTED_ENUM_VALUE(EnumType, value)
Throw an UnexpectedEnumValueException.
Definition: UnexpectedEnumValueException.h:61
ARMARX_IMPORTANT
#define ARMARX_IMPORTANT
Definition: Logging.h:183
LocalException.h
armarx::navigation::core::Pose
Eigen::Isometry3f Pose
Definition: basic_types.h:31
armarx::navigation::client::GlobalPlanningStrategy::Free
@ Free
armarx::navigation::client::freeze
client::detail::GlobalPlanningStrategy freeze(const client::GlobalPlanningStrategy &strategy)
Definition: ice_conversions.cpp:77
Pose.h
boost::target
Vertex target(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:688
UnexpectedEnumValueException.h
armarx::navigation::client
This file is part of ArmarX.
Definition: ComponentPlugin.cpp:20
armarx::navigation::client::WaypointTarget::pose
std::optional< core::Pose > pose
Definition: ice_conversions.h:41
armarx::navigation::client::detail::Waypoint::locationId
string locationId
Definition: NavigatorInterface.ice:52
ARMARX_CHECK
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
Definition: ExpressionException.h:82
armarx::toIce
void toIce(std::map< IceKeyT, IceValueT > &iceMap, const boost::container::flat_map< CppKeyT, CppValueT > &cppMap)
Definition: ice_conversions_boost_templates.h:15
armarx::navigation::client::WaypointTarget::locationId
std::optional< std::string > locationId
Definition: ice_conversions.h:40
armarx::navigation::client::defrost
client::GlobalPlanningStrategy defrost(const client::detail::GlobalPlanningStrategy &strategy)
Definition: ice_conversions.cpp:16
armarx::navigation::client::detail::Waypoints
sequence< Waypoint > Waypoints
Definition: NavigatorInterface.ice:58
armarx::navigation::client::detail::Point2Point
@ Point2Point
Definition: NavigatorInterface.ice:46
armarx::navigation::client::WaypointTarget
Definition: ice_conversions.h:38
armarx::fromIce
void fromIce(const std::map< IceKeyT, IceValueT > &iceMap, boost::container::flat_map< CppKeyT, CppValueT > &cppMap)
Definition: ice_conversions_boost_templates.h:26
ExpressionException.h
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::client::GlobalPlanningStrategy
GlobalPlanningStrategy
Definition: types.h:27
Logging.h
armarx::navigation::client::detail::Waypoint::strategy
GlobalPlanningStrategy strategy
Definition: NavigatorInterface.ice:55
armarx::navigation::client::detail::Waypoint::pose
armarx::PoseBase pose
Definition: NavigatorInterface.ice:53
armarx::navigation::client::GlobalPlanningStrategy::Point2Point
@ Point2Point
types.h
armarx::navigation::client::WaypointTargets
std::vector< WaypointTarget > WaypointTargets
Definition: ice_conversions.h:81
armarx::navigation::client::detail::Waypoint
Definition: NavigatorInterface.ice:50