Plugin.cpp
Go to the documentation of this file.
1#include "Plugin.h"
2
4
5namespace armarx
6{
7
12} // namespace armarx
13
14namespace armarx::plugins
15{
16
17 void
19 {
21
22 ARMARX_INFO << "Got as config: " << properties.configJson;
23
24 nlohmann::json config = nlohmann::json::parse(properties.configJson);
25
26 if (config.contains(CONFIG_ROBOT_NAME))
27 {
28 robot.name = config[CONFIG_ROBOT_NAME];
29 }
30
31 if (config.contains(CONFIG_XML_PACKAGE_PATH))
32 {
33 auto config_pp = config[CONFIG_XML_PACKAGE_PATH];
34 if (config_pp.contains(CONFIG_XML_PACKAGE_PATH_PACKAGE))
35 {
36 robot.xmlPackagePath.package = config_pp[CONFIG_XML_PACKAGE_PATH_PACKAGE];
37 }
38 if (config_pp.contains(CONFIG_XML_PACKAGE_PATH_PATH))
39 {
40 robot.xmlPackagePath.path = config_pp[CONFIG_XML_PACKAGE_PATH_PATH];
41 }
42 }
44
45 if (config.contains(CONFIG_MNS_PRX))
46 {
47 p.usingProxy(config[CONFIG_MNS_PRX]);
48 }
49 if (config.contains(CONFIG_SKILLS_MANAGER_PRX))
50 {
51 p.usingProxy(config[CONFIG_SKILLS_MANAGER_PRX]);
52 }
53
54 if (config.contains(CONFIG_ARMS))
55 {
56 for (const auto& [k, config_arm] : config[CONFIG_ARMS].items())
57 {
58 auto& arm = robot.armInfos[k];
59
60 if (config_arm.contains(CONFIG_ARM_KINEMATIC_CHAIN_NAME))
61 {
62 arm.kinematicChainName = config_arm[CONFIG_ARM_KINEMATIC_CHAIN_NAME];
63 }
64
65 if (config_arm.contains(CONFIG_ARM_HAND))
66 {
67 auto config_hand = config_arm[CONFIG_ARM_HAND];
68
69 if (config_hand.contains(CONFIG_ARM_HAND_NAME))
70 {
71 arm.hand.name = config_hand[CONFIG_ARM_HAND_NAME];
72 }
73 if (config_hand.contains(CONFIG_ARM_HAND_FT_NAME))
74 {
75 arm.hand.ft_name = config_hand[CONFIG_ARM_HAND_FT_NAME];
76 }
77
78 if (config_hand.contains(CONFIG_ARM_HAND_PRX))
79 {
80 p.usingProxy(config_hand[CONFIG_ARM_HAND_PRX]);
81 }
82 }
83 }
84 }
85 }
86
87 void
89 {
91
92 nlohmann::json config = nlohmann::json::parse(properties.configJson);
93
95
96 if (config.contains(CONFIG_MNS_PRX))
97 {
98 auto mns = p.getProxy<armarx::armem::mns::MemoryNameSystemInterfacePrx>(
99 config[CONFIG_MNS_PRX]);
100 robot.memoryNameSystem.initialize(mns, &p);
101 }
102
103 if (config.contains(CONFIG_SKILLS_MANAGER_PRX))
104 {
105 auto skill_manager = p.getProxy<armarx::skills::manager::dti::SkillManagerInterfacePrx>(
107 robot.skillManager = skill_manager;
108 }
109
110 if (config.contains(CONFIG_ARMS))
111 {
112 for (const auto& [k, config_arm] : config[CONFIG_ARMS].items())
113 {
114 auto& arm = robot.armInfos[k];
115
116 if (config_arm.contains(CONFIG_ARM_HAND))
117 {
118 auto config_hand = config_arm[CONFIG_ARM_HAND];
119
120 if (config_hand.contains(CONFIG_ARM_HAND_PRX))
121 {
122 auto hand_prx = p.getProxy<armarx::HandUnitInterfacePrx>(
123 config_hand[CONFIG_ARM_HAND_PRX]);
124 arm.hand.handUnitInterface = hand_prx;
125 }
126 }
127 }
128 }
129
130 // finally commit robot
131 properties.rns->registerRobotInfo(robot.toIce());
132 }
133
134 void
136 {
137 def->optional(properties.configJson, "robotConfigJson");
138 def->component(properties.rns);
139 }
140
141 void
143 {
144 properties.rns->unregisterRobotInfo(robot.name);
145 }
146
147} // namespace armarx::plugins
PluginT * addPlugin(const std::string prefix="", ParamsT &&... params)
void postCreatePropertyDefinitions(PropertyDefinitionsPtr &properties) override
Definition Plugin.cpp:135
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
This file is part of ArmarX.
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.