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 static std::string GetDefaultName();
82
83 /**
84 * @see PropertyUser::createPropertyDefinitions()
85 */
92
93 armarx::FramedPoseBasePtr
94 resolveToGlobalPose(const GraphNodeBasePtr& node,
95 const ::Ice::Current& = Ice::emptyCurrent) override;
96 std::string getNearestNodeIdToPosition(const std::string& sceneName,
97 const std::string& nodeParentName,
98 ::Ice::Float x,
99 ::Ice::Float y,
100 const ::Ice::Current& = Ice::emptyCurrent) override;
101 GraphNodeBasePtr
102 getNearestNodeToPosition(const std::string& sceneName,
103 const std::string& nodeParentName,
104 ::Ice::Float x,
105 ::Ice::Float y,
106 const ::Ice::Current& = Ice::emptyCurrent) override;
107 std::string getNearestNodeIdToPose(const std::string& sceneName,
108 const std::string& nodeParentName,
109 const armarx::FramedPoseBasePtr& pose,
110 const ::Ice::Current& = Ice::emptyCurrent) override;
111 GraphNodeBasePtr getNearestNodeToPose(const std::string& sceneName,
112 const std::string& nodeParentName,
113 const armarx::FramedPoseBasePtr& pose,
114 const ::Ice::Current& = Ice::emptyCurrent) override;
115 std::string
116 getNearestRobotLocationNodeId(const GraphNodeBasePtr& node,
117 const ::Ice::Current& = Ice::emptyCurrent) override;
118 GraphNodeBasePtr
119 getNearestRobotLocationNode(const GraphNodeBasePtr& node,
120 const ::Ice::Current& = Ice::emptyCurrent) override;
121
122 void forceRefetch(const std::string& nodeId,
123 const ::Ice::Current& = Ice::emptyCurrent) override;
124 void forceRefetchForAll(const ::Ice::Current& = Ice::emptyCurrent) override;
125
126 protected:
127 /**
128 * @see armarx::ManagedIceObject::onInitComponent()
129 */
130 void onInitComponent() override;
131
132 /**
133 * @see armarx::ManagedIceObject::onConnectComponent()
134 */
135 void onConnectComponent() override;
136
137 /**
138 * @see armarx::ManagedIceObject::onDisconnectComponent()
139 */
140 void onDisconnectComponent() override;
141
142 /**
143 * @see armarx::ManagedIceObject::onExitComponent()
144 */
145 void onExitComponent() override;
146
147 armarx::FramedPosePtr getRelativeNodePositionForObject(const std::string& objectClassName,
148 const GraphNodeBasePtr& node);
149
150 private:
151 struct CachedNodeInfo
152 {
153 GraphNodePtr node;
154 armarx::FramedPosePtr globalPose;
155 std::vector<std::string> parents;
156 };
157
158 CachedNodeInfo getCacheEntry(const std::string& nodeId);
159 GraphNodeBasePtr getNearestNodeToPoseImpl(const std::string& sceneName,
160 const std::string& nodeParentName,
161 const Eigen::Matrix4f& pose,
162 bool ignoreOrientation = false,
163 bool ignoreParent = false);
164
165 memoryx::PriorKnowledgeInterfacePrx prior;
166 memoryx::WorkingMemoryInterfacePrx wm;
168
169 memoryx::ObjectInstanceMemorySegmentBasePrx objectInstances;
170 memoryx::GraphMemorySegmentBasePrx graphSegment;
171
172 std::map<std::string, std::map<std::string, armarx::FramedPositionPtr>>
173 relativePlacesettingPositions;
174 std::map<std::string, CachedNodeInfo> nodeInfoCache;
175 std::map<std::string, GraphNodeBaseList> sceneNodesCache;
176
177 std::recursive_mutex cacheMutex;
178 };
179
181} // 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