26 #include <AffordanceKit/ColorMap.h>
27 #include <AffordanceKit/primitives/Plane.h>
28 #include <Inventor/nodes/SoDrawStyle.h>
33 const AffordanceKit::UnimanualAffordancePtr& unimanualAffordance) :
34 visualizationNode(nullptr)
60 return pose.block<3, 1>(0, 3) - offset * pose.block<3, 1>(0, 2);
67 float pos = (sampling1.block<3, 1>(0, 3) - sampling2.block<3, 1>(0, 3)).
norm();
70 sampling1.block<3, 1>(0, 2).normalized().dot(sampling2.block<3, 1>(0, 2).normalized());
71 CLAMP_TO_ACOS_DOMAIN(rot);
73 return pos + 1000 * acos(rot);
78 const std::string& layerName,
79 const std::string&
id,
80 float minExpectedProbability,
81 const AffordanceKit::PrimitivePtr& primitive)
83 const float pointCloudVisualizationOffset = 2;
92 if (primitive->getId() != entry.first.first->getId())
97 unsigned int size = primitive->getSamplingSize();
98 if (size == 0 ||
affordance->getThetaSize(entry.first) != size)
105 if (boost::dynamic_pointer_cast<AffordanceKit::Plane>(primitive))
107 AffordanceKit::PlanePtr p = boost::dynamic_pointer_cast<AffordanceKit::Plane>(primitive);
109 Eigen::Vector3f
min = p->getBoundingBoxMin();
110 Eigen::Vector3f
max = p->getBoundingBoxMax();
113 armarx::PolygonPointList ppl;
114 ppl.push_back(
new armarx::Vector3(Eigen::Vector3f((pose * Eigen::Vector4f(
min(0),
min(1), 0, 1)).head(3))));
115 ppl.push_back(
new armarx::Vector3(Eigen::Vector3f((pose * Eigen::Vector4f(
max(0),
min(1), 0, 1)).head(3))));
116 ppl.push_back(
new armarx::Vector3(Eigen::Vector3f((pose * Eigen::Vector4f(
max(0),
max(1), 0, 1)).head(3))));
117 ppl.push_back(
new armarx::Vector3(Eigen::Vector3f((pose * Eigen::Vector4f(
min(0),
max(1), 0, 1)).head(3))));
119 debugDrawer->setPolygonVisu(layerName,
id +
"_boundingBox", ppl, armarx::DrawColor {0, 0, 0, 0}, armarx::DrawColor {0, 0, 0, 1}, 3);
120 debugDrawer->setPoseVisu(layerName,
id +
"_pose",
new armarx::Pose(p->getPose()));
124 armarx::DebugDrawer24BitColoredPointCloud originalSamplingPointCloud;
125 originalSamplingPointCloud.pointSize = 7;
126 originalSamplingPointCloud.transparency = 0;
127 originalSamplingPointCloud.points.reserve(size);
130 AffordanceKit::Belief maxBelief;
131 float maxExpectedProbability = -1;
134 for (
unsigned int i = 0; i < size; i++)
136 bool addCurrentPoint =
false;
140 P = primitive->getSampling(i);
145 addCurrentPoint =
true;
150 if (maxExpectedProbability >= minExpectedProbability)
152 Eigen::Vector3f pos =
155 armarx::DebugDrawer24BitColoredPointCloudElement e;
161 AffordanceKit::ColorMap::GetVisualizationColor(maxBelief);
162 e.color = armarx::DrawColor24Bit{
163 (
unsigned char)
c(0), (
unsigned char)
c(1), (
unsigned char)
c(2)};
165 originalSamplingPointCloud.points.push_back(e);
168 maxExpectedProbability = -1;
172 AffordanceKit::Belief b =
173 affordance->getTheta(AffordanceKit::PrimitivePair(primitive), i);
176 float v = b.expectedProbability();
177 if (maxExpectedProbability <
v)
181 maxExpectedProbability =
v;
185 debugDrawer->set24BitColoredPointCloudVisu(
186 layerName,
id +
"_sampling", originalSamplingPointCloud);