Component.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 * @package control::ArmarXObjects::controller_creator
17 * @author Jianfeng Gao ( jianfeng dot gao at kit dot edu )
18 * @date 2023
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23
24#pragma once
25
26
27// #include <mutex>
28// #include <Ice/Optional.h>
29#include <VirtualRobot/VirtualRobot.h>
30
32// #include <ArmarXCore/libraries/ArmarXCoreComponentPlugins/DebugObserverComponentPlugin.h>
33
34// #include <ArmarXGui/libraries/ArmarXGuiComponentPlugins/LightweightRemoteGuiComponentPlugin.h>
35
36// #include <RobotAPI/libraries/RobotAPIComponentPlugins/ArVizComponentPlugin.h>
37
38#include <experimental/memory>
39
40#include <RobotAPI/interface/units/RobotUnit/RobotUnitInterface.h>
45
50#include <armarx/control/components/controller_creator/ComponentInterface.h>
53
55{
56
57 class Component :
58 virtual public armarx::Component,
59 virtual public ComponentInterface,
63 // , virtual public armarx::DebugObserverComponentPluginUser
64 // , virtual public armarx::LightweightRemoteGuiComponentPluginUser
65 // , virtual public armarx::ArVizComponentPluginUser
66
67 {
68 public:
69 Component();
70
71 ~Component() override;
72
73 /// @see armarx::ManagedIceObject::getDefaultName()
74 std::string getDefaultName() const override;
75
76 /// Get the component's default name.
77 static std::string GetDefaultName();
78
79
80 protected:
81 /// @see PropertyUser::createPropertyDefinitions()
83
84 /// @see armarx::ManagedIceObject::onInitComponent()
85 void onInitComponent() override;
86
87 /// @see armarx::ManagedIceObject::onConnectComponent()
88 void onConnectComponent() override;
89
90 /// @see armarx::ManagedIceObject::onDisconnectComponent()
91 void onDisconnectComponent() override;
92
93 /// @see armarx::ManagedIceObject::onExitComponent()
94 void onExitComponent() override;
95
96
97 /* (Requires armarx::LightweightRemoteGuiComponentPluginUser.)
98 /// This function should be called once in onConnect() or when you
99 /// need to re-create the Remote GUI tab.
100 void createRemoteGuiTab();
101
102 /// After calling `RemoteGui_startRunningTask`, this function is
103 /// called periodically in a separate thread. If you update variables,
104 /// make sure to synchronize access to them.
105 void RemoteGui_update() override;
106 */
107
108 public:
109 std::string createController(const std::string& namePrefix,
110 const std::string& controllerType,
111 const aron::data::dto::DictPtr& configDict = nullptr,
112 const std::string& configFilename = "",
113 bool activate = false,
114 bool allowReuse = true,
115 bool cfgFromMemory = false,
116 const Ice::Current& = Ice::emptyCurrent) override;
117
118 Ice::FloatSeq getPoseInRootFrame(const std::string& nodeName,
119 const Ice::Current& = Ice::emptyCurrent) override;
120 Ice::FloatSeq getPoseInGlobalFrame(const std::string& nodeName,
121 const Ice::Current& = Ice::emptyCurrent) override;
122
123 std::string kinestheticTeaching(const std::string& kinematicChainName,
124 const std::string& side,
125 const std::string& fileName,
126 const std::string& nameSuffix,
127 const Ice::Current& = Ice::emptyCurrent) override;
128
129 void enableVelocityMode(const Ice::Current& = Ice::emptyCurrent) override;
130 void toggleZeroTorque(const std::string& leftNodesetName, const std::string& rightNodesetName, const Ice::Current& = Ice::emptyCurrent) override;
131 void createZeroTorqueController(const std::string& kinematicChainName);
132 template <control::common::ControllerType T>
133 std::string
134 createComplianceController(const std::string& namePrefix,
135 const ::armarx::aron::data::dto::DictPtr& configDict = nullptr,
136 const std::string& configFilename = "",
137 bool flagActivate = true,
138 bool flagAllowReuse = true,
139 bool flagFromMemory = false);
140
141 private:
142 // Private methods go here.
143
144 // Forward declare `Properties` if you used it before its defined.
145 // struct Properties;
146
147 /* (Requires the armarx::ArVizComponentPluginUser.)
148 /// Draw some boxes in ArViz.
149 void drawBoxes(const Properties& p, viz::Client& arviz);
150 */
151
152 // std::string createTSBiImpedanceController(
153 // const std::string &controllerNamePrefix,
154 // const std::string &configFilename,
155 // bool activate,
156 // bool allowReuse);
157
158 private:
159 static const std::string defaultName;
160
161 // Private member variables go here.
162 RobotUnitInterfacePrx m_robot_unit = nullptr;
163 VirtualRobot::RobotPtr m_robot = nullptr;
164 // armem::client::plugins::ReaderWriterPlugin<armem::robot_state::VirtualRobotReader>* m_virtualRobotReaderPlugin = nullptr;
165
166 /// observer
167 /*ForceTorqueUnitObserverInterfacePrx m_force_torque_observer;
168 armarx::control::common::ft::ForceTorqueUtilityPtr m_ft_l = nullptr;
169 armarx::control::common::ft::ForceTorqueUtilityPtr m_ft_r = nullptr;*/
170
171 /// robot node sets
172 VirtualRobot::RobotNodeSetPtr m_rns_l;
173 VirtualRobot::RobotNodeSetPtr m_rns_r;
174
175 std::map<std::string, VirtualRobot::RobotNodeSetPtr> m_robotNodeSets;
176 std::map<std::string, unsigned int> m_controllerJointNumbers;
177
178 // std::map<std::string, TargetPoseMap> m_prevTargetPose;
179 // std::map<std::string, TargetNullspaceMap > m_prevNullspaceJointTarget;
180 std::map<std::string, std::map<std::string, Eigen::Matrix4f>> m_prevTargetPose;
181 std::map<std::string, std::map<std::string, Eigen::VectorXf>> m_prevNullspaceJointTarget;
182
183 /// Properties shown in the Scenario GUI.
184 struct Properties
185 {
186 std::string robotName = "Armar6";
187 // std::string robotUnitName = "Armar6Unit";
188 //std::string ftObserverName = "Armar6ForceTorqueObserver";
189 std::string ftSensorNameLeft = "FT L_ArmL_FT";
190 std::string ftSensorNameRight = "FT R_ArmR_FT";
191
192 std::string defaultRobotNodeSetLeft = "LeftArm";
193 std::string defaultRobotNodeSetRight = "RightArm";
194 };
195
196 Properties properties;
197 /* Use a mutex if you access variables from different threads
198 * (e.g. ice functions and RemoteGui_update()).
199 std::mutex propertiesMutex;
200 */
201
202
203 /* (Requires the armarx::LightweightRemoteGuiComponentPluginUser.)
204 /// Tab shown in the Remote GUI.
205 struct RemoteGuiTab : armarx::RemoteGui::Client::Tab
206 {
207 armarx::RemoteGui::Client::LineEdit boxLayerName;
208 armarx::RemoteGui::Client::IntSpinBox numBoxes;
209
210 armarx::RemoteGui::Client::Button drawBoxes;
211 };
212 RemoteGuiTab tab;
213 */
214 template <typename T>
216
217 template <typename T>
219
220 obs_ptr<rw_plugin<armarx::armem::robot_state::VirtualRobotReader>> virtualRobotReader_;
221
222 //armarx::kinesthetic_learning::kinesthetic_teaching::trigger::FTWristSensorTrigger m_trigger;
223 };
224
225} // namespace armarx::control::components::controller_creator
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition Component.h:94
A component plugin offering client-side access to a reader or writer and manages the lifecycle,...
void createZeroTorqueController(const std::string &kinematicChainName)
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition Component.cpp:74
std::string createComplianceController(const std::string &namePrefix, const ::armarx::aron::data::dto::DictPtr &configDict=nullptr, const std::string &configFilename="", bool flagActivate=true, bool flagAllowReuse=true, bool flagFromMemory=false)
std::string kinestheticTeaching(const std::string &kinematicChainName, const std::string &side, const std::string &fileName, const std::string &nameSuffix, const Ice::Current &=Ice::emptyCurrent) override
std::string createController(const std::string &namePrefix, const std::string &controllerType, const aron::data::dto::DictPtr &configDict=nullptr, const std::string &configFilename="", bool activate=false, bool allowReuse=true, bool cfgFromMemory=false, const Ice::Current &=Ice::emptyCurrent) override
void toggleZeroTorque(const std::string &leftNodesetName, const std::string &rightNodesetName, const Ice::Current &=Ice::emptyCurrent) override
static std::string GetDefaultName()
Get the component's default name.
Ice::FloatSeq getPoseInGlobalFrame(const std::string &nodeName, const Ice::Current &=Ice::emptyCurrent) override
Ice::FloatSeq getPoseInRootFrame(const std::string &nodeName, const Ice::Current &=Ice::emptyCurrent) override
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
client::plugins::ListeningPluginUser ListeningClientPluginUser
::IceInternal::Handle< Dict > DictPtr
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotUnitInterface > RobotUnitInterfacePrx
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.