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,
23 {
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 " << QUOTED(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,
73 {
74 const auto dict = aron::data::Dict::FromAronDictDTO(params);
75 return store(dict, clientId, timestamp);
76 }
77
84} // namespace armarx::navigation::server
std::string timestamp()
#define QUOTED(x)
static PointerType FromAronDictDTO(const data::dto::DictPtr &aron)
Definition Dict.cpp:130
Represents a point in time.
Definition DateTime.h:25
MemoryParameterizationService(memory::client::param::Reader *reader, memory::client::param::Writer *writer)
bool store(const aron::data::DictPtr &params, const std::string &clientId, const armarx::core::time::DateTime &timestamp)
#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...
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
::IceInternal::Handle< Dict > DictPtr
std::shared_ptr< Dict > DictPtr
Definition Dict.h:42
const simox::meta::EnumNames< StackLayer > StackLayerNames
Definition constants.h:46
This file is part of ArmarX.