Go to the documentation of this file.
7 #include <Eigen/Geometry>
9 #include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
33 class ManagedIceObject;
188 template <
typename Source>
274 const std::string&
getLayer()
const;
276 void setLayer(
const std::string& layer);
305 template <
typename DurationT>
306 void sleepFor(
const DurationT& duration);
309 template <
typename DurationT>
325 void clearLayer(
const std::string& layer,
bool sleep =
false);
334 void drawText(
const VisuID&
id,
const Eigen::Vector3f& position,
const std::string& text,
336 bool ignoreLengthScale =
false);
342 bool ignoreLengthScale =
false);
346 bool ignoreLengthScale =
false);
350 const VirtualRobot::BoundingBox& boundingBox,
352 bool ignoreLengthScale =
false);
356 const VirtualRobot::BoundingBox& boundingBox,
const Eigen::Matrix4f& pose,
358 bool ignoreLengthScale =
false);
368 const Eigen::Vector3f& extents,
370 bool ignoreLengthScale =
false);
376 bool ignoreLengthScale =
false);
380 const VirtualRobot::BoundingBox& boundingBox,
382 bool ignoreLengthScale =
false);
388 bool ignoreLengthScale =
false);
392 const VirtualRobot::BoundingBox& boundingBox,
const Eigen::Matrix4f& pose,
394 bool ignoreLengthScale =
false);
400 bool ignoreLengthScale =
false);
412 const Eigen::Vector3f& center,
const Eigen::Vector3f& direction,
float length,
float radius,
414 bool ignoreLengthScale =
false);
423 const Eigen::Vector3f& center,
const Eigen::Quaternionf& orientation,
float length,
float radius,
425 bool ignoreLengthScale =
false);
430 const Eigen::Vector3f& from,
const Eigen::Vector3f& to,
float radius,
432 bool ignoreLengthScale =
false);
441 const Eigen::Vector3f& center,
float radius,
443 bool ignoreLengthScale =
false);
452 const Eigen::Vector3f& position,
const Eigen::Vector3f& direction,
float length,
454 bool ignoreLengthScale =
false);
459 const Eigen::Vector3f& from,
const Eigen::Vector3f& to,
461 bool ignoreLengthScale =
false);
470 const std::vector<Eigen::Vector3f>& points,
471 const DrawColor& colorFace,
473 bool ignoreLengthScale =
false);
482 const Eigen::Vector3f& from,
const Eigen::Vector3f& to,
484 bool ignoreLengthScale =
false);
493 const DebugDrawerLineSet& lineSet,
494 bool ignoreLengthScale =
false);
502 const std::vector<Eigen::Vector3f>& points,
504 bool ignoreLengthScale =
false);
513 const std::vector<Eigen::Vector3f>& points,
514 float width,
const DrawColor& colorA,
const DrawColor& colorB,
515 const std::vector<float>& intensitiesB,
516 bool ignoreLengthScale =
false);
526 bool ignoreLengthScale =
false);
529 bool ignoreLengthScale =
false);
533 bool ignoreLengthScale =
false);
537 bool ignoreLengthScale =
false);
556 const std::string& robotFile,
const std::string& armarxProject,
557 armarx::DrawStyle drawStyle = armarx::DrawStyle::FullModel);
563 bool ignoreScale =
false);
569 bool ignoreScale =
false);
574 const std::map<std::string, float>& config);
580 const VisuID&
id,
const std::string& nodeName,
const DrawColor& color);
591 const VirtualRobot::TriMeshModel& triMesh,
592 const DrawColor& color = {.5, .5, .5, 1},
593 bool ignoreLengthScale =
false);
598 const VirtualRobot::TriMeshModel& trimesh,
601 bool ignoreLengthScale =
false);
606 const VirtualRobot::TriMeshModel& trimesh,
const Eigen::Matrix4f& pose,
609 bool ignoreLengthScale =
false);
614 const VirtualRobot::TriMeshModel& trimesh,
615 const std::vector<DrawColor>& faceColorsInner,
617 bool ignoreLengthScale =
false);
630 template <
class Po
intCloudT>
636 bool ignoreLengthScale =
false);
644 template <
class Po
intCloudT>
649 bool ignoreLengthScale =
false);
657 template <
class Po
intCloudT>
662 bool ignoreLengthScale =
false);
673 template <
class Po
intCloudT,
class ColorFuncT>
677 const ColorFuncT& colorFunc,
679 bool ignoreLengthScale =
false);
685 void drawPointCloud(
const VisuID&
id,
const DebugDrawerPointCloud& pointCloud);
688 void drawPointCloud(
const VisuID&
id,
const DebugDrawerColoredPointCloud& pointCloud);
691 void drawPointCloud(
const VisuID&
id,
const DebugDrawer24BitColoredPointCloud& pointCloud);
707 const VisuID&
id = {
"floor" },
708 const Eigen::Vector3f& at = Eigen::Vector3f::Zero(),
709 const Eigen::Vector3f& up = Eigen::Vector3f::UnitZ(),
711 bool ignoreLengthScale =
false);
718 operator bool()
const;
736 static Eigen::Vector3f
rgb2hsv(
const Eigen::Vector3f& rgb);
743 static Eigen::Vector3f
hsv2rgb(
const Eigen::Vector3f& hsv);
757 template <
class ColorT>
758 static DrawColor
toDrawColor(
const ColorT& color,
float alpha = 1,
bool byteToFloat =
false);
770 const std::string& layer(
const std::string& passedLayer)
const;
773 const std::string& layer(
const VisuID&
id)
const;
777 float lengthScale(
bool ignore =
false)
const;
780 static float scaled(
float scale,
float value);
782 static Vector3BasePtr scaled(
float scale,
const Eigen::Vector3f& vector);
788 template <
class ScaledT>
789 static ScaledT scaledT(
float scale,
const Eigen::Vector3f& vector);
792 template <
class XYZT>
793 static void scaleXYZ(
float scale, XYZT& xyz);
799 static const std::string TOPIC_NAME;
801 static const std::string DEFAULT_LAYER;
808 bool _enabled =
true;
811 std::string _layer = DEFAULT_LAYER;
814 float _lengthScale = 1;
817 float _poseScale = 1;
820 std::chrono::milliseconds _shortSleepDuration { 100 };
825 template <
typename DurationT>
830 std::this_thread::sleep_for(duration);
834 template <
typename DurationT>
837 this->_shortSleepDuration = std::chrono::duration_cast<std::chrono::milliseconds>(duration);
840 template <
class ColorT>
843 const float scale = byteToFloat ? (1 / 255.f) : 1;
844 return { color.r * scale, color.g * scale, color.b * scale, alpha };
848 template <
class Po
intCloudT>
852 const DrawColor& color,
854 bool ignoreLengthScale)
860 pointSize, ignoreLengthScale);
863 template<
class Po
intCloudT>
868 bool ignoreLengthScale)
874 pointSize, ignoreLengthScale);
877 template <
class Po
intCloudT>
882 bool ignoreLengthScale)
888 pointSize, ignoreLengthScale);
891 template <
class Po
intCloudT,
class ColorFuncT>
895 const ColorFuncT& colorFn,
897 bool ignoreLengthScale)
904 const float lf = ignoreLengthScale ? 1.0 : _lengthScale;
906 DebugDrawerColoredPointCloud dd;
907 dd.points.reserve(pointCloud.size());
909 dd.pointSize = pointSize;
911 for (
const auto& p : pointCloud)
913 dd.points.push_back(DebugDrawerColoredPointCloudElement
915 lf * p.x, lf * p.y, lf * p.z, colorFn(p)
923 template <
class ScaledT>
924 ScaledT DebugDrawerTopic::scaledT(
float scale,
const Eigen::Vector3f& vector)
926 auto scaled = vector * scale;
927 return { scaled.x(), scaled.y(), scaled.z() };
930 template <
class XYZT>
931 void DebugDrawerTopic::scaleXYZ(
float scale, XYZT& xyz)
void setTopic(const DebugDrawerInterfacePrx &topic)
Set the topic.
void sleepFor(const DurationT &duration)
If enabled, sleep for the given duration (e.g. a chrono duration).
void offeringTopic(ManagedIceObject &component, const std::string &topicNameOverride="") const
Call offeringTopic([topicName]) on the given component.
The DebugDrawerTopic wraps a DebugDrawerInterfacePrx and provides a more useful interface than the Ic...
static DrawColor getGlasbeyLUTColor(int id, float alpha=1.f)
Get a color from the Glasbey look-up-table.
std::string layer
The layer name (empty by default).
void drawLineSet(const VisuID &id, const DebugDrawerLineSet &lineSet, bool ignoreLengthScale=false)
Draw a line set.
bool enabled() const
Indicate whether visualization is enabled, i.e. a topic is set and enabled flag is set.
void drawPointCloudLabeled(const VisuID &id, const PointCloudT &pointCloud, float pointSize=DEFAULTS.pointCloudPointSize, bool ignoreLengthScale=false)
Draw a colored point cloud with colors according to labels.
void drawText(const VisuID &id, const Eigen::Vector3f &position, const std::string &text, int size=10, const DrawColor color=DEFAULTS.colorText, bool ignoreLengthScale=false)
Draw text at the specified position.
DebugDrawerTopic(const std::string &layer=DEFAULT_LAYER)
Construct without topic, and optional layer.
void removeboxEdges(const VisuID &id)
Remove box edges (as a line set).
void drawLine(const VisuID &id, const Eigen::Vector3f &from, const Eigen::Vector3f &to, float width, const DrawColor &color=DEFAULTS.colorLine, bool ignoreLengthScale=false)
Draw a line from start to end.
void drawFloor(const VisuID &id={ "floor" }, const Eigen::Vector3f &at=Eigen::Vector3f::Zero(), const Eigen::Vector3f &up=Eigen::Vector3f::UnitZ(), float size=5, const DrawColor &color=DEFAULTS.colorFloor, bool ignoreLengthScale=false)
Draw a quad representing the floor.
void shortSleep()
Sleep for the shortSleepDuration. Useful after clearing.
DrawColor colorPolygonEdge
DebugDrawerInterfacePrx & operator->()
Pointer member access operator to access the raw debug drawer proxy.
void setLengthScaleMillimetersToMeters()
Set the scale for positions, lengths and distances to 0.001.
VisuID withName(const std::string &name) const
Get a VisuID with the given name and same layer as `*this.
void setLengthScale(float scale)
Set the scale for positions, lengths and distances.
static DrawColor toDrawColor(const ColorT &color, float alpha=1, bool byteToFloat=false)
Construct a DrawColor from the given color type.
static Eigen::Vector3f hsv2rgb(const Eigen::Vector3f &hsv)
Convert a HSV color RGB.
VisuID()
Empty constructor.
void drawPointCloudRGBA(const VisuID &id, const PointCloudT &pointCloud, float pointSize=DEFAULTS.pointCloudPointSize, bool ignoreLengthScale=false)
Draw a colored point cloud with RGBA information.
void removeRobot(const VisuID &id)
Remove a robot visualization.
void updateRobotNodeColor(const VisuID &id, const std::string &nodeName, const DrawColor &color)
Update / set the color of a robot node.
float pointCloudPointSize
void clearColoredPointCloud(const VisuID &id)
Forces the "deletion" of a point cloud by drawing an empty one.
VisuID(const Source &name)
Construct a VisuID from a non-std::string source (e.g. char[]).
void clearLayer(bool sleep=false)
Clear the (set default) layer.
static Eigen::Vector3f rgb2hsv(const Eigen::Vector3f &rgb)
Convert a RGB color to HSV.
const std::string & getLayer() const
Get the default layer (used if no layer is passed to a method).
void updateRobotConfig(const VisuID &id, const std::map< std::string, float > &config)
Update / set the robot configuration (joint angles).
void removeArrow(const VisuID &id)
Remove an arrow.
std::shared_ptr< Value > value()
void drawCylinder(const VisuID &id, const Eigen::Vector3f ¢er, const Eigen::Vector3f &direction, float length, float radius, const DrawColor &color=DEFAULTS.colorCylinder, bool ignoreLengthScale=false)
Draw a cylinder with center and direction.
void setLengthScaleMetersToMillimeters()
Set the scale for positions, lengths and distances to 1000.
void removePolygon(const VisuID &id)
Remove a polygon.
void updateRobotColor(const VisuID &id, const DrawColor &color)
Update / set the robot color.
void drawArrowFromTo(const VisuID &id, const Eigen::Vector3f &from, const Eigen::Vector3f &to, float width, const DrawColor &color=DEFAULTS.colorArrow, bool ignoreLengthScale=false)
Draw an arrow with start and end.
void setPoseScaleMeters()
Set the pose scale to 0.001 (good when drawing in meters).
std::string name
The visu name (empty by default).
float getLengthScale() const
Get the scaling for positions, lengths and distances.
void drawBox(const VisuID &id, const Eigen::Vector3f &position, const Eigen::Quaternionf &orientation, const Eigen::Vector3f &extents, const DrawColor &color=DEFAULTS.colorBox, bool ignoreLengthScale=false)
Draw a box.
float getPoseScale() const
Get the scale for pose visualization.
pcl::PointCloud< PointT > PointCloudT
void setShortSleepDuration(const DurationT &duration)
Set the duration for "short sleeps".
void removeBox(const VisuID &id)
Remove a box.
DrawColor colorPolygonFace
void drawPose(const VisuID &id, const Eigen::Matrix4f &pose, bool ignoreLengthScale=false)
Draw a pose (with the preset scale).
DrawColor colorPointCloud
The ManagedIceObject is the base class for all ArmarX objects.
MatrixXX< 4, 4, float > Matrix4f
void setPoseScale(float scale)
Set the scale for pose visualization.
void setLayer(const std::string &layer)
Set the default layer (used if no layer is passed to a method).
void drawBoxEdges(const VisuID &id, const Eigen::Vector3f &position, const Eigen::Quaternionf &orientation, const Eigen::Vector3f &extents, float width=DEFAULTS.boxEdgesWidth, const DrawColor &color=DEFAULTS.boxEdgesColor, bool ignoreLengthScale=false)
Draw box edges (as a line set).
void removeLine(const VisuID &id)
Remove a line.
void drawTriMesh(const VisuID &id, const VirtualRobot::TriMeshModel &triMesh, const DrawColor &color={.5,.5,.5, 1}, bool ignoreLengthScale=false)
Draw a TriMeshModel as DebugDrawerTriMesh.
void updateRobotPose(const VisuID &id, const Eigen::Matrix4f &pose, bool ignoreScale=false)
Update / set the robot pose.
void drawPointCloud(const VisuID &id, const PointCloudT &pointCloud, const DrawColor &color=DEFAULTS.colorPointCloud, float pointSize=DEFAULTS.pointCloudPointSize, bool ignoreLengthScale=false)
Draw a unicolored point cloud.
void drawPolygon(const VisuID &id, const std::vector< Eigen::Vector3f > &points, const DrawColor &colorFace, float lineWidth=0, const DrawColor &colorEdge=DEFAULTS.colorPolygonEdge, bool ignoreLengthScale=false)
Draw a polygon.
void drawTriMeshAsPolygons(const VisuID &id, const VirtualRobot::TriMeshModel &trimesh, const DrawColor &colorFace=DEFAULTS.colorPolygonFace, float lineWidth=0, const DrawColor &colorEdge=DEFAULTS.colorPolygonEdge, bool ignoreLengthScale=false)
Draw a TriMeshModel as individual polygons.
void removeCylinder(const VisuID &id)
Remove a cylinder.
void setPoseScaleMillimeters()
Set the pose scale to 1 (good when drawing in millimeters).
void drawSphere(const VisuID &id, const Eigen::Vector3f ¢er, float radius, const DrawColor &color=DEFAULTS.colorSphere, bool ignoreLengthScale=false)
Draw a sphere.
DebugDrawerInterfacePrx getTopic() const
Get the topic.
void drawRobot(const VisuID &id, const std::string &robotFile, const std::string &armarxProject, armarx::DrawStyle drawStyle=armarx::DrawStyle::FullModel)
Draw a robot.
friend std::ostream & operator<<(std::ostream &os, const VisuID &rhs)
Streams a short human-readable description of rhs to os.
void setEnabled(bool enabled)
Set whether drawing is enabled.
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface > DebugDrawerInterfacePrx
void removeSphere(const VisuID &id)
Remove a sphere.
void clearAll(bool sleep=false)
Clear all layers.
Default values for drawing functions.
void removePose(const VisuID &id)
Remove a pose.
void drawCylinderFromTo(const VisuID &id, const Eigen::Vector3f &from, const Eigen::Vector3f &to, float radius, const DrawColor &color=DEFAULTS.colorCylinder, bool ignoreLengthScale=false)
Draw a cylinder from start to end.
This file offers overloads of toIce() and fromIce() functions for STL container types.
static const Defaults DEFAULTS
void drawArrow(const VisuID &id, const Eigen::Vector3f &position, const Eigen::Vector3f &direction, float length, float width, const DrawColor &color=DEFAULTS.colorArrow, bool ignoreLengthScale=false)
Draw an arrow with position (start) and direction.
void removeLineSet(const VisuID &id)
Remove a line set.