GraphNodePoseResolver.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package MemoryX::ArmarXObjects::GraphNodePoseResolver
19  * @author Valerij Wittenbeck ( valerij.wittenbeck at student dot kit dot edu )
20  * @date 2015
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #pragma once
26 
29 #include <RobotAPI/interface/core/RobotState.h>
33 #include <MemoryX/interface/components/GraphNodePoseResolverInterface.h>
36 
37 #include <mutex>
38 
39 namespace memoryx
40 {
43  {
44  public:
47  {
48  defineOptionalProperty<std::string>("WorkingMemoryName", "WorkingMemory", "Name of the WorkingMemory that should be used");
49  defineOptionalProperty<std::string>("RobotStateComponentName", "RobotStateComponent", "Name of the RobotStateComponent that should be used");
50 
51  }
52  };
53  /**
54  * @class GraphNodePoseResolver
55  * @brief A brief description
56  *
57  * Detailed Description
58  */
60  virtual public GraphNodePoseResolverInterface,
61  virtual public armarx::Component
62  {
63  public:
65  /**
66  * @see armarx::ManagedIceObject::getDefaultName()
67  */
68  std::string getDefaultName() const override
69  {
70  return "GraphNodePoseResolver";
71  }
72 
73  /**
74  * @see PropertyUser::createPropertyDefinitions()
75  */
77  {
80  }
81 
82  armarx::FramedPoseBasePtr resolveToGlobalPose(const GraphNodeBasePtr& node, const ::Ice::Current& = Ice::emptyCurrent) override;
83  std::string getNearestNodeIdToPosition(const std::string& sceneName, const std::string& nodeParentName, ::Ice::Float x, ::Ice::Float y, const ::Ice::Current& = Ice::emptyCurrent) override;
84  GraphNodeBasePtr getNearestNodeToPosition(const std::string& sceneName, const std::string& nodeParentName, ::Ice::Float x, ::Ice::Float y, const ::Ice::Current& = Ice::emptyCurrent) override;
85  std::string getNearestNodeIdToPose(const std::string& sceneName, const std::string& nodeParentName, const armarx::FramedPoseBasePtr& pose, const ::Ice::Current& = Ice::emptyCurrent) override;
86  GraphNodeBasePtr getNearestNodeToPose(const std::string& sceneName, const std::string& nodeParentName, const armarx::FramedPoseBasePtr& pose, const ::Ice::Current& = Ice::emptyCurrent) override;
87  std::string getNearestRobotLocationNodeId(const GraphNodeBasePtr& node, const ::Ice::Current& = Ice::emptyCurrent) override;
88  GraphNodeBasePtr getNearestRobotLocationNode(const GraphNodeBasePtr& node, const ::Ice::Current& = Ice::emptyCurrent) override;
89 
90  void forceRefetch(const std::string& nodeId, const ::Ice::Current& = Ice::emptyCurrent) override;
91  void forceRefetchForAll(const ::Ice::Current& = Ice::emptyCurrent) override;
92 
93  protected:
94  /**
95  * @see armarx::ManagedIceObject::onInitComponent()
96  */
97  void onInitComponent() override;
98 
99  /**
100  * @see armarx::ManagedIceObject::onConnectComponent()
101  */
102  void onConnectComponent() override;
103 
104  /**
105  * @see armarx::ManagedIceObject::onDisconnectComponent()
106  */
107  void onDisconnectComponent() override;
108 
109  /**
110  * @see armarx::ManagedIceObject::onExitComponent()
111  */
112  void onExitComponent() override;
113 
114  armarx::FramedPosePtr getRelativeNodePositionForObject(const std::string& objectClassName, const GraphNodeBasePtr& node);
115 
116  private:
117  struct CachedNodeInfo
118  {
119  GraphNodePtr node;
120  armarx::FramedPosePtr globalPose;
121  std::vector<std::string> parents;
122  };
123 
124  CachedNodeInfo getCacheEntry(const std::string& nodeId);
125  GraphNodeBasePtr getNearestNodeToPoseImpl(const std::string& sceneName, const std::string& nodeParentName, const Eigen::Matrix4f& pose,
126  bool ignoreOrientation = false, bool ignoreParent = false);
127 
128  memoryx::PriorKnowledgeInterfacePrx prior;
129  memoryx::WorkingMemoryInterfacePrx wm;
131 
132  memoryx::ObjectInstanceMemorySegmentBasePrx objectInstances;
133  memoryx::GraphMemorySegmentBasePrx graphSegment;
134 
135  std::map<std::string, std::map<std::string, armarx::FramedPositionPtr>> relativePlacesettingPositions;
136  std::map<std::string, CachedNodeInfo> nodeInfoCache;
137  std::map<std::string, GraphNodeBaseList> sceneNodesCache;
138 
139  std::recursive_mutex cacheMutex;
140  };
141 
143 }
144 
memoryx::GraphNodePoseResolver::forceRefetch
void forceRefetch(const std::string &nodeId, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: GraphNodePoseResolver.cpp:272
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:918
memoryx::GraphNodePoseResolver::getNearestNodeToPose
GraphNodeBasePtr getNearestNodeToPose(const std::string &sceneName, const std::string &nodeParentName, const armarx::FramedPoseBasePtr &pose, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: GraphNodePoseResolver.cpp:253
memoryx::GraphNodePoseResolver::onInitComponent
void onInitComponent() override
Definition: GraphNodePoseResolver.cpp:36
memoryx::GraphNodePoseResolver::onDisconnectComponent
void onDisconnectComponent() override
Definition: GraphNodePoseResolver.cpp:64
memoryx::GraphNodePoseResolver::getNearestNodeToPosition
GraphNodeBasePtr getNearestNodeToPosition(const std::string &sceneName, const std::string &nodeParentName, ::Ice::Float x, ::Ice::Float y, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: GraphNodePoseResolver.cpp:239
memoryx::GraphNodePoseResolver::getNearestRobotLocationNodeId
std::string getNearestRobotLocationNodeId(const GraphNodeBasePtr &node, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: GraphNodePoseResolver.cpp:259
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
memoryx::GraphNodePoseResolverPropertyDefinitions::GraphNodePoseResolverPropertyDefinitions
GraphNodePoseResolverPropertyDefinitions(std::string prefix)
Definition: GraphNodePoseResolver.h:45
memoryx::GraphNodePoseResolver::getRelativeNodePositionForObject
armarx::FramedPosePtr getRelativeNodePositionForObject(const std::string &objectClassName, const GraphNodeBasePtr &node)
Definition: GraphNodePoseResolver.cpp:72
memoryx::GraphNodePoseResolverPropertyDefinitions
Definition: GraphNodePoseResolver.h:41
memoryx::GraphNodePoseResolver::getDefaultName
std::string getDefaultName() const override
Definition: GraphNodePoseResolver.h:68
memoryx::GraphNodePoseResolver::onExitComponent
void onExitComponent() override
Definition: GraphNodePoseResolver.cpp:68
IceInternal::Handle< FramedPose >
PriorKnowledge.h
memoryx::GraphNodePoseResolver
A brief description.
Definition: GraphNodePoseResolver.h:59
memoryx::GraphNodePoseResolver::forceRefetchForAll
void forceRefetchForAll(const ::Ice::Current &=Ice::emptyCurrent) override
Definition: GraphNodePoseResolver.cpp:283
ManagedIceObject.h
FramedPose.h
memoryx::GraphNodePoseResolver::getNearestNodeIdToPosition
std::string getNearestNodeIdToPosition(const std::string &sceneName, const std::string &nodeParentName, ::Ice::Float x, ::Ice::Float y, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: GraphNodePoseResolver.cpp:234
GraphNode.h
MemoryXCoreObjectFactories.h
WorkingMemory.h
memoryx::GraphNodePoseResolver::onConnectComponent
void onConnectComponent() override
Definition: GraphNodePoseResolver.cpp:43
memoryx::GraphNodePoseResolver::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: GraphNodePoseResolver.h:76
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
memoryx::GraphNodePoseResolver::getNearestNodeIdToPose
std::string getNearestNodeIdToPose(const std::string &sceneName, const std::string &nodeParentName, const armarx::FramedPoseBasePtr &pose, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: GraphNodePoseResolver.cpp:248
memoryx::GraphNodePoseResolver::GraphNodePoseResolver
GraphNodePoseResolver()
Definition: GraphNodePoseResolver.cpp:32
armarx::Component::getConfigIdentifier
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition: Component.cpp:74
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
IceUtil::Handle< class PropertyDefinitionContainer >
IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface >
armarx::ComponentPropertyDefinitions::ComponentPropertyDefinitions
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition: Component.cpp:37
MemoryXTypesObjectFactories.h
memoryx::GraphNodePoseResolver::resolveToGlobalPose
armarx::FramedPoseBasePtr resolveToGlobalPose(const GraphNodeBasePtr &node, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: GraphNodePoseResolver.cpp:227
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:34
memoryx::GraphNodePoseResolver::getNearestRobotLocationNode
GraphNodeBasePtr getNearestRobotLocationNode(const GraphNodeBasePtr &node, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: GraphNodePoseResolver.cpp:264