24 static armarx::DrawColor toArmarx(
const semrel::DrawColor& color)
26 return armarx::DrawColor { color.r, color.g, color.b, color.a };
31 semrel::VisualizerInterface::setImplementation(std::make_shared<ArmarXVisualizer>(debugDrawer));
46 drawer->clearLayer(layer);
49 void ArmarXVisualizer::drawLine(semrel::VisuMetaInfo
id,
const Eigen::Vector3f& start,
const Eigen::Vector3f& end,
float lineWidth, semrel::DrawColor color)
51 drawer->setLineVisu(
id.layer,
id.name, toArmarx(start), toArmarx(end), lineWidth, toArmarx(color));
54 void ArmarXVisualizer::drawArrow(semrel::VisuMetaInfo
id,
const Eigen::Vector3f& origin,
const Eigen::Vector3f& direction,
float length,
float width, semrel::DrawColor color)
56 drawer->setArrowVisu(
id.layer,
id.name, toArmarx(origin), toArmarx(direction), toArmarx(color), length, width);
61 drawer->setBoxVisu(
id.layer,
id.name, toArmarx(box.getPosition(), box.getOrientation()),
62 toArmarx(box.getExtents()), toArmarx(color));
67 drawer->setCylinderVisu(
id.layer,
id.name, toArmarx(cylinder.getPosition()), toArmarx(cylinder.getAxisDirection()),
68 cylinder.getHeight(), cylinder.getRadius(), toArmarx(color));
73 drawer->setSphereVisu(
id.layer,
id.name, toArmarx(sphere.getPosition()), toArmarx(color), sphere.getRadius());
76 void ArmarXVisualizer::drawPolygon(semrel::VisuMetaInfo
id,
const std::vector<Eigen::Vector3f>& polygonPoints,
float lineWidth, semrel::DrawColor colorInner, semrel::DrawColor colorBorder)
78 armarx::PolygonPointList armarxPoints;
79 for (
const Eigen::Vector3f&
v : polygonPoints)
81 armarxPoints.push_back(toArmarx(
v));
84 drawer->setPolygonVisu(
id.layer,
id.name, armarxPoints, toArmarx(colorInner), toArmarx(colorBorder), lineWidth);
101 for (semrel::TriMesh::Triangle triangle : mesh.getTriangles())
103 semrel::VisuMetaInfo triID = id;
104 std::stringstream ss;
105 ss << triID.name <<
"_" << i;
106 triID.name = ss.str();
108 Eigen::Vector3f v0 = mesh.getVertex(triangle.v0);
109 Eigen::Vector3f v1 = mesh.getVertex(triangle.v1);
110 Eigen::Vector3f v2 = mesh.getVertex(triangle.v2);
111 std::vector<Eigen::Vector3f> points;
112 points.push_back(v0);
113 points.push_back(v1);
114 points.push_back(v2);
116 semrel::DrawColor inner = color;
124 void ArmarXVisualizer::drawText(semrel::VisuMetaInfo
id,
const std::string& text,
const Eigen::Vector3f& position,
float size, semrel::DrawColor color)
126 drawer->setTextVisu(
id.layer,
id.name, text, toArmarx(position), toArmarx(color),
int(roundf(size)));
131 armarx::DrawColor armarxColor = toArmarx(color);
133 armarx::DebugDrawerColoredPointCloud ddPointcloud;
134 ddPointcloud.pointSize = pointSize;
136 for (
const Eigen::Vector3f&
v : cloud)
138 armarx::DebugDrawerColoredPointCloudElement el {
v(0),
v(1),
v(2), armarxColor };
139 ddPointcloud.points.push_back(el);
142 drawer->setColoredPointCloudVisu(
id.layer,
id.name, ddPointcloud);
147 "Visualization level: Determines what is shown in the debug drawer.\n"
148 "Possible values: live, verbose, result, user, disabled";
153 semrel::VisuLevel defaultLevel,
const std::string& description)
156 .map(
"live", semrel::VisuLevel::LIVE_VISU)
157 .map(
"verbose", semrel::VisuLevel::VERBOSE)
158 .map(
"result", semrel::VisuLevel::RESULT)
159 .map(
"user", semrel::VisuLevel::USER)
160 .map(
"disabled", semrel::VisuLevel::DISABLED);
165 return defs.
getProperty<semrel::VisuLevel>(propertyName);