33 class ControllerManagement;
38 RobotUnit*
getRobotUnit(RobotUnitModule::ControllerManagement* cmgr);
45 const NJointControllerConfigPtr&,
49 const std::string& instanceName)
const = 0;
52 const std::map<std::string, ConstControlDevicePtr>&,
53 const std::map<std::string, ConstSensorDevicePtr>&)
const = 0;
54 virtual NJointControllerConfigPtr
56 virtual bool hasRemoteConfiguration()
const = 0;
73 template <
class ControllerType>
79 hasGenerateConfigDescription,
80 GenerateConfigDescription,
83 hasGenerateConfigFromVariants,
84 GenerateConfigFromVariants,
86 typename T::ConfigPtrT>);
88 template <
class NJo
intControllerT>
93 "Either overload both GenerateConfigDescription and "
94 "GenerateConfigFromVariants, or none!");
95 static constexpr
bool hasRemoteConfiguration_ =
98 NJointControllerBasePtr
100 const NJointControllerConfigPtr& config,
104 const std::string& instanceName)
const final override
108 using ConfigPtrT =
typename NJointControllerT::ConfigPtrT;
109 ConfigPtrT cfg = ConfigPtrT::dynamicCast(config);
111 <<
"The configuration is of the wrong type! it has to be an instance of: "
112 << GetTypeString<ConfigPtrT>();
115 <<
"Two NJointControllers are created at the same time";
116 NJointControllerBasePtr ptr;
118 ConstructorIsRunning_ =
true;
121 ConstructorIsRunning_ =
false;
123 ptr =
new NJointControllerT(
getRobotUnit(cmngr), cfg, rob);
125 ptr->deletable = deletable;
126 ptr->internal =
internal;
127 ptr->rtClassName_ = ptr->getClassName(Ice::emptyCurrent);
128 ptr->instanceName_ = instanceName;
133 GenerateConfigDescription(
135 const std::map<std::string, ConstControlDevicePtr>& controlDevices,
136 const std::map<std::string, ConstSensorDevicePtr>& sensorDevices)
139 if constexpr (hasRemoteConfiguration_)
143 return NJointControllerT::GenerateConfigDescription(
144 robot, controlDevices, sensorDevices);
146 catch (Ice::UserException& e)
148 ARMARX_ERROR <<
"Exception calling '" << GetTypeString<NJointControllerT>()
149 <<
"::GenerateConfigDescription'"
150 <<
"\n---- file = " << e.ice_file()
151 <<
"\n---- line = " << e.ice_line()
152 <<
"\n---- id = " << e.ice_id() <<
"\n---- what:\n"
153 << e.what() <<
"\n---- stacktrace:\n"
154 << e.ice_stackTrace();
157 catch (std::exception& e)
159 ARMARX_ERROR <<
"Exception calling '" << GetTypeString<NJointControllerT>()
160 <<
"::GenerateConfigDescription'"
167 ARMARX_ERROR <<
"Exception calling '" << GetTypeString<NJointControllerT>()
168 <<
"::GenerateConfigDescription'";
178 NJointControllerConfigPtr
181 if constexpr (hasRemoteConfiguration_)
185 return NJointControllerT::GenerateConfigFromVariants(variants);
187 catch (Ice::UserException& e)
189 ARMARX_ERROR <<
"Exception calling '" << GetTypeString<NJointControllerT>()
190 <<
"::GenerateConfigFromVariants'"
191 <<
"\n---- file = " << e.ice_file()
192 <<
"\n---- line = " << e.ice_line()
193 <<
"\n---- id = " << e.ice_id() <<
"\n---- what:\n"
194 << e.what() <<
"\n---- stacktrace:\n"
195 << e.ice_stackTrace();
198 catch (std::exception& e)
200 ARMARX_ERROR <<
"Exception calling '" << GetTypeString<NJointControllerT>()
201 <<
"::GenerateConfigFromVariants'"
208 ARMARX_ERROR <<
"Exception calling '" << GetTypeString<NJointControllerT>()
209 <<
"::GenerateConfigFromVariants'";
220 hasRemoteConfiguration() const final
override
222 return hasRemoteConfiguration_;
229 template <
class ControllerType>
230 struct NJointControllerRegistration
236 std::unique_ptr<NJointControllerRegistryEntry>(
242 #define ARMARX_ASSERT_NJOINTCONTROLLER_HAS_CONSTRUCTION_GUI(T) \
244 ::armarx::detail::hasGenerateConfigDescription<T>::value, \
245 #T " does not offer a construction gui (missing: static GenerateConfigDescription)"); \
247 ::armarx::detail::hasGenerateConfigFromVariants<T>::value, \
248 #T " does not offer a construction gui (missing: static GenerateConfigFromVariants)")