ConfigurableNJointControllerBase.h
Go to the documentation of this file.
1/**
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @author ( )
17 * @date 2024
18 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19 * GNU General Public License
20 */
21
22#pragma once
23
25
26#include <armarx/control/interface/ConfigurableNJointControllerInterface.h>
27
29{
30
31
32 template <typename _AronConfigT>
34 public armarx::control::ConfigurableNJointControllerInterface
35 {
36 public:
37 using AronConfigT = _AronConfigT;
39
40 ConfigurableNJointControllerBase(const NJointControllerConfigPtr& config) :
41 configData_(readConfig(config))
42 {
43 // check if nodeSetName is set properly
44 using IceConfigPtrT = control::ConfigurableNJointControllerConfigPtr;
45
46 const IceConfigPtrT cfg = IceConfigPtrT::dynamicCast(config);
47 ARMARX_CHECK_EXPRESSION(!cfg->nodeSetName.empty());
48 }
49
51
52 void
53 updateConfig(const ::armarx::aron::data::dto::DictPtr& dto,
54 const Ice::Current& iceCurrent) override
55 {
56 const AronConfigT configData = AronConfigT::FromAron(dto);
57 updateConfig(configData);
58 }
59
60 protected:
61 // access to the initial config data (set in constructor)
62 const AronConfigT&
64 {
65 return configData_;
66 }
67
68 virtual void updateConfig(const AronConfigT& configData) = 0;
69
70 private:
72 readConfig(const NJointControllerConfigPtr& config) const
73 {
74 static_assert(std::is_base_of<armarx::aron::codegenerator::cpp::AronGeneratedClass,
75 AronConfigT>::value,
76 "AronConfigT must be a generated class from Aron!");
77
78 using IceConfigPtrT = control::ConfigurableNJointControllerConfigPtr;
79
80 // convert to ice type
81 const IceConfigPtrT cfg = IceConfigPtrT::dynamicCast(config);
83
84 // convert to aron type
85 AronConfigT configData = AronConfigT::FromAron(cfg->config);
86 return configData;
87 }
88
89 const AronConfigT configData_;
90 };
91
92} // namespace armarx::control::njoint_controller::core
void updateConfig(const ::armarx::aron::data::dto::DictPtr &dto, const Ice::Current &iceCurrent) override
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
aron::cpp::AronGeneratedClass AronGeneratedClass