MemoryParameterizationService.cpp
Go to the documentation of this file.
2 
3 #include <string>
4 #include <unordered_map>
5 
9 
10 #include <RobotAPI/interface/aron/Aron.h>
12 
16 
18 {
19  bool
21  const std::string& clientId,
22  const armarx::core::time::DateTime& timestamp)
23  {
24  ARMARX_CHECK_NOT_NULL(writer);
25 
26  using aron::data::Dict;
27 
28  const auto getElementOrNull = [&params](const core::StackLayer& layer) -> Dict::PointerType
29  {
30  const std::string key = core::StackLayerNames.to_name(layer);
31 
32  if (params->hasElement(key))
33  {
34  return Dict::DynamicCast(params->getElement(key));
35  }
36 
37  ARMARX_INFO << "Skipping '" << key << "'";
38 
39  return nullptr;
40  };
41 
42  // convert to more structured representation
43  std::unordered_map<core::StackLayer, Dict::PointerType> cfgs;
44 
45  if (const auto globalPlannerCfg = getElementOrNull(core::StackLayer::GlobalPlanner))
46  {
47  cfgs.emplace(core::StackLayer::GlobalPlanner, globalPlannerCfg);
48  }
49 
50  if (const auto localPlannerCfg = getElementOrNull(core::StackLayer::LocalPlanner))
51  {
52  cfgs.emplace(core::StackLayer::LocalPlanner, localPlannerCfg);
53  }
54 
55  if (const auto trajectoryControllerCfg =
57  {
58  cfgs.emplace(core::StackLayer::TrajectoryController, trajectoryControllerCfg);
59  }
60 
61  if (const auto safetyControllerCfg = getElementOrNull(core::StackLayer::SafetyGuard))
62  {
63  cfgs.emplace(core::StackLayer::SafetyGuard, safetyControllerCfg);
64  }
65 
66  return writer->store(cfgs, clientId, timestamp);
67  }
68 
69  bool
71  const std::string& clientId,
72  const armarx::core::time::DateTime& timestamp)
73  {
74  const auto dict = aron::data::Dict::FromAronDictDTO(params);
75  return store(dict, clientId, timestamp);
76  }
77 
81  reader(reader), writer(writer)
82  {
83  }
84 } // namespace armarx::navigation::server
armarx::navigation::server::MemoryParameterizationService::store
bool store(const aron::data::DictPtr &params, const std::string &clientId, const armarx::core::time::DateTime &timestamp)
Definition: MemoryParameterizationService.cpp:20
armarx::navigation::memory::client::param::Writer
Definition: Writer.h:38
armarx::navigation::core::StackLayer::GlobalPlanner
@ GlobalPlanner
DateTime.h
ARMARX_CHECK_NOT_NULL
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
Definition: ExpressionException.h:206
armarx::navigation::server::MemoryParameterizationService::MemoryParameterizationService
MemoryParameterizationService(memory::client::param::Reader *reader, memory::client::param::Writer *writer)
Definition: MemoryParameterizationService.cpp:78
armarx::navigation::memory::client::param::Writer::store
bool store(const std::unordered_map< core::StackLayer, aron::data::DictPtr > &stack, const std::string &clientID, const armarx::core::time::DateTime &timestamp)
Definition: Writer.cpp:21
Reader.h
constants.h
MemoryParameterizationService.h
Dict.h
armarx::aron::data::Dict::FromAronDictDTO
static PointerType FromAronDictDTO(const data::dto::DictPtr &aron)
Definition: Dict.cpp:130
armarx::navigation::core::StackLayer::TrajectoryController
@ TrajectoryController
armarx::navigation::server
This file is part of ArmarX.
Definition: EventPublishingInterface.h:6
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::navigation::core::StackLayer::SafetyGuard
@ SafetyGuard
armarx::navigation::core::StackLayerNames
const simox::meta::EnumNames< StackLayer > StackLayerNames
Definition: constants.h:44
Writer.h
ExpressionException.h
armarx::navigation::core::StackLayer::LocalPlanner
@ LocalPlanner
armarx::core::time::DateTime
Represents a point in time.
Definition: DateTime.h:24
armarx::aron::data::DictPtr
std::shared_ptr< Dict > DictPtr
Definition: Dict.h:41
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:181
armarx::navigation::memory::client::param::Reader
Definition: Reader.h:31
Logging.h
armarx::navigation::core::StackLayer
StackLayer
Definition: constants.h:36
armarx::aron::data::Dict
Definition: Dict.h:44