MemoryParameterizationService.cpp
Go to the documentation of this file.
2 
3 #include <unordered_map>
4 
6 
8 
10 
12 {
13  bool
15  const std::string& clientId,
16  const armarx::core::time::DateTime& timestamp)
17  {
18  ARMARX_CHECK_NOT_NULL(writer);
19 
20  using aron::data::Dict;
21 
22  const auto getElementOrNull = [&params](const core::StackLayer& layer) -> Dict::PointerType
23  {
24  const std::string key = core::StackLayerNames.to_name(layer);
25 
26  if (params->hasElement(key))
27  {
28  return Dict::DynamicCast(params->getElement(key));
29  }
30 
31  ARMARX_INFO << "Skipping '" << key << "'";
32 
33  return nullptr;
34  };
35 
36  // convert to more structured representation
37  std::unordered_map<core::StackLayer, Dict::PointerType> cfgs;
38 
39  if (const auto globalPlannerCfg = getElementOrNull(core::StackLayer::GlobalPlanner))
40  {
41  cfgs.emplace(core::StackLayer::GlobalPlanner, globalPlannerCfg);
42  }
43 
44  if (const auto localPlannerCfg = getElementOrNull(core::StackLayer::LocalPlanner))
45  {
46  cfgs.emplace(core::StackLayer::LocalPlanner, localPlannerCfg);
47  }
48 
49  if (const auto trajectoryControllerCfg =
51  {
52  cfgs.emplace(core::StackLayer::TrajectoryController, trajectoryControllerCfg);
53  }
54 
55  if (const auto safetyControllerCfg = getElementOrNull(core::StackLayer::SafetyController))
56  {
57  cfgs.emplace(core::StackLayer::SafetyController, safetyControllerCfg);
58  }
59 
60  return writer->store(cfgs, clientId, timestamp);
61  }
62 
63  bool
65  const std::string& clientId,
66  const armarx::core::time::DateTime& timestamp)
67  {
68  const auto dict = aron::data::Dict::FromAronDictDTO(params);
69  return store(dict, clientId, timestamp);
70  }
71 
75  reader(reader), writer(writer)
76  {
77  }
78 } // namespace armarx::navigation::server
armarx::navigation::core::StackLayer::LocalPlanner
@ LocalPlanner
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:14
armarx::navigation::memory::client::param::Writer
Definition: Writer.h:33
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:72
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:12
constants.h
MemoryParameterizationService.h
armarx::navigation::core::StackLayer::GlobalPlanner
@ GlobalPlanner
Dict.h
armarx::aron::data::Dict::FromAronDictDTO
static PointerType FromAronDictDTO(const data::dto::DictPtr &aron)
Definition: Dict.cpp:129
armarx::navigation::server
This file is part of ArmarX.
Definition: EventPublishingInterface.h:10
armarx::navigation::core::StackLayerNames
const simox::meta::EnumNames< StackLayer > StackLayerNames
Definition: constants.h:41
armarx::navigation::core::StackLayer::TrajectoryController
@ TrajectoryController
ExpressionException.h
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:174
armarx::navigation::core::StackLayer
StackLayer
Definition: constants.h:33
armarx::navigation::core::StackLayer::SafetyController
@ SafetyController
armarx::navigation::memory::client::param::Reader
Definition: Reader.h:29
armarx::aron::data::Dict
Definition: Dict.h:44