26 #include <VirtualRobot/math/Helpers.h>
51 return _rn->getGlobalPose(pose);
60 return _rn->getGlobalPosition(position);
62 return (
_fallbackFrame * position.homogeneous()).eval().hnormalized();
69 return ::math::Helpers::TransformDirection(
_rn->getGlobalPose(), direction);
71 return ::math::Helpers::TransformDirection(
_fallbackFrame, direction);
91 #define CHECK_AND_ADD(name,type) if (!_helper->enableVisu) {return;} _helper->addNewElement(name,type);
114 void FrameView::drawLine(
const std::string& name,
const Eigen::Vector3f& p1,
const Eigen::Vector3f& p2,
float width,
const DrawColor& color)
121 void FrameView::drawText(
const std::string& name,
const Eigen::Vector3f& p1,
const std::string& text,
const DrawColor& color,
int size)
128 void FrameView::drawArrow(
const std::string& name,
const Eigen::Vector3f& pos,
const Eigen::Vector3f& direction,
const DrawColor& color,
float length,
float width)
135 void FrameView::drawSphere(
const std::string& name,
const Eigen::Vector3f& position,
float size,
const DrawColor& color)
141 void FrameView::drawPointCloud(
const std::string& name,
const std::vector<Eigen::Vector3f>& points,
float pointSize,
const DrawColor& color)
145 DebugDrawerColoredPointCloud
pc;
146 pc.pointSize = pointSize;
147 for (
const Eigen::Vector3f& p : points)
150 DebugDrawerColoredPointCloudElement e;
155 pc.points.push_back(e);
157 _helper->debugDrawerPrx->setColoredPointCloudVisu(
_helper->layerName, name,
pc);
164 _helper->debugDrawerPrx->setRobotVisu(
_helper->layerName, name, robotFile, armarxProject, DrawStyle::FullModel);
166 _helper->debugDrawerPrx->updateRobotColor(
_helper->layerName, name, color);
172 _helper->debugDrawerPrx->updateRobotConfig(
_helper->layerName, name, config);
177 _helper->debugDrawerPrx->updateRobotColor(
_helper->layerName, name, color);
190 for (std::size_t idx = 0; idx < poses.size(); ++idx)
199 for (std::size_t idx = 0; idx < poses.size(); ++idx)
206 void FrameView::drawBox(
const std::string& name,
const Eigen::Vector3f& position,
float size,
const DrawColor& color)
215 drawBox(name, pose, Eigen::Vector3f(size, size, size), color);
224 void FrameView::drawLines(
const std::string& prefix,
const std::vector<Eigen::Vector3f>& ps,
float width,
const DrawColor& color)
227 for (std::size_t idx = 1; idx < ps.size(); ++idx)
235 for (std::size_t idx = 1; idx < ps.size(); ++idx)
240 void FrameView::drawLines(
const std::string& prefix,
const std::vector<Eigen::Matrix4f>& ps,
float width,
const DrawColor& color)
243 for (std::size_t idx = 1; idx < ps.size(); ++idx)
246 ps.at(idx - 1).topRightCorner<3, 1>(),
247 ps.at(idx).topRightCorner<3, 1>(),
254 for (std::size_t idx = 1; idx < ps.size(); ++idx)
257 ps.at(idx - 1).topRightCorner<3, 1>(),
258 ps.at(idx).topRightCorner<3, 1>());
267 const std::string& layerName,
270 FrameView(*this, robot ? robot->getRootNode() : nullptr),
271 debugDrawerPrx(debugDrawerPrx), layerName(layerName), robot(robot)
284 debugDrawerPrx->clearLayer(layerName);
309 if (newElements.find(old) == newElements.end())
315 oldElements = newElements;
321 this->enableVisu = enableVisu;
330 debugDrawerPrx->removePoseVisu(layerName, name);
333 debugDrawerPrx->removeBoxVisu(layerName, name);
336 debugDrawerPrx->removeLineVisu(layerName, name);
339 debugDrawerPrx->removeTextVisu(layerName, name);
342 debugDrawerPrx->removeArrowVisu(layerName, name);
345 debugDrawerPrx->removeColoredPointCloudVisu(layerName, name);
348 debugDrawerPrx->removeRobotVisu(layerName, name);
360 return debugDrawerPrx;
366 debugDrawerPrx = drawer;
376 return {*
this, frame};
387 return {*
this, robot->getRobotNode(nodeName)};
393 return {*
this, node};
413 _rn = robot->getRobotNode(nodeName);
426 newElements.insert(DrawElement {name, type});
439 ::math::Helpers::Lerp(
a.r, b.r, f),
440 ::math::Helpers::Lerp(
a.g, b.g, f),
441 ::math::Helpers::Lerp(
a.b, b.b, f),
442 ::math::Helpers::Lerp(
a.a, b.a, f)