25 #include <AffordanceKit/ColorMap.h>
26 #include <AffordanceKit/primitives/Plane.h>
28 #include <Inventor/nodes/SoDrawStyle.h>
33 visualizationNode(nullptr)
57 return pose.block<3, 1>(0, 3) - offset * pose.block<3, 1>(0, 2);
62 float pos = (sampling1.block<3, 1>(0, 3) - sampling2.block<3, 1>(0, 3)).
norm();
64 float rot = sampling1.block<3, 1>(0, 2).normalized().dot(sampling2.block<3, 1>(0, 2).normalized());
65 CLAMP_TO_ACOS_DOMAIN(rot);
67 return pos + 1000 * acos(rot);
72 const float pointCloudVisualizationOffset = 2;
81 if (primitive->getId() != entry.first.first->getId())
86 unsigned int size = primitive->getSamplingSize();
87 if (size == 0 ||
affordance->getThetaSize(entry.first) != size)
94 if (boost::dynamic_pointer_cast<AffordanceKit::Plane>(primitive))
96 AffordanceKit::PlanePtr p = boost::dynamic_pointer_cast<AffordanceKit::Plane>(primitive);
98 Eigen::Vector3f
min = p->getBoundingBoxMin();
99 Eigen::Vector3f
max = p->getBoundingBoxMax();
102 armarx::PolygonPointList ppl;
103 ppl.push_back(
new armarx::Vector3(Eigen::Vector3f((pose * Eigen::Vector4f(
min(0),
min(1), 0, 1)).head(3))));
104 ppl.push_back(
new armarx::Vector3(Eigen::Vector3f((pose * Eigen::Vector4f(
max(0),
min(1), 0, 1)).head(3))));
105 ppl.push_back(
new armarx::Vector3(Eigen::Vector3f((pose * Eigen::Vector4f(
max(0),
max(1), 0, 1)).head(3))));
106 ppl.push_back(
new armarx::Vector3(Eigen::Vector3f((pose * Eigen::Vector4f(
min(0),
max(1), 0, 1)).head(3))));
108 debugDrawer->setPolygonVisu(layerName,
id +
"_boundingBox", ppl, armarx::DrawColor {0, 0, 0, 0}, armarx::DrawColor {0, 0, 0, 1}, 3);
109 debugDrawer->setPoseVisu(layerName,
id +
"_pose",
new armarx::Pose(p->getPose()));
113 armarx::DebugDrawer24BitColoredPointCloud originalSamplingPointCloud;
114 originalSamplingPointCloud.pointSize = 7;
115 originalSamplingPointCloud.transparency = 0;
116 originalSamplingPointCloud.points.reserve(size);
119 AffordanceKit::Belief maxBelief;
120 float maxExpectedProbability = -1;
123 for (
unsigned int i = 0; i < size; i++)
125 bool addCurrentPoint =
false;
129 P = primitive->getSampling(i);
134 addCurrentPoint =
true;
139 if (maxExpectedProbability >= minExpectedProbability)
143 armarx::DebugDrawer24BitColoredPointCloudElement e;
148 Eigen::Vector3i
c = AffordanceKit::ColorMap::GetVisualizationColor(maxBelief);
149 e.color = armarx::DrawColor24Bit {(
unsigned char)
c(0), (
unsigned char)
c(1), (
unsigned char)
c(2)};
151 originalSamplingPointCloud.points.push_back(e);
154 maxExpectedProbability = -1;
158 AffordanceKit::Belief b =
affordance->getTheta(AffordanceKit::PrimitivePair(primitive), i);
161 float v = b.expectedProbability();
162 if (maxExpectedProbability <
v)
166 maxExpectedProbability =
v;
170 debugDrawer->set24BitColoredPointCloudVisu(layerName,
id +
"_sampling", originalSamplingPointCloud);