24 #include <ArmarXCore/interface/core/UserException.h>
27 #include <Eigen/Geometry>
37 #define GRAPH_NODE_ATTR_SCENE memoryx::GraphNode::GRAPH_NODE_ATTR_SCENE
38 #define GRAPH_NODE_ATTR_POSE "pose"
39 #define GRAPH_NODE_ATTR_ADJ_NODES "adjacentNodes"
41 memoryx::GraphNode::GraphNode()
46 memoryx::GraphNode::GraphNode(
float x,
float y,
float alpha,
const std::string& nodeName,
const std::string& scene)
48 Eigen::AngleAxisf aa(alpha, Eigen::Vector3f(0, 0, 1));
53 Eigen::Vector3f(x, y, 0),
61 memoryx::GraphNode::GraphNode(armarx::FramedPoseBasePtr pose,
const std::string& nodeName,
const std::string& scene)
105 auto deg = getOutdegree();
107 if (i < 0 || i >= deg)
110 s <<
"Graph node: Access to adjacent node with index " << i <<
"! (outdegree is " << deg <<
")";
111 throw armarx::IndexOutOfBoundsException {
s.str()};
114 return armarx::VariantPtr::dynamicCast(getAttribute(
GRAPH_NODE_ATTR_ADJ_NODES)->getValueAt(i))->getClass< memoryx::EntityRefBase>();
119 int nodes = getOutdegree();
120 for (
int i = 0; i < nodes; ++i)
122 auto node = getAdjacentNode(i);
123 if (node->entityId == nodeId)
133 memoryx::GraphNodeBaseList result;
134 int nodes = getOutdegree();
135 for (
int i = 0; i < nodes; ++i)
137 auto nodeEntity = getAdjacentNode(i);
138 auto graphNode = GraphNodeBasePtr::dynamicCast(nodeEntity->getEntity());
140 result.push_back(graphNode);
147 ARMARX_VERBOSE_S <<
"node " << getName() <<
" (" << getId() <<
") in scene " << getScene()
148 <<
": adding new adjacent node...";
150 if (!memoryx::GraphNodeBasePtr::dynamicCast(newAdjacentNode->getEntity(
c)))
152 std::stringstream
s {};
153 s <<
"Expected " << memoryx::GraphNodeBase::ice_id(
c);
154 throw armarx::InvalidTypeException {
s.str()};
158 ARMARX_VERBOSE_S <<
"adding new adjacent node: done! (new outdegree: " << getOutdegree() <<
")";
168 int nodes = getOutdegree();
169 for (
int i = 0; i < nodes; ++i)
171 auto node = getAdjacentNode(i);
172 if (node->entityId == nodeId)
183 Eigen::Matrix3f mat = armarx::QuaternionPtr::dynamicCast(getPose()->orientation)->toEigen();
184 Eigen::Vector3f rpy = mat.eulerAngles(0, 1, 2);
190 return this->clone();