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>
91 static_assert(hasGenerateConfigDescription<NJointControllerT>::value ==
92 hasGenerateConfigFromVariants<NJointControllerT>::value,
93 "Either overload both GenerateConfigDescription and "
94 "GenerateConfigFromVariants, or none!");
95 static constexpr bool hasRemoteConfiguration_ =
96 hasGenerateConfigDescription<NJointControllerT>::value;
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: "
115 <<
"Two NJointControllers are created at the same time";
116 NJointControllerBasePtr ptr;
123 ptr =
new NJointControllerT(
getRobotUnit(cmngr), cfg, rob);
125 ptr->deletable = deletable;
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)
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)
160 <<
"::GenerateConfigDescription'"
168 <<
"::GenerateConfigDescription'";
178 NJointControllerConfigPtr
181 if constexpr (hasRemoteConfiguration_)
185 return NJointControllerT::GenerateConfigFromVariants(variants);
187 catch (Ice::UserException& e)
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)
201 <<
"::GenerateConfigFromVariants'"
209 <<
"::GenerateConfigFromVariants'";
220 hasRemoteConfiguration()
const final override
222 return hasRemoteConfiguration_;
229 template <
class ControllerType>
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)")
ConfigPrtType(*)(const StringVariantBaseMap &) GenerateConfigFromVariantsFunctionSignature
WidgetDescription::WidgetPtr(*)( const VirtualRobot::RobotPtr &, const std::map< std::string, ConstControlDevicePtr > &controlDevices, const std::map< std::string, ConstSensorDevicePtr > &sensorDevices) GenerateConfigDescriptionFunctionSignature
static bool ConstructorIsRunning()
virtual ~NJointControllerRegistryEntry()=default
static thread_local bool ConstructorIsRunning_
static void registerElement(const std::string &key, std::unique_ptr< NJointControllerRegistryEntry > element)
This Module manages NJointControllers.
The RobotUnit class manages a robot and its controllers.
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
#define ARMARX_ON_SCOPE_EXIT
Executes given code when the enclosing scope is left.
std::shared_ptr< class Robot > RobotPtr
This file offers overloads of toIce() and fromIce() functions for STL container types.
Registrar< std::unique_ptr< NJointControllerRegistryEntry > > NJointControllerRegistry
RobotUnit * getRobotUnit(RobotUnitModule::ControllerManagement *cmngr)
std::map< std::string, VariantBasePtr > StringVariantBaseMap
std::string GetTypeString(const std::type_info &tinf, bool withoutNamespaceSpecifier=false)
NJointControllerRegistration(const std::string &name)