Go to the documentation of this file.
7 #include <Eigen/Geometry>
9 #include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
33 class ManagedIceObject;
184 template <
typename Source>
237 const std::string& layer = DEFAULT_LAYER);
260 const std::string& topicNameOverride =
"")
const;
270 const std::string&
getLayer()
const;
272 void setLayer(
const std::string& layer);
300 template <
typename DurationT>
301 void sleepFor(
const DurationT& duration);
304 template <
typename DurationT>
320 void clearLayer(
const std::string& layer,
bool sleep =
false);
330 const Eigen::Vector3f& position,
331 const std::string& text,
334 bool ignoreLengthScale =
false);
339 const Eigen::Vector3f& position,
341 const Eigen::Vector3f& extents,
343 bool ignoreLengthScale =
false);
347 const Eigen::Vector3f& extents,
349 bool ignoreLengthScale =
false);
353 const VirtualRobot::BoundingBox& boundingBox,
355 bool ignoreLengthScale =
false);
359 const VirtualRobot::BoundingBox& boundingBox,
362 bool ignoreLengthScale =
false);
371 const Eigen::Vector3f& position,
373 const Eigen::Vector3f& extents,
376 bool ignoreLengthScale =
false);
381 const Eigen::Vector3f& extents,
384 bool ignoreLengthScale =
false);
388 const VirtualRobot::BoundingBox& boundingBox,
391 bool ignoreLengthScale =
false);
398 bool ignoreLengthScale =
false);
402 const VirtualRobot::BoundingBox& boundingBox,
406 bool ignoreLengthScale =
false);
414 bool ignoreLengthScale =
false);
425 const Eigen::Vector3f&
center,
426 const Eigen::Vector3f& direction,
430 bool ignoreLengthScale =
false);
438 const Eigen::Vector3f&
center,
443 bool ignoreLengthScale =
false);
447 const Eigen::Vector3f&
from,
448 const Eigen::Vector3f& to,
451 bool ignoreLengthScale =
false);
459 const Eigen::Vector3f&
center,
462 bool ignoreLengthScale =
false);
470 const Eigen::Vector3f& position,
471 const Eigen::Vector3f& direction,
475 bool ignoreLengthScale =
false);
479 const Eigen::Vector3f&
from,
480 const Eigen::Vector3f& to,
483 bool ignoreLengthScale =
false);
491 const std::vector<Eigen::Vector3f>& points,
492 const DrawColor& colorFace,
495 bool ignoreLengthScale =
false);
503 const Eigen::Vector3f&
from,
504 const Eigen::Vector3f& to,
507 bool ignoreLengthScale =
false);
515 const DebugDrawerLineSet& lineSet,
516 bool ignoreLengthScale =
false);
523 const std::vector<Eigen::Vector3f>& points,
526 bool ignoreLengthScale =
false);
534 const std::vector<Eigen::Vector3f>& points,
536 const DrawColor& colorA,
537 const DrawColor& colorB,
538 const std::vector<float>& intensitiesB,
539 bool ignoreLengthScale =
false);
552 const Eigen::Vector3f& pos,
554 bool ignoreLengthScale =
false);
560 bool ignoreLengthScale =
false);
563 const Eigen::Vector3f& pos,
566 bool ignoreLengthScale =
false);
584 const std::string& robotFile,
585 const std::string& armarxProject,
586 armarx::DrawStyle drawStyle = armarx::DrawStyle::FullModel);
594 const Eigen::Vector3f& pos,
596 bool ignoreScale =
false);
615 const VirtualRobot::TriMeshModel& triMesh,
616 const DrawColor& color = {.5, .5, .5, 1},
617 bool ignoreLengthScale =
false);
621 const VirtualRobot::TriMeshModel& trimesh,
625 bool ignoreLengthScale =
false);
629 const VirtualRobot::TriMeshModel& trimesh,
634 bool ignoreLengthScale =
false);
638 const VirtualRobot::TriMeshModel& trimesh,
639 const std::vector<DrawColor>& faceColorsInner,
642 bool ignoreLengthScale =
false);
655 template <
class Po
intCloudT>
660 bool ignoreLengthScale =
false);
668 template <
class Po
intCloudT>
672 bool ignoreLengthScale =
false);
680 template <
class Po
intCloudT>
684 bool ignoreLengthScale =
false);
695 template <
class Po
intCloudT,
class ColorFuncT>
698 const ColorFuncT& colorFunc,
700 bool ignoreLengthScale =
false);
706 void drawPointCloud(
const VisuID&
id,
const DebugDrawerPointCloud& pointCloud);
709 void drawPointCloud(
const VisuID&
id,
const DebugDrawerColoredPointCloud& pointCloud);
712 void drawPointCloud(
const VisuID&
id,
const DebugDrawer24BitColoredPointCloud& pointCloud);
727 void drawFloor(
const VisuID&
id = {
"floor"},
728 const Eigen::Vector3f& at = Eigen::Vector3f::Zero(),
729 const Eigen::Vector3f&
up = Eigen::Vector3f::UnitZ(),
732 bool ignoreLengthScale =
false);
739 operator bool()
const;
756 static Eigen::Vector3f
rgb2hsv(
const Eigen::Vector3f& rgb);
763 static Eigen::Vector3f
hsv2rgb(
const Eigen::Vector3f& hsv);
777 template <
class ColorT>
779 toDrawColor(
const ColorT& color,
float alpha = 1,
bool byteToFloat =
false);
790 const std::string& layer(
const std::string& passedLayer)
const;
793 const std::string& layer(
const VisuID&
id)
const;
797 float lengthScale(
bool ignore =
false)
const;
800 static float scaled(
float scale,
float value);
802 static Vector3BasePtr scaled(
float scale,
const Eigen::Vector3f& vector);
808 template <
class ScaledT>
809 static ScaledT scaledT(
float scale,
const Eigen::Vector3f& vector);
812 template <
class XYZT>
813 static void scaleXYZ(
float scale, XYZT& xyz);
818 static const std::string TOPIC_NAME;
820 static const std::string DEFAULT_LAYER;
827 bool _enabled =
true;
830 std::string _layer = DEFAULT_LAYER;
833 float _lengthScale = 1;
836 float _poseScale = 1;
839 std::chrono::milliseconds _shortSleepDuration{100};
842 template <
typename DurationT>
848 std::this_thread::sleep_for(duration);
852 template <
typename DurationT>
856 this->_shortSleepDuration = std::chrono::duration_cast<std::chrono::milliseconds>(duration);
859 template <
class ColorT>
863 const float scale = byteToFloat ? (1 / 255.f) : 1;
864 return {color.r * scale, color.g * scale, color.b * scale, alpha};
867 template <
class Po
intCloudT>
871 const DrawColor& color,
873 bool ignoreLengthScale)
876 id, pointCloud, [&color](
const auto&) {
return color; }, pointSize, ignoreLengthScale);
879 template <
class Po
intCloudT>
884 bool ignoreLengthScale)
894 template <
class Po
intCloudT>
899 bool ignoreLengthScale)
909 template <
class Po
intCloudT,
class ColorFuncT>
913 const ColorFuncT& colorFn,
915 bool ignoreLengthScale)
922 const float lf = ignoreLengthScale ? 1.0 : _lengthScale;
924 DebugDrawerColoredPointCloud dd;
925 dd.points.reserve(pointCloud.size());
927 dd.pointSize = pointSize;
929 for (
const auto& p : pointCloud)
932 DebugDrawerColoredPointCloudElement{lf * p.x, lf * p.y, lf * p.z, colorFn(p)});
938 template <
class ScaledT>
940 DebugDrawerTopic::scaledT(
float scale,
const Eigen::Vector3f& vector)
942 auto scaled = vector * scale;
943 return {scaled.x(), scaled.y(), scaled.z()};
946 template <
class XYZT>
948 DebugDrawerTopic::scaleXYZ(
float scale, XYZT& xyz)
state::Type up(state::Type previous)
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 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 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.
MatrixXX< 4, 4, float > Matrix4f
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 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.
state::Type from(Eigen::Vector3f targetPosition)
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.
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.
state::Type center(state::Type previous)
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.