24 #include <Eigen/Geometry>
28 #include <ArmarXCore/interface/core/UserException.h>
36 #define GRAPH_NODE_ATTR_SCENE memoryx::GraphNode::GRAPH_NODE_ATTR_SCENE
37 #define GRAPH_NODE_ATTR_POSE "pose"
38 #define GRAPH_NODE_ATTR_ADJ_NODES "adjacentNodes"
40 memoryx::GraphNode::GraphNode()
44 memoryx::GraphNode::GraphNode(
float x,
47 const std::string& nodeName,
48 const std::string& scene)
50 Eigen::AngleAxisf aa(alpha, Eigen::Vector3f(0, 0, 1));
60 memoryx::GraphNode::GraphNode(armarx::FramedPoseBasePtr pose,
61 const std::string& nodeName,
62 const std::string& scene)
79 armarx::FramedPoseBasePtr
109 memoryx::EntityRefBasePtr
112 auto deg = getOutdegree();
114 if (i < 0 || i >= deg)
117 s <<
"Graph node: Access to adjacent node with index " << i <<
"! (outdegree is " << deg
119 throw armarx::IndexOutOfBoundsException{
s.str()};
123 ->getClass<memoryx::EntityRefBase>();
126 memoryx::EntityRefBasePtr
129 int nodes = getOutdegree();
130 for (
int i = 0; i < nodes; ++i)
132 auto node = getAdjacentNode(i);
133 if (node->entityId == nodeId)
141 memoryx::GraphNodeBaseList
144 memoryx::GraphNodeBaseList result;
145 int nodes = getOutdegree();
146 for (
int i = 0; i < nodes; ++i)
148 auto nodeEntity = getAdjacentNode(i);
149 auto graphNode = GraphNodeBasePtr::dynamicCast(nodeEntity->getEntity());
151 result.push_back(graphNode);
158 const Ice::Current&
c)
160 ARMARX_VERBOSE_S <<
"node " << getName() <<
" (" << getId() <<
") in scene " << getScene()
161 <<
": adding new adjacent node...";
163 if (!memoryx::GraphNodeBasePtr::dynamicCast(newAdjacentNode->getEntity(
c)))
165 std::stringstream
s{};
166 s <<
"Expected " << memoryx::GraphNodeBase::ice_id(
c);
167 throw armarx::InvalidTypeException{
s.str()};
172 ARMARX_VERBOSE_S <<
"adding new adjacent node: done! (new outdegree: " << getOutdegree() <<
")";
185 int nodes = getOutdegree();
186 for (
int i = 0; i < nodes; ++i)
188 auto node = getAdjacentNode(i);
189 if (node->entityId == nodeId)
201 Eigen::Matrix3f mat = armarx::QuaternionPtr::dynamicCast(getPose()->orientation)->toEigen();
202 Eigen::Vector3f rpy = mat.eulerAngles(0, 1, 2);
209 return this->clone();