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 
27 #include <mutex>
28 
30 
31 #include <RobotAPI/interface/core/RobotState.h>
33 
37 #include <MemoryX/interface/components/GraphNodePoseResolverInterface.h>
40 
41 namespace memoryx
42 {
44  {
45  public:
48  {
49  defineOptionalProperty<std::string>("WorkingMemoryName",
50  "WorkingMemory",
51  "Name of the WorkingMemory that should be used");
52  defineOptionalProperty<std::string>(
53  "RobotStateComponentName",
54  "RobotStateComponent",
55  "Name of the RobotStateComponent that should be used");
56  }
57  };
58 
59  /**
60  * @class GraphNodePoseResolver
61  * @brief A brief description
62  *
63  * Detailed Description
64  */
66  virtual public GraphNodePoseResolverInterface,
67  virtual public armarx::Component
68  {
69  public:
71 
72  /**
73  * @see armarx::ManagedIceObject::getDefaultName()
74  */
75  std::string
76  getDefaultName() const override
77  {
78  return "GraphNodePoseResolver";
79  }
80 
81  /**
82  * @see PropertyUser::createPropertyDefinitions()
83  */
86  {
89  }
90 
91  armarx::FramedPoseBasePtr
92  resolveToGlobalPose(const GraphNodeBasePtr& node,
93  const ::Ice::Current& = Ice::emptyCurrent) override;
94  std::string getNearestNodeIdToPosition(const std::string& sceneName,
95  const std::string& nodeParentName,
96  ::Ice::Float x,
97  ::Ice::Float y,
98  const ::Ice::Current& = Ice::emptyCurrent) override;
99  GraphNodeBasePtr
100  getNearestNodeToPosition(const std::string& sceneName,
101  const std::string& nodeParentName,
102  ::Ice::Float x,
103  ::Ice::Float y,
104  const ::Ice::Current& = Ice::emptyCurrent) override;
105  std::string getNearestNodeIdToPose(const std::string& sceneName,
106  const std::string& nodeParentName,
107  const armarx::FramedPoseBasePtr& pose,
108  const ::Ice::Current& = Ice::emptyCurrent) override;
109  GraphNodeBasePtr getNearestNodeToPose(const std::string& sceneName,
110  const std::string& nodeParentName,
111  const armarx::FramedPoseBasePtr& pose,
112  const ::Ice::Current& = Ice::emptyCurrent) override;
113  std::string
114  getNearestRobotLocationNodeId(const GraphNodeBasePtr& node,
115  const ::Ice::Current& = Ice::emptyCurrent) override;
116  GraphNodeBasePtr
117  getNearestRobotLocationNode(const GraphNodeBasePtr& node,
118  const ::Ice::Current& = Ice::emptyCurrent) override;
119 
120  void forceRefetch(const std::string& nodeId,
121  const ::Ice::Current& = Ice::emptyCurrent) override;
122  void forceRefetchForAll(const ::Ice::Current& = Ice::emptyCurrent) override;
123 
124  protected:
125  /**
126  * @see armarx::ManagedIceObject::onInitComponent()
127  */
128  void onInitComponent() override;
129 
130  /**
131  * @see armarx::ManagedIceObject::onConnectComponent()
132  */
133  void onConnectComponent() override;
134 
135  /**
136  * @see armarx::ManagedIceObject::onDisconnectComponent()
137  */
138  void onDisconnectComponent() override;
139 
140  /**
141  * @see armarx::ManagedIceObject::onExitComponent()
142  */
143  void onExitComponent() override;
144 
145  armarx::FramedPosePtr getRelativeNodePositionForObject(const std::string& objectClassName,
146  const GraphNodeBasePtr& node);
147 
148  private:
149  struct CachedNodeInfo
150  {
151  GraphNodePtr node;
152  armarx::FramedPosePtr globalPose;
153  std::vector<std::string> parents;
154  };
155 
156  CachedNodeInfo getCacheEntry(const std::string& nodeId);
157  GraphNodeBasePtr getNearestNodeToPoseImpl(const std::string& sceneName,
158  const std::string& nodeParentName,
159  const Eigen::Matrix4f& pose,
160  bool ignoreOrientation = false,
161  bool ignoreParent = false);
162 
163  memoryx::PriorKnowledgeInterfacePrx prior;
164  memoryx::WorkingMemoryInterfacePrx wm;
166 
167  memoryx::ObjectInstanceMemorySegmentBasePrx objectInstances;
168  memoryx::GraphMemorySegmentBasePrx graphSegment;
169 
170  std::map<std::string, std::map<std::string, armarx::FramedPositionPtr>>
171  relativePlacesettingPositions;
172  std::map<std::string, CachedNodeInfo> nodeInfoCache;
173  std::map<std::string, GraphNodeBaseList> sceneNodesCache;
174 
175  std::recursive_mutex cacheMutex;
176  };
177 
179 } // namespace memoryx
memoryx::GraphNodePoseResolver::forceRefetch
void forceRefetch(const std::string &nodeId, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: GraphNodePoseResolver.cpp:334
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:919
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:305
memoryx::GraphNodePoseResolver::onInitComponent
void onInitComponent() override
Definition: GraphNodePoseResolver.cpp:38
memoryx::GraphNodePoseResolver::onDisconnectComponent
void onDisconnectComponent() override
Definition: GraphNodePoseResolver.cpp:71
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:650
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:281
memoryx::GraphNodePoseResolver::getNearestRobotLocationNodeId
std::string getNearestRobotLocationNodeId(const GraphNodeBasePtr &node, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: GraphNodePoseResolver.cpp:316
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:345
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
memoryx::GraphNodePoseResolverPropertyDefinitions::GraphNodePoseResolverPropertyDefinitions
GraphNodePoseResolverPropertyDefinitions(std::string prefix)
Definition: GraphNodePoseResolver.h:46
memoryx::GraphNodePoseResolver::getRelativeNodePositionForObject
armarx::FramedPosePtr getRelativeNodePositionForObject(const std::string &objectClassName, const GraphNodeBasePtr &node)
Definition: GraphNodePoseResolver.cpp:81
memoryx::GraphNodePoseResolverPropertyDefinitions
Definition: GraphNodePoseResolver.h:43
memoryx::GraphNodePoseResolver::getDefaultName
std::string getDefaultName() const override
Definition: GraphNodePoseResolver.h:76
memoryx::GraphNodePoseResolver::onExitComponent
void onExitComponent() override
Definition: GraphNodePoseResolver.cpp:76
IceInternal::Handle< FramedPose >
PriorKnowledge.h
memoryx::GraphNodePoseResolver
A brief description.
Definition: GraphNodePoseResolver.h:65
memoryx::GraphNodePoseResolver::forceRefetchForAll
void forceRefetchForAll(const ::Ice::Current &=Ice::emptyCurrent) override
Definition: GraphNodePoseResolver.cpp:346
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:271
GraphNode.h
MemoryXCoreObjectFactories.h
WorkingMemory.h
memoryx::GraphNodePoseResolver::onConnectComponent
void onConnectComponent() override
Definition: GraphNodePoseResolver.cpp:46
memoryx::GraphNodePoseResolver::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: GraphNodePoseResolver.h:85
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:91
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:296
memoryx::GraphNodePoseResolver::GraphNodePoseResolver
GraphNodePoseResolver()
Definition: GraphNodePoseResolver.cpp:33
armarx::Component::getConfigIdentifier
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition: Component.cpp:79
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:69
IceUtil::Handle< class PropertyDefinitionContainer >
IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface >
armarx::ComponentPropertyDefinitions::ComponentPropertyDefinitions
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition: Component.cpp:35
MemoryXTypesObjectFactories.h
memoryx::GraphNodePoseResolver::resolveToGlobalPose
armarx::FramedPoseBasePtr resolveToGlobalPose(const GraphNodeBasePtr &node, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: GraphNodePoseResolver.cpp:263
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:35
memoryx::GraphNodePoseResolver::getNearestRobotLocationNode
GraphNodeBasePtr getNearestRobotLocationNode(const GraphNodeBasePtr &node, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: GraphNodePoseResolver.cpp:323