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
41namespace memoryx
42{
44 {
45 public:
48 {
49 defineOptionalProperty<std::string>("WorkingMemoryName",
50 "WorkingMemory",
51 "Name of the WorkingMemory that should be used");
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 */
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
Default component property definition container.
Definition Component.h:70
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition Component.cpp:46
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition Component.h:94
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition Component.cpp:90
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
GraphNodeBasePtr getNearestRobotLocationNode(const GraphNodeBasePtr &node, const ::Ice::Current &=Ice::emptyCurrent) override
GraphNodeBasePtr getNearestNodeToPosition(const std::string &sceneName, const std::string &nodeParentName, ::Ice::Float x, ::Ice::Float y, const ::Ice::Current &=Ice::emptyCurrent) override
GraphNodeBasePtr getNearestNodeToPose(const std::string &sceneName, const std::string &nodeParentName, const armarx::FramedPoseBasePtr &pose, const ::Ice::Current &=Ice::emptyCurrent) override
armarx::FramedPosePtr getRelativeNodePositionForObject(const std::string &objectClassName, const GraphNodeBasePtr &node)
armarx::FramedPoseBasePtr resolveToGlobalPose(const GraphNodeBasePtr &node, const ::Ice::Current &=Ice::emptyCurrent) override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
std::string getNearestNodeIdToPose(const std::string &sceneName, const std::string &nodeParentName, const armarx::FramedPoseBasePtr &pose, const ::Ice::Current &=Ice::emptyCurrent) override
void forceRefetch(const std::string &nodeId, const ::Ice::Current &=Ice::emptyCurrent) override
std::string getNearestRobotLocationNodeId(const GraphNodeBasePtr &node, const ::Ice::Current &=Ice::emptyCurrent) override
void forceRefetchForAll(const ::Ice::Current &=Ice::emptyCurrent) override
std::string getDefaultName() const override
std::string getNearestNodeIdToPosition(const std::string &sceneName, const std::string &nodeParentName, ::Ice::Float x, ::Ice::Float y, const ::Ice::Current &=Ice::emptyCurrent) override
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface > RobotStateComponentInterfacePrx
IceInternal::Handle< FramedPose > FramedPosePtr
Definition FramedPose.h:272
VirtualRobot headers.
IceInternal::Handle< GraphNodePoseResolver > GraphNodePoseResolverPtr
IceInternal::Handle< GraphNode > GraphNodePtr
Definition GraphNode.h:47