WorkingMemoryObjectPoseProvider.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 MemoryX::ArmarXObjects::WorkingMemoryObjectPoseProvider
17  * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu )
18  * @date 2020
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #pragma once
24 
25 #include <SimoxUtility/json/json.hpp>
26 
29 
30 #include <RobotAPI/interface/core/RobotState.h>
33 
34 #include <MemoryX/interface/components/WorkingMemoryInterface.h>
35 #include <MemoryX/interface/components/WorkingMemoryObjectPoseProviderInterface.h>
36 
39 
40 
41 namespace memoryx
42 {
43 
44 
45  struct Config
46  {
47  std::map<std::string, std::string> objectNames;
48  };
49 
50  void to_json(nlohmann::json& j, const Config& config);
51  void from_json(const nlohmann::json& j, Config& config);
52 
53 
54 
55 
56  /**
57  * @defgroup Component-WorkingMemoryObjectPoseProvider WorkingMemoryObjectPoseProvider
58  * @ingroup MemoryX-Components
59  * A description of the component WorkingMemoryObjectPoseProvider.
60  *
61  * @class WorkingMemoryObjectPoseProvider
62  * @ingroup Component-WorkingMemoryObjectPoseProvider
63  * @brief Brief description of class WorkingMemoryObjectPoseProvider.
64  *
65  * Detailed description of class WorkingMemoryObjectPoseProvider.
66  */
68  virtual public armarx::Component
69  , virtual public memoryx::WorkingMemoryObjectPoseProviderInterface
71  {
72  public:
73 
74  /// @see armarx::ManagedIceObject::getDefaultName()
75  std::string getDefaultName() const override;
76 
77 
78  // ObjectPoseProvider interface
79  armarx::objpose::ProviderInfo getProviderInfo(const Ice::Current& = Ice::emptyCurrent) override;
80 
81  // ObjectToRobotNodeAttachmentInterface interface
82  void attachObjectToRobotNode(const AttachObjectToRobotNodeInput& attachment, const Ice::Current&) override;
83  void detachObjectFromRobotNode(const DetachObjectFromRobotNodeInput& detachment, const Ice::Current&) override;
84 
85 
86  protected:
87 
88  /// @see armarx::ManagedIceObject::onInitComponent()
89  void onInitComponent() override;
90 
91  /// @see armarx::ManagedIceObject::onConnectComponent()
92  void onConnectComponent() override;
93 
94  /// @see armarx::ManagedIceObject::onDisconnectComponent()
95  void onDisconnectComponent() override;
96 
97  /// @see armarx::ManagedIceObject::onExitComponent()
98  void onExitComponent() override;
99 
100  /// @see PropertyUser::createPropertyDefinitions()
102 
103 
104  private:
105 
106  void provideObjectInstancesPoses();
107  void provideObjectInstancesPoses(const std::vector<ObjectInstancePtr>& objectInstances);
108 
109  armarx::objpose::ProvidedObjectPose toProvidedObjectPose(const ObjectInstancePtr& instance);
110 
111 
112  private:
113 
114  memoryx::PriorKnowledgeInterfacePrx priorKnowledge;
115  memoryx::WorkingMemoryInterfacePrx workingMemory;
116  armarx::RobotStateComponentInterfacePrx robotStateComponent;
117 
118  ObjectClassSegmentWrapper objectClassSegment;
119 
120 
121  float updateFrequency = 50;
123 
124  Config config;
125  std::string loadObjectDatasetsStr = "";
126  std::string configFile = "MemoryX/WorkingMemoryObjectPoseProvider/config.json";
127 
128  std::mutex mutex;
130 
131  };
132 }
memoryx::from_json
void from_json(const nlohmann::json &j, Config &config)
Definition: WorkingMemoryObjectPoseProvider.cpp:49
ObjectClassSegmentWrapper.h
ObjectPoseProviderPlugin.h
memoryx::Config::objectNames
std::map< std::string, std::string > objectNames
Definition: WorkingMemoryObjectPoseProvider.h:47
memoryx::ObjectClassSegmentWrapper
Definition: ObjectClassSegmentWrapper.h:23
memoryx::WorkingMemoryObjectPoseProvider::getProviderInfo
armarx::objpose::ProviderInfo getProviderInfo(const Ice::Current &=Ice::emptyCurrent) override
Definition: WorkingMemoryObjectPoseProvider.cpp:217
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
armarx::ObjectPoseProviderPluginUser
Provides an objpose::ObjectPoseTopicPrx objectPoseTopic as member variable.
Definition: ObjectPoseProviderPlugin.h:43
ObjectInstanceToRobotNodeAttachments.h
memoryx::WorkingMemoryObjectPoseProvider
Brief description of class WorkingMemoryObjectPoseProvider.
Definition: WorkingMemoryObjectPoseProvider.h:67
memoryx::Config
Definition: WorkingMemoryObjectPoseProvider.h:45
memoryx::WorkingMemoryObjectPoseProvider::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: WorkingMemoryObjectPoseProvider.cpp:58
IceInternal::Handle< ObjectInstance >
memoryx::WorkingMemoryObjectPoseProvider::onInitComponent
void onInitComponent() override
Definition: WorkingMemoryObjectPoseProvider.cpp:79
memoryx::to_json
void to_json(nlohmann::json &j, const Config &config)
Definition: WorkingMemoryObjectPoseProvider.cpp:44
TaskUtil.h
memoryx::WorkingMemoryObjectPoseProvider::onConnectComponent
void onConnectComponent() override
Definition: WorkingMemoryObjectPoseProvider.cpp:95
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
memoryx::WorkingMemoryObjectPoseProvider::onDisconnectComponent
void onDisconnectComponent() override
Definition: WorkingMemoryObjectPoseProvider.cpp:126
armarx::objpose::ProvidedObjectPose
An object pose provided by an ObjectPoseProvider.
Definition: ProvidedObjectPose.h:25
forward_declarations.h
IceUtil::Handle< class PropertyDefinitionContainer >
IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface >
memoryx::WorkingMemoryObjectPoseProvider::detachObjectFromRobotNode
void detachObjectFromRobotNode(const DetachObjectFromRobotNodeInput &detachment, const Ice::Current &) override
Definition: WorkingMemoryObjectPoseProvider.cpp:232
memoryx::WorkingMemoryObjectPoseProvider::attachObjectToRobotNode
void attachObjectToRobotNode(const AttachObjectToRobotNodeInput &attachment, const Ice::Current &) override
Definition: WorkingMemoryObjectPoseProvider.cpp:225
memoryx::WorkingMemoryObjectPoseProvider::getDefaultName
std::string getDefaultName() const override
Definition: WorkingMemoryObjectPoseProvider.cpp:73
memoryx::WorkingMemoryObjectPoseProvider::onExitComponent
void onExitComponent() override
Definition: WorkingMemoryObjectPoseProvider.cpp:135
memoryx::ObjectInstanceToRobotNodeAttachments
This class can be used to visualize object instances from working memory to ArViz.
Definition: ObjectInstanceToRobotNodeAttachments.h:23