26#include <VirtualRobot/Nodes/RobotNode.h>
27#include <VirtualRobot/Robot.h>
28#include <VirtualRobot/math/Helpers.h>
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(
132 const Eigen::Matrix4f& pose,
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,
226 const Eigen::Matrix4f& pose,
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)
267 Eigen::Matrix4f
const& pose = poses[idx];
268 drawPose(prefix + std::to_string(idx), pose);
274 const std::vector<Eigen::Matrix4f>& poses,
278 for (std::size_t idx = 0; idx < poses.size(); ++idx)
280 Eigen::Matrix4f
const& pose = poses[idx];
281 drawPose(prefix + std::to_string(idx), pose, scale);
287 const Eigen::Vector3f& position,
289 const DrawColor& color)
293 Helpers::CreatePose(position, Eigen::Matrix3f::Identity()),
294 Eigen::Vector3f(size, size, size),
300 const Eigen::Matrix4f& pose,
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)
326 drawLine(prefix + std::to_string(idx), ps.at(idx - 1), ps.at(idx), width, color);
334 for (std::size_t idx = 1; idx < ps.size(); ++idx)
336 drawLine(prefix + std::to_string(idx), ps.at(idx - 1), ps.at(idx));
342 const std::vector<Eigen::Matrix4f>& ps,
344 const DrawColor& color)
347 for (std::size_t idx = 1; idx < ps.size(); ++idx)
349 drawLine(prefix + std::to_string(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)
363 drawLine(prefix + std::to_string(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;
491 DebugDrawerHelper::FrameView
494 return {*
this, frame};
497 DebugDrawerHelper::FrameView
500 return {*
this, Eigen::Matrix4f::Identity()};
503 DebugDrawerHelper::FrameView
509 return {*
this, robot->getRobotNode(nodeName)};
512 DebugDrawerHelper::FrameView
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)};
#define CHECK_AND_ADD(name, type)
static const DrawColor Red
static const DrawColor Blue
static const DrawColor Orange
static const DrawColor Yellow
static DrawColor Lerp(const DrawColor &a, const DrawColor &b, float f)
static const DrawColor Green
DebugDrawerHelper(const DebugDrawerInterfacePrx &debugDrawerPrx, const std::string &layerName, const VirtualRobot::RobotPtr &robot)
void removeElement(const std::string &name, DrawElementType type)
FrameView inGlobalFrame()
const DebugDrawerInterfacePrx & getDebugDrawer() const
void setVisuEnabled(bool enableVisu)
FrameView inFrame(const Eigen::Matrix4f &frame=Eigen::Matrix4f::Identity())
void setDefaultFrameToGlobal()
void setDebugDrawer(const DebugDrawerInterfacePrx &drawer)
void setRobot(const VirtualRobot::RobotPtr &rob)
const VirtualRobot::RobotPtr & getRobot() const
void setDefaultFrame(const Eigen::Matrix4f &frame=Eigen::Matrix4f::Identity())
void drawLine(const std::string &name, const Eigen::Vector3f &p1, const Eigen::Vector3f &p2, float width, const DrawColor &color)
FrameView(class DebugDrawerHelper &helper, const Eigen::Matrix4f frame=Eigen::Matrix4f::Identity())
void setRobotConfig(const std::string &name, const std::map< std::string, float > &config)
class DebugDrawerHelper * _helper
void drawText(const std::string &name, const Eigen::Vector3f &p1, const std::string &text, const DrawColor &color, int size)
VirtualRobot::RobotNodePtr _rn
void drawLines(const std::string &prefix, const std::vector< Eigen::Vector3f > &ps, float width, const DrawColor &color)
void drawBox(const std::string &name, const Eigen::Matrix4f &pose, const Eigen::Vector3f &size, const DrawColor &color)
Eigen::Matrix4f _fallbackFrame
void drawArrow(const std::string &name, const Eigen::Vector3f &pos, const Eigen::Vector3f &direction, const DrawColor &color, float length, float width)
Eigen::Matrix4f makeGlobalEigen(const Eigen::Matrix4f &pose) const
void setRobotPose(const std::string &name, const Eigen::Matrix4f &pose)
void drawRobot(const std::string &name, const std::string &robotFile, const std::string &armarxProject, const Eigen::Matrix4f &pose, const DrawColor &color)
void drawPointCloud(const std::string &name, const std::vector< Eigen::Vector3f > &points, float pointSize, const DrawColor &color)
void drawPoses(const std::string &prefix, const std::vector< Eigen::Matrix4f > &poses)
void drawPose(const std::string &name, const Eigen::Matrix4f &pose)
Vector3Ptr makeGlobalDirection(const Eigen::Vector3f &direction) const
void drawSphere(const std::string &name, const Eigen::Vector3f &position, float size, const DrawColor &color)
PosePtr makeGlobal(const Eigen::Matrix4f &pose) const
void setRobotColor(const std::string &name, const DrawColor &color)
Eigen::Vector3f makeGlobalDirectionEigen(const Eigen::Vector3f &direction) const
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
std::shared_ptr< class Robot > RobotPtr
::armarx::DebugDrawerHelper::DrawElementType DrawElementType
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< Vector3 > Vector3Ptr
IceInternal::Handle< Pose > PosePtr
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface > DebugDrawerInterfacePrx