26 #include <VirtualRobot/Nodes/RobotNode.h>
27 #include <VirtualRobot/Robot.h>
28 #include <VirtualRobot/math/Helpers.h>
40 _helper{&helper}, _fallbackFrame{frame}
45 _helper{&helper}, _rn{rn}
56 return _rn->getGlobalPose(pose);
67 return _rn->getGlobalPosition(position);
69 return (
_fallbackFrame * position.homogeneous()).eval().hnormalized();
78 return ::math::Helpers::TransformDirection(
_rn->getGlobalPose(), direction);
80 return ::math::Helpers::TransformDirection(
_fallbackFrame, direction);
106 #define CHECK_AND_ADD(name, type) \
107 if (!_helper->enableVisu) \
111 _helper->addNewElement(name, type);
126 _helper->debugDrawerPrx->setScaledPoseVisu(
133 const Eigen::Vector3f& size,
134 const DrawColor& color)
138 _helper->debugDrawerPrx->setBoxVisu(
144 const Eigen::Vector3f& p1,
145 const Eigen::Vector3f& p2,
147 const DrawColor& color)
151 _helper->debugDrawerPrx->setLineVisu(
157 const Eigen::Vector3f& p1,
158 const std::string& text,
159 const DrawColor& color,
164 _helper->debugDrawerPrx->setTextVisu(
170 const Eigen::Vector3f& pos,
171 const Eigen::Vector3f& direction,
172 const DrawColor& color,
189 const Eigen::Vector3f& position,
191 const DrawColor& color)
194 _helper->debugDrawerPrx->setSphereVisu(
200 const std::vector<Eigen::Vector3f>& points,
202 const DrawColor& color)
206 DebugDrawerColoredPointCloud
pc;
207 pc.pointSize = pointSize;
208 for (
const Eigen::Vector3f& p : points)
211 DebugDrawerColoredPointCloudElement e;
217 pc.points.push_back(e);
219 _helper->debugDrawerPrx->setColoredPointCloudVisu(
_helper->layerName, name,
pc);
224 const std::string& robotFile,
225 const std::string& armarxProject,
227 const DrawColor& color)
231 _helper->debugDrawerPrx->setRobotVisu(
232 _helper->layerName, name, robotFile, armarxProject, DrawStyle::FullModel);
234 _helper->debugDrawerPrx->updateRobotColor(
_helper->layerName, name, color);
241 _helper->debugDrawerPrx->updateRobotConfig(
_helper->layerName, name, config);
248 _helper->debugDrawerPrx->updateRobotColor(
_helper->layerName, name, color);
265 for (std::size_t idx = 0; idx < poses.size(); ++idx)
274 const std::vector<Eigen::Matrix4f>& poses,
278 for (std::size_t idx = 0; idx < poses.size(); ++idx)
287 const Eigen::Vector3f& position,
289 const DrawColor& color)
294 Eigen::Vector3f(size, size, size),
302 const DrawColor& color)
305 drawBox(name, pose, Eigen::Vector3f(size, size, size), color);
310 const Eigen::Vector3f& p1,
311 const Eigen::Vector3f& p2)
319 const std::vector<Eigen::Vector3f>& ps,
321 const DrawColor& color)
324 for (std::size_t idx = 1; idx < ps.size(); ++idx)
334 for (std::size_t idx = 1; idx < ps.size(); ++idx)
342 const std::vector<Eigen::Matrix4f>& ps,
344 const DrawColor& color)
347 for (std::size_t idx = 1; idx < ps.size(); ++idx)
350 ps.at(idx - 1).topRightCorner<3, 1>(),
351 ps.at(idx).topRightCorner<3, 1>(),
361 for (std::size_t idx = 1; idx < ps.size(); ++idx)
364 ps.at(idx - 1).topRightCorner<3, 1>(),
365 ps.at(idx).topRightCorner<3, 1>());
373 const std::string& layerName,
375 FrameView(*this, robot ? robot->getRootNode() : nullptr),
376 debugDrawerPrx(debugDrawerPrx),
377 layerName(layerName),
384 FrameView(*this, nullptr), layerName{layerName}
393 debugDrawerPrx->clearLayer(layerName);
419 if (newElements.find(old) == newElements.end())
425 oldElements = newElements;
432 this->enableVisu = enableVisu;
443 debugDrawerPrx->removePoseVisu(layerName, name);
446 debugDrawerPrx->removeBoxVisu(layerName, name);
449 debugDrawerPrx->removeLineVisu(layerName, name);
452 debugDrawerPrx->removeTextVisu(layerName, name);
455 debugDrawerPrx->removeArrowVisu(layerName, name);
458 debugDrawerPrx->removeColoredPointCloudVisu(layerName, name);
461 debugDrawerPrx->removeRobotVisu(layerName, name);
475 return debugDrawerPrx;
482 debugDrawerPrx = drawer;
494 return {*
this, frame};
509 return {*
this, robot->getRobotNode(nodeName)};
517 return {*
this, node};
542 _rn = robot->getRobotNode(nodeName);
555 DebugDrawerHelper::addNewElement(
const std::string& name,
559 newElements.insert(DrawElement{name, type});
571 return DrawColor{::math::Helpers::Lerp(
a.r, b.r, f),
572 ::math::Helpers::Lerp(
a.g, b.g, f),
573 ::math::Helpers::Lerp(
a.b, b.b, f),
574 ::math::Helpers::Lerp(
a.a, b.a, f)};