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/Robot.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 Ice::Current& = Ice::emptyCurrent) override;
127 
128  void enableVelocityMode(const Ice::Current& = Ice::emptyCurrent) override;
129 
130  template <control::common::ControllerType T>
131  std::string
132  createComplianceController(const std::string& namePrefix,
133  const ::armarx::aron::data::dto::DictPtr& configDict = nullptr,
134  const std::string& configFilename = "",
135  bool flagActivate = true,
136  bool flagAllowReuse = true,
137  bool flagFromMemory = false);
138 
139  private:
140  // Private methods go here.
141 
142  // Forward declare `Properties` if you used it before its defined.
143  // struct Properties;
144 
145  /* (Requires the armarx::ArVizComponentPluginUser.)
146  /// Draw some boxes in ArViz.
147  void drawBoxes(const Properties& p, viz::Client& arviz);
148  */
149 
150  // std::string createTSBiImpedanceController(
151  // const std::string &controllerNamePrefix,
152  // const std::string &configFilename,
153  // bool activate,
154  // bool allowReuse);
155 
156  private:
157  static const std::string defaultName;
158 
159  // Private member variables go here.
160  RobotUnitInterfacePrx m_robot_unit = nullptr;
161  VirtualRobot::RobotPtr m_robot = nullptr;
162  // armem::client::plugins::ReaderWriterPlugin<armem::robot_state::VirtualRobotReader>* m_virtualRobotReaderPlugin = nullptr;
163 
164  /// observer
165  /*ForceTorqueUnitObserverInterfacePrx m_force_torque_observer;
166  armarx::control::common::ft::ForceTorqueUtilityPtr m_ft_l = nullptr;
167  armarx::control::common::ft::ForceTorqueUtilityPtr m_ft_r = nullptr;*/
168 
169  /// robot node sets
170  VirtualRobot::RobotNodeSetPtr m_rns_l;
171  VirtualRobot::RobotNodeSetPtr m_rns_r;
172 
173  std::map<std::string, VirtualRobot::RobotNodeSetPtr> m_robotNodeSets;
174  std::map<std::string, unsigned int> m_controllerJointNumbers;
175 
176  // std::map<std::string, TargetPoseMap> m_prevTargetPose;
177  // std::map<std::string, TargetNullspaceMap > m_prevNullspaceJointTarget;
178  std::map<std::string, std::map<std::string, Eigen::Matrix4f>> m_prevTargetPose;
179  std::map<std::string, std::map<std::string, Eigen::VectorXf>> m_prevNullspaceJointTarget;
180 
181  /// Properties shown in the Scenario GUI.
182  struct Properties
183  {
184  std::string robotName = "Armar6";
185  std::string robotUnitName = "Armar6Unit";
186  //std::string ftObserverName = "Armar6ForceTorqueObserver";
187  std::string ftSensorNameLeft = "FT L_ArmL_FT";
188  std::string ftSensorNameRight = "FT R_ArmR_FT";
189 
190  std::string defaultRobotNodeSetLeft = "LeftArm";
191  std::string defaultRobotNodeSetRight = "RightArm";
192  };
193 
194  Properties properties;
195  /* Use a mutex if you access variables from different threads
196  * (e.g. ice functions and RemoteGui_update()).
197  std::mutex propertiesMutex;
198  */
199 
200 
201  /* (Requires the armarx::LightweightRemoteGuiComponentPluginUser.)
202  /// Tab shown in the Remote GUI.
203  struct RemoteGuiTab : armarx::RemoteGui::Client::Tab
204  {
205  armarx::RemoteGui::Client::LineEdit boxLayerName;
206  armarx::RemoteGui::Client::IntSpinBox numBoxes;
207 
208  armarx::RemoteGui::Client::Button drawBoxes;
209  };
210  RemoteGuiTab tab;
211  */
212  template <typename T>
214 
215  template <typename T>
217 
219 
220  //armarx::kinesthetic_learning::kinesthetic_teaching::trigger::FTWristSensorTrigger m_trigger;
221  };
222 
223 } // namespace armarx::control::components::controller_creator
armarx::control::components::controller_creator::ComponentInterface
Definition: ComponentInterface.ice:49
RobotStateComponentPlugin.h
armarx::armem::client::plugins::ReaderWriterPlugin
A component plugin offering client-side access to a reader or writer and manages the lifecycle,...
Definition: ReaderWriterPlugin.h:44
armarx::control::components::controller_creator::Component::onExitComponent
void onExitComponent() override
Definition: Component.cpp:180
armarx::control::components::controller_creator::Component::kinestheticTeaching
std::string kinestheticTeaching(const std::string &kinematicChainName, const std::string &side, const std::string &fileName, const Ice::Current &=Ice::emptyCurrent) override
Definition: Component.cpp:704
armarx::control::components::controller_creator::Component
Definition: Component.h:57
ReaderWriterPlugin.h
ForceTorqueUtility.h
std::experimental::fundamentals_v2::observer_ptr
Definition: ManagedIceObject.h:53
armarx::control::components::controller_creator::Component::Component
Component()
Definition: Component.cpp:57
armarx::control::components::controller_creator::Component::createController
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
Definition: Component.cpp:462
armarx::control::components::controller_creator::Component::createComplianceController
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)
type.h
armarx::control::client::ComponentPluginUser
Definition: ComponentPlugin.h:147
armarx::control::components::controller_creator::Component::getPoseInRootFrame
Ice::FloatSeq getPoseInRootFrame(const std::string &nodeName, const Ice::Current &=Ice::emptyCurrent) override
Definition: Component.cpp:1174
VirtualRobotReader.h
armarx::control::components::controller_creator::Component::~Component
~Component() override
ControllerBuilder.h
plugins.h
controller_descriptions.h
armarx::control::components::controller_creator::Component::onInitComponent
void onInitComponent() override
Definition: Component.cpp:103
armarx::control::components::controller_creator::Component::GetDefaultName
static std::string GetDefaultName()
Get the component's default name.
Definition: Component.cpp:1214
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
armarx::aron::data::DictPtr
std::shared_ptr< Dict > DictPtr
Definition: Dict.h:41
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::control::components::controller_creator::Component::getDefaultName
std::string getDefaultName() const override
Definition: Component.cpp:1208
IceInternal::ProxyHandle<::IceProxy::armarx::RobotUnitInterface >
ComponentPlugin.h
armarx::control::components::controller_creator::ComponentInterface::enableVelocityMode
void enableVelocityMode()
armarx::control::components::controller_creator::Component::onConnectComponent
void onConnectComponent() override
Definition: Component.cpp:113
armarx::armem::client::plugins::ListeningPluginUser
A memory name system client which listens to the memory updates topic (MemoryListenerInterface).
Definition: ListeningPluginUser.h:23
armarx::control::components::controller_creator::Component::getPoseInGlobalFrame
Ice::FloatSeq getPoseInGlobalFrame(const std::string &nodeName, const Ice::Current &=Ice::emptyCurrent) override
Definition: Component.cpp:1191
armarx::RobotStateComponentPluginUser
Definition: RobotStateComponentPlugin.h:167
armarx::control::components::controller_creator
Definition: Component.cpp:52
armarx::control::components::controller_creator::Component::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: Component.cpp:65
armarx::control::components::controller_creator::Component::onDisconnectComponent
void onDisconnectComponent() override
Definition: Component.cpp:175
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
controller_descriptions.h