DebugDrawerTopic.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <chrono>
4 #include <functional>
5 #include <thread>
6 
7 #include <Eigen/Geometry>
8 
9 #include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
10 
11 namespace Eigen
12 {
13  /**
14  * @brief A 3x2 matrix.
15  *
16  * Useful to represent axis-aligned bounding boxes (AABBs). When used as a
17  * AABB, column 0 contains the minimal x, y, z values and column 1 the
18  * maximal x, y, z values.
19  * Accordingly, the rows each contain the limits in x, y, z direction.
20  */
22 }
23 
24 namespace VirtualRobot
25 {
26  class TriMeshModel;
27  class BoundingBox;
28 }
29 
30 namespace armarx
31 {
32  // forward declaration
33  class ManagedIceObject;
34 
35 
36  /**
37  * @brief The `DebugDrawerTopic` wraps a `DebugDrawerInterfacePrx` and
38  * provides a more useful interface than the Ice interface.
39  *
40  * The methods by `DebugDrawerTopic` take "raw" types, such as Eigen or PCL
41  * types, and take care of conversion to Ice variants or data structures.
42  * In addition, this class provides useful overloads for different use cases.
43  *
44  * Drawing is enabled if the internal topic proxy is set and an optional
45  * enabled flag is set (true by default). All methods check whether drawing
46  * is enabled and do nothing if drawing is disabled. To disable
47  * visualization by this class completely, use `setEnabled(true/false)` or
48  * just do not set the topic. To check whether visualization is enabled,
49  * use `enabled()` or just convert `*this` to bool:
50  * @code
51  * DebugDrawerTopic debugDrawer;
52  * if (debugDrawer) // Equivalent: if (debugDrawer.enabled())
53  * {
54  * // Do stuff if visualization is enabled.
55  * }
56  * @endcode
57  *
58  * The `DebugDrawerTopic` allows to set a layer on constructor or via
59  * `setLayer()`. This layer will be used if none is passed to a drawing
60  * method. If no layer is passed or set, `DebugDrawerTopic::DEFAULT_LAYER`
61  * is used.
62  *
63  *
64  * @par Initialisation by Offering and Getting Topic
65  *
66  * A `DebugDrawerTopic` needs an underlying `DebugDrawerInterfacePrx` topic proxy.
67  * This proxy can be passed on construction or set via `setTopic()`.
68  * In a component (or any other `ManagedIceObject`), `DebugDrawerTopic`
69  * provides convenience functions to register and fetch the topics.
70  *
71  * In `onInitComponent()` (or equivalent method), call:
72  * @code
73  * debugDrawer.offeringTopic(*this);
74  * @endcode
75  * In `onConnectComponent()` (or equivalent), call:
76  * @code
77  * debugDrawer.getTopic(*this);
78  * @endcode
79  * where `*this` is a `ManagedIceObject`.
80  *
81  * This will call `this->offeringTopic("...")` and `this->getTopic("...")`
82  * with the correct topic name (`DebugDrawerTopic::TOPIC_NAME`) and
83  * enable the `DebugDrawerTopic`.
84  *
85  *
86  * @par Scaling
87  *
88  * `DebugDrawerTopic` supports length scaling and pose scaling.
89  *
90  * If a length scale is set, all visualizations will be scaled up or down
91  * by this value. This scaling affects positions, sizes / extents, and
92  * distances / lengths. This is useful when drawing quantities of
93  * different sources using different scalings (such as meters vs
94  * millimeters).
95  * Length scale can be set via `setPoseScale()` or the short hands
96  * `setPoseScaleMetersToMillimeters()` and `setPoseScaleMillimetersToMeters()`.
97  *
98  * All applicable methods offer a final argument called
99  * `ignoreLengthScaling` (false by default, expect for robots, see below),
100  * which can be set to true to ignore the set length scale for this
101  * method call.
102  *
103  * @note Robots are always drawn in their native size (the
104  * `DebugDrawerInterface` offers no size scaling for robots).
105  * (That is, robots are drawn in millimeters most of the time.)
106  *
107  *
108  * In addition, this class allows to set a pose scale, which will be used
109  * for all drawn poses (if no other value is passed to drawPose()).
110  * This is useful when working with geometries scaled in meters, in which
111  * case a pose scale of 0.001 can be used.
112  *
113  *
114  * @par Argument Pattern
115  *
116  * All drawing methods take a `VisuID` as first argument, which specifies
117  * the name of the visualization and the layer to draw on.
118  * There are different ways to specify the first argument.
119  * For example, to specify a only the name for a pose, pass just the name:
120  *
121  * @code
122  * Eigen::Matrix4f pose = Eigen::Matrix4f::Identity();
123  * std::string name = "pose";
124  * debugDrawer.drawPose(name, pose);
125  * debugDrawer.drawPose({name}, pose); // equivalent to the line above
126  * @endcode
127  *
128  * This will draw a pose on the preset layer (i.e. the layer passed to the
129  * constructor or set via `setLayer()`, or "debug" by default).
130  * To specify both name and layer of a single visualization, pass both in
131  * an initializer list:
132  *
133  * @code
134  * Eigen::Matrix4f pose = Eigen::Matrix4f::Identity();
135  * std::string layer = "layer";
136  * std::string name = "pose";
137  * debugDrawer.drawPose({layer, name}, pose);
138  * @endcode
139  *
140  *
141  * After the VisuID, usually the essential geometric parameters follow,
142  * (e.g. position, size, length, point list, ...), depending on the type
143  * of visualization.
144  * Finally, decorative parameters like colors and width can be passed.
145  * Most of the time, they have sensible default values and can be omitted
146  * for quick-and-dirty drawing.
147  *
148  * (Added methods should adhere to this pattern.)
149  *
150  * @see `DebugDrawerTopic::VisuID`
151  */
153  {
154  public:
155 
156 
157  /**
158  * @brief A visualisation ID.
159  *
160  * This constructor can be called in the following ways
161  * (with `draw(const VisuID& id, ...)` being any drawing method):
162  *
163  * @code
164  * std::string name = "pose";
165  * std::string layer = "layer";
166  * draw(name, ...); // just the name, implicit call
167  * draw({name}, ...); // just the name, call with initializer list
168  * draw({layer, name}, ...); // layer and name, with initializer list
169  * @endcode
170  *
171  * (And of course by an explicit call if you want to be really verbose.)
172  * Not passing a layer will cause DebugDrawerTopic to use the
173  * preset layer.
174  */
175  struct VisuID
176  {
177  public:
178 
179  /// Empty constructor.
180  VisuID();
181 
182  /// Construct a VisuID with given name (for drawing to the preset layer).
183  VisuID(const std::string& name);
184  /// Construct a VisuID with given name and layer.
185  VisuID(const std::string& layer, const std::string& name);
186 
187  /// Construct a VisuID from a non-std::string source (e.g. char[]).
188  template <typename Source>
189  VisuID(const Source& name) : VisuID(std::string(name))
190  {}
191 
192 
193  /// Get a `VisuID` with the given name and same layer as `*this.
194  VisuID withName(const std::string& name) const;
195 
196  /// Streams a short human-readable description of `rhs` to `os`.
197  friend std::ostream& operator<<(std::ostream& os, const VisuID& rhs);
198 
199  public:
200 
201  std::string layer = ""; ///< The layer name (empty by default).
202  std::string name = ""; ///< The visu name (empty by default).
203  };
204 
205 
206  /// Default values for drawing functions.
207  struct Defaults
208  {
209  DrawColor colorText { 0, 0, 0, 1 };
210 
211  DrawColor colorArrow { 1, .5, 0, 1 };
212  DrawColor colorBox { 1, 0, 0, 1 };
213  DrawColor colorCylinder { 0, 1, 0, 1 };
214  DrawColor colorLine { .5, 0, 0, 1 };
215  DrawColor colorSphere { 0, 0, 1, 1 };
216 
217  DrawColor colorPolygonFace { 0, 1, 1, 1 };
218  DrawColor colorPolygonEdge { .75, .75, .75, 1 };
219 
220  DrawColor colorFloor { .1f, .1f, .1f, 1 };
221 
222  DrawColor colorPointCloud { .5, .5, .5, 1. };
223 
224  // Default value of DebugDrawerColoredPointCloud etc.
225  float pointCloudPointSize = 3.0f;
226 
227  float lineWidth = 2;
228 
229  DrawColor boxEdgesColor { 0, 1, 1, 1 };
230  float boxEdgesWidth = 2;
231  };
232  static const Defaults DEFAULTS;
233 
234 
235  public:
236 
237  // CONSTRUCTION & SETUP
238 
239  /// Construct without topic, and optional layer.
240  DebugDrawerTopic(const std::string& layer = DEFAULT_LAYER);
241  /// Construct with given topic and optional layer.
242  DebugDrawerTopic(const DebugDrawerInterfacePrx& topic, const std::string& layer = DEFAULT_LAYER);
243 
244 
245  /// Set the topic.
246  void setTopic(const DebugDrawerInterfacePrx& topic);
247  /// Get the topic.
249 
250  /**
251  * @brief Set whether drawing is enabled.
252  * Visualization is only truly enabled if the topic is set.
253  */
254  void setEnabled(bool enabled);
255  /// Indicate whether visualization is enabled, i.e. a topic is set and enabled flag is set.
256  bool enabled() const;
257 
258  /**
259  * @brief Call offeringTopic([topicName]) on the given component.
260  * @param component The component (`*this` when called from a component).
261  * @param topicNameOverride Optional override for the topic name. If left empty (default),
262  * uses the standard topic name (see `TOPIC_NAME`).
263  */
264  void offeringTopic(ManagedIceObject& component, const std::string& topicNameOverride = "") const;
265  /**
266  * @brief Get the topic by calling getTopic([topicName]) on the given component.
267  * @param component The component (`*this` when called from a component).
268  * @param topicNameOverride Optional override for the topic name. If left empty (default),
269  * uses the standard topic name (see `TOPIC_NAME`).
270  */
271  void getTopic(ManagedIceObject& component, const std::string& topicNameOverride = "");
272 
273  /// Get the default layer (used if no layer is passed to a method).
274  const std::string& getLayer() const;
275  /// Set the default layer (used if no layer is passed to a method).
276  void setLayer(const std::string& layer);
277 
278  /// Get the scaling for positions, lengths and distances.
279  float getLengthScale() const;
280  /// Set the scale for positions, lengths and distances.
281  void setLengthScale(float scale);
282  /// Set the scale for positions, lengths and distances to 1000.
284  /// Set the scale for positions, lengths and distances to 0.001.
286 
287  /// Get the scale for pose visualization.
288  float getPoseScale() const;
289  /// Set the scale for pose visualization.
290  /// This value will be used for all successive calls to drawPose().
291  void setPoseScale(float scale);
292  /// Set the pose scale to 0.001 (good when drawing in meters).
293  void setPoseScaleMeters();
294  /// Set the pose scale to 1 (good when drawing in millimeters).
296 
297 
298 
299  // SLEEP
300 
301  /// Sleep for the `shortSleepDuration`. Useful after clearing.
302  void shortSleep();
303 
304  /// If enabled, sleep for the given duration (e.g. a chrono duration).
305  template <typename DurationT>
306  void sleepFor(const DurationT& duration);
307 
308  /// Set the duration for "short sleeps".
309  template <typename DurationT>
310  void setShortSleepDuration(const DurationT& duration);
311 
312 
313  // CLEAR
314 
315  /// Clear all layers.
316  /// @param sleep If true, do a short sleep clearing.
317  void clearAll(bool sleep = false);
318 
319  /// Clear the (set default) layer.
320  /// @param sleep If true, do a short sleep clearing.
321  void clearLayer(bool sleep = false);
322 
323  /// Clear the given layer.
324  /// @param sleep If true, do a short sleep clearing.
325  void clearLayer(const std::string& layer, bool sleep = false);
326 
327 
328  // PRIMITIVES
329 
330  /**
331  * @brief Draw text at the specified position.
332  * @param size the text size (in pixels, not affected by length scaling)
333  */
334  void drawText(const VisuID& id, const Eigen::Vector3f& position, const std::string& text,
335  int size = 10, const DrawColor color = DEFAULTS.colorText,
336  bool ignoreLengthScale = false);
337 
338 
339  /// Draw a box.
340  void drawBox(const VisuID& id, const Eigen::Vector3f& position, const Eigen::Quaternionf& orientation,
341  const Eigen::Vector3f& extents, const DrawColor& color = DEFAULTS.colorBox,
342  bool ignoreLengthScale = false);
343  /// Draw a box.
344  void drawBox(const VisuID& id, const Eigen::Matrix4f& pose, const Eigen::Vector3f& extents,
345  const DrawColor& color = DEFAULTS.colorBox,
346  bool ignoreLengthScale = false);
347 
348  /// Draw an axis aligned bounding box.
349  void drawBox(const VisuID& id,
350  const VirtualRobot::BoundingBox& boundingBox,
351  const DrawColor& color = DEFAULTS.colorBox,
352  bool ignoreLengthScale = false);
353 
354  /// Draw a locally axis aligned bounding box, transformed by the given pose.
355  void drawBox(const VisuID& id,
356  const VirtualRobot::BoundingBox& boundingBox, const Eigen::Matrix4f& pose,
357  const DrawColor& color = DEFAULTS.colorBox,
358  bool ignoreLengthScale = false);
359 
360 
361  /// Remove a box.
362  void removeBox(const VisuID& id);
363 
364 
365  /// Draw box edges (as a line set).
366  void drawBoxEdges(const VisuID& id,
367  const Eigen::Vector3f& position, const Eigen::Quaternionf& orientation,
368  const Eigen::Vector3f& extents,
369  float width = DEFAULTS.boxEdgesWidth, const DrawColor& color = DEFAULTS.boxEdgesColor,
370  bool ignoreLengthScale = false);
371 
372  /// Draw box edges (as a line set).
373  void drawBoxEdges(const VisuID& id,
374  const Eigen::Matrix4f& pose, const Eigen::Vector3f& extents,
375  float width = DEFAULTS.boxEdgesWidth, const DrawColor& color = DEFAULTS.boxEdgesColor,
376  bool ignoreLengthScale = false);
377 
378  /// Draw edges of an axis aligned bounding box (as a line set).
379  void drawBoxEdges(const VisuID& id,
380  const VirtualRobot::BoundingBox& boundingBox,
381  float width = DEFAULTS.boxEdgesWidth, const DrawColor& color = DEFAULTS.boxEdgesColor,
382  bool ignoreLengthScale = false);
383 
384  /// Draw edges of an axis aligned bounding box (as a line set).
385  void drawBoxEdges(const VisuID& id,
386  const Eigen::Matrix32f& aabb,
387  float width = DEFAULTS.boxEdgesWidth, const DrawColor& color = DEFAULTS.boxEdgesColor,
388  bool ignoreLengthScale = false);
389 
390  /// Draw edges of a locally axis-aligned bounding box, transformed by the given pose (as a line set).
391  void drawBoxEdges(const VisuID& id,
392  const VirtualRobot::BoundingBox& boundingBox, const Eigen::Matrix4f& pose,
393  float width = DEFAULTS.boxEdgesWidth, const DrawColor& color = DEFAULTS.boxEdgesColor,
394  bool ignoreLengthScale = false);
395 
396  /// Draw edges of a locally axis-aligned bounding box, transformed by the given pose (as a line set).
397  void drawBoxEdges(const VisuID& id,
398  const Eigen::Matrix32f& aabb, const Eigen::Matrix4f& pose,
399  float width = DEFAULTS.boxEdgesWidth, const DrawColor& color = DEFAULTS.boxEdgesColor,
400  bool ignoreLengthScale = false);
401 
402  /// Remove box edges (as a line set).
403  void removeboxEdges(const VisuID& id);
404 
405 
406  /**
407  * @brief Draw a cylinder with center and direction.
408  * @param length The full length (not half-length).
409  */
410  void drawCylinder(
411  const VisuID& id,
412  const Eigen::Vector3f& center, const Eigen::Vector3f& direction, float length, float radius,
413  const DrawColor& color = DEFAULTS.colorCylinder,
414  bool ignoreLengthScale = false);
415 
416  /**
417  * @brief Draw a cylinder with center and orientation.
418  * An identity orientation represents a cylinder with an axis aligned to the Y-axis.
419  * @param length The full length (not half-length).
420  */
421  void drawCylinder(
422  const VisuID& id,
423  const Eigen::Vector3f& center, const Eigen::Quaternionf& orientation, float length, float radius,
424  const DrawColor& color = DEFAULTS.colorCylinder,
425  bool ignoreLengthScale = false);
426 
427  /// Draw a cylinder from start to end.
428  void drawCylinderFromTo(
429  const VisuID& id,
430  const Eigen::Vector3f& from, const Eigen::Vector3f& to, float radius,
431  const DrawColor& color = DEFAULTS.colorCylinder,
432  bool ignoreLengthScale = false);
433 
434  /// Remove a cylinder.
435  void removeCylinder(const VisuID& id);
436 
437 
438  /// Draw a sphere.
439  void drawSphere(
440  const VisuID& id,
441  const Eigen::Vector3f& center, float radius,
442  const DrawColor& color = DEFAULTS.colorSphere,
443  bool ignoreLengthScale = false);
444 
445  /// Remove a sphere.
446  void removeSphere(const VisuID& id);
447 
448 
449  /// Draw an arrow with position (start) and direction.
450  void drawArrow(
451  const VisuID& id,
452  const Eigen::Vector3f& position, const Eigen::Vector3f& direction, float length,
453  float width, const DrawColor& color = DEFAULTS.colorArrow,
454  bool ignoreLengthScale = false);
455 
456  /// Draw an arrow with start and end.
457  void drawArrowFromTo(
458  const VisuID& id,
459  const Eigen::Vector3f& from, const Eigen::Vector3f& to,
460  float width, const DrawColor& color = DEFAULTS.colorArrow,
461  bool ignoreLengthScale = false);
462 
463  /// Remove an arrow.
464  void removeArrow(const VisuID& id);
465 
466 
467  /// Draw a polygon.
468  void drawPolygon(
469  const VisuID& id,
470  const std::vector<Eigen::Vector3f>& points,
471  const DrawColor& colorFace,
472  float lineWidth = 0, const DrawColor& colorEdge = DEFAULTS.colorPolygonEdge,
473  bool ignoreLengthScale = false);
474 
475  /// Remove a polygon.
476  void removePolygon(const VisuID& id);
477 
478 
479  /// Draw a line from start to end.
480  void drawLine(
481  const VisuID& id,
482  const Eigen::Vector3f& from, const Eigen::Vector3f& to,
483  float width, const DrawColor& color = DEFAULTS.colorLine,
484  bool ignoreLengthScale = false);
485 
486  /// Remove a line.
487  void removeLine(const VisuID& id);
488 
489 
490  /// Draw a line set.
491  void drawLineSet(
492  const VisuID& id,
493  const DebugDrawerLineSet& lineSet,
494  bool ignoreLengthScale = false);
495 
496  /**
497  * @brief Draw a set of lines with constant color.
498  * @param points List of start and end points [ s1, e1, s2, e2, ..., sn, en ].
499  */
500  void drawLineSet(
501  const VisuID& id,
502  const std::vector<Eigen::Vector3f>& points,
503  float width, const DrawColor& color = DEFAULTS.colorLine,
504  bool ignoreLengthScale = false);
505 
506  /**
507  * @brief Draw a set of lines with constant color.
508  * @param points List of start and end points [ s1, e1, s2, e2, ..., sn, en ].
509  * @param colors List of line colors [ c1, c2, ..., cn ].
510  */
511  void drawLineSet(
512  const VisuID& id,
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);
517 
518  /// Remove a line set.
519  void removeLineSet(const VisuID& id);
520 
521 
522  // POSE
523 
524  /// Draw a pose (with the preset scale).
525  void drawPose(const VisuID& id, const Eigen::Matrix4f& pose,
526  bool ignoreLengthScale = false);
527  /// Draw a pose (with the preset scale).
528  void drawPose(const VisuID& id, const Eigen::Vector3f& pos, const Eigen::Quaternionf& ori,
529  bool ignoreLengthScale = false);
530 
531  /// Draw a pose with the given scale.
532  void drawPose(const VisuID& id, const Eigen::Matrix4f& pose, float scale,
533  bool ignoreLengthScale = false);
534  /// Draw a pose with the given scale.
535  void drawPose(const VisuID& id, const Eigen::Vector3f& pos, const Eigen::Quaternionf& ori,
536  float scale,
537  bool ignoreLengthScale = false);
538 
539  /// Remove a pose.
540  void removePose(const VisuID& id);
541 
542 
543  // ROBOT
544 
545  /**
546  * @brief Draw a robot.
547  * Afterwards, `updateRobot*()` methods can be used with the same VisuID.
548  *
549  * @param robotFile The robot file. Either an absolute path, or a path
550  * relative to the data directory of the ArmarX project specified by `armarxProject`.
551  * @param armarxProject The name of the ArmarX project keeping the robot model.
552  * @param drawStyle The draw style (full or collision model).
553  */
554  void drawRobot(
555  const VisuID& id,
556  const std::string& robotFile, const std::string& armarxProject,
557  armarx::DrawStyle drawStyle = armarx::DrawStyle::FullModel);
558 
559  /// Update / set the robot pose.
560  void updateRobotPose(
561  const VisuID& id,
562  const Eigen::Matrix4f& pose,
563  bool ignoreScale = false);
564 
565  /// Update / set the robot pose.
566  void updateRobotPose(
567  const VisuID& id,
568  const Eigen::Vector3f& pos, const Eigen::Quaternionf& ori,
569  bool ignoreScale = false);
570 
571  /// Update / set the robot configuration (joint angles).
572  void updateRobotConfig(
573  const VisuID& id,
574  const std::map<std::string, float>& config);
575 
576  /// Update / set the robot color.
577  void updateRobotColor(const VisuID& id, const DrawColor& color);
578  /// Update / set the color of a robot node.
580  const VisuID& id, const std::string& nodeName, const DrawColor& color);
581 
582  /// Remove a robot visualization.
583  void removeRobot(const VisuID& id);
584 
585 
586  // TRI MESH
587 
588  /// Draw a TriMeshModel as DebugDrawerTriMesh.
589  void drawTriMesh(
590  const VisuID& id,
591  const VirtualRobot::TriMeshModel& triMesh,
592  const DrawColor& color = {.5, .5, .5, 1},
593  bool ignoreLengthScale = false);
594 
595  /// Draw a TriMeshModel as individual polygons.
597  const VisuID& id,
598  const VirtualRobot::TriMeshModel& trimesh,
599  const DrawColor& colorFace = DEFAULTS.colorPolygonFace,
600  float lineWidth = 0, const DrawColor& colorEdge = DEFAULTS.colorPolygonEdge,
601  bool ignoreLengthScale = false);
602 
603  /// Draw a TriMeshModel as individual polygons, transformed by the given pose.
605  const VisuID& id,
606  const VirtualRobot::TriMeshModel& trimesh, const Eigen::Matrix4f& pose,
607  const DrawColor& colorFace = DEFAULTS.colorPolygonFace,
608  float lineWidth = 0, const DrawColor& colorEdge = DEFAULTS.colorPolygonEdge,
609  bool ignoreLengthScale = false);
610 
611  /// Draw a TriMeshModel as individual polygons with individual face colors.
613  const VisuID& id,
614  const VirtualRobot::TriMeshModel& trimesh,
615  const std::vector<DrawColor>& faceColorsInner,
616  float lineWidth = 0, const DrawColor& colorEdge = DEFAULTS.colorPolygonEdge,
617  bool ignoreLengthScale = false);
618 
619 
620  // POINT CLOUD
621  /* (By templating these functions, we can make them usable for PCL
622  * point clouds without a dependency on PCL.)
623  */
624 
625  /**
626  * @brief Draw a unicolored point cloud.
627  *
628  * `pointCloud` must be iterable and its elements must provide members `x, y, z`.
629  */
630  template <class PointCloudT>
631  void drawPointCloud(
632  const VisuID& id,
633  const PointCloudT& pointCloud,
634  const DrawColor& color = DEFAULTS.colorPointCloud,
635  float pointSize = DEFAULTS.pointCloudPointSize,
636  bool ignoreLengthScale = false);
637 
638  /**
639  * @brief Draw a colored point cloud with RGBA information.
640  *
641  * `pointCloud` must be iterable and its elements must provide
642  * members `x, y, z, r, g, b, a`.
643  */
644  template <class PointCloudT>
645  void drawPointCloudRGBA(
646  const VisuID& id,
647  const PointCloudT& pointCloud,
648  float pointSize = DEFAULTS.pointCloudPointSize,
649  bool ignoreLengthScale = false);
650 
651  /**
652  * @brief Draw a colored point cloud with colors according to labels.
653  *
654  * `pointCloud` must be iterable and its elements must provide
655  * members `x, y, z, label`.
656  */
657  template <class PointCloudT>
659  const VisuID& id,
660  const PointCloudT& pointCloud,
661  float pointSize = DEFAULTS.pointCloudPointSize,
662  bool ignoreLengthScale = false);
663 
664  /**
665  * @brief Draw a colored point cloud with custom colors.
666  *
667  * `pointCloud` must be iterable and its elements must provide
668  * members `x, y, z`.
669  * The color of a point is specified by `colorFunc`, which must be
670  * a callable taking an element of `pointCloud` and returning its
671  * color as `armarx::DrawColor`.
672  */
673  template <class PointCloudT, class ColorFuncT>
674  void drawPointCloud(
675  const VisuID& id,
676  const PointCloudT& pointCloud,
677  const ColorFuncT& colorFunc,
678  float pointSize = DEFAULTS.pointCloudPointSize,
679  bool ignoreLengthScale = false);
680 
681 
682  // Debug Drawer Point Cloud Types
683 
684  /// Draw a non-colored point cloud.
685  void drawPointCloud(const VisuID& id, const DebugDrawerPointCloud& pointCloud);
686 
687  /// Draw a colored point cloud.
688  void drawPointCloud(const VisuID& id, const DebugDrawerColoredPointCloud& pointCloud);
689 
690  /// Draw a 24 bit colored point cloud.
691  void drawPointCloud(const VisuID& id, const DebugDrawer24BitColoredPointCloud& pointCloud);
692 
693 
694  /// Forces the "deletion" of a point cloud by drawing an empty one.
695  void clearColoredPointCloud(const VisuID& id);
696 
697 
698  // CUSTOM
699 
700  /**
701  * @brief Draw a quad representing the floor.
702  * @param at the quad'S center
703  * @param up the up direction (normal of the floor plane)
704  * @param size the quad's edge length
705  */
706  void drawFloor(
707  const VisuID& id = { "floor" },
708  const Eigen::Vector3f& at = Eigen::Vector3f::Zero(),
709  const Eigen::Vector3f& up = Eigen::Vector3f::UnitZ(),
710  float size = 5, const DrawColor& color = DEFAULTS.colorFloor,
711  bool ignoreLengthScale = false);
712 
713 
714  // OPERATORS
715 
716  /// Indicate whether visualization is enabled.
717  /// @see `enabled()`
718  operator bool() const;
719 
720  /// Conversion operator to DebugDrawerInterfacePrx.
721  operator DebugDrawerInterfacePrx& ();
722  operator const DebugDrawerInterfacePrx& () const;
723 
724  /// Pointer member access operator to access the raw debug drawer proxy.
726  const DebugDrawerInterfacePrx& operator->() const;
727 
728 
729  public: // STATIC
730 
731  /**
732  * @brief Convert a RGB color to HSV.
733  * @param rgb RGB color as [r, g, b] with r, g, b in [0, 1].
734  * @return HSV color as [h, s, v] with h in [0 deg, 360 deg] and s, v in [0, 1].
735  */
736  static Eigen::Vector3f rgb2hsv(const Eigen::Vector3f& rgb);
737 
738  /**
739  * @brief Convert a HSV color RGB.
740  * @param HSV color as [h, s, v] with h in [0 deg, 360 deg] and s, v in [0, 1].
741  * @return RGB color as [r, g, b] with r, g, b in [0, 1].
742  */
743  static Eigen::Vector3f hsv2rgb(const Eigen::Vector3f& hsv);
744 
745 
746  /**
747  * @brief Construct a DrawColor from the given color type.
748  *
749  * The used color type must have members named `r`, `g` and `b`.
750  * Applicable types include:
751  * - pcl::RGB (byteToFloat = true)
752  * - armarx::DrawColor (useful to get a color with a different alpha)
753  *
754  * @param alpha the alpha (default: 1)
755  * @param byteToFloat If true, scale from range [0, 255] to [0, 1]
756  */
757  template <class ColorT>
758  static DrawColor toDrawColor(const ColorT& color, float alpha = 1, bool byteToFloat = false);
759 
760 
761  /// Get a color from the Glasbey look-up-table.
762  static DrawColor getGlasbeyLUTColor(int id, float alpha = 1.f);
763  static DrawColor getGlasbeyLUTColor(uint32_t id, float alpha = 1.f);
764  static DrawColor getGlasbeyLUTColor(std::size_t id, float alpha = 1.f);
765 
766 
767  private:
768 
769  /// Get the layer to draw on. (passedLayer if not empty, _layer otherwise).
770  const std::string& layer(const std::string& passedLayer) const;
771 
772  /// Get the layer to draw on. (id.layer if not empty, _layer otherwise).
773  const std::string& layer(const VisuID& id) const;
774 
775 
776  /// Return _lengthScale if ignore is false (default), 1 otherwise.
777  float lengthScale(bool ignore = false) const;
778 
779  /// Scale the value.
780  static float scaled(float scale, float value);
781  /// Scale the given vector and return it as Vector3 pointer.
782  static Vector3BasePtr scaled(float scale, const Eigen::Vector3f& vector);
783  /// Scale the translation of the given pose and return it as Pose pointer.
784  static PoseBasePtr scaled(float scale, const Eigen::Matrix4f& pose);
785 
786  /// Scale the given vector and return it as `ScaledT`.
787  /// The constructor of `ScaledT` must take the x, y and z coordinates.
788  template <class ScaledT>
789  static ScaledT scaledT(float scale, const Eigen::Vector3f& vector);
790 
791  /// Scale a value with .x, .y and .z attributes in-place.
792  template <class XYZT>
793  static void scaleXYZ(float scale, XYZT& xyz);
794 
795 
796  private:
797 
798  /// The name of the debug drawer topic.
799  static const std::string TOPIC_NAME;
800  /// The default layer ("debug").
801  static const std::string DEFAULT_LAYER;
802 
803 
804  /// The debug drawer topic.
805  DebugDrawerInterfacePrx topic = nullptr;
806 
807  /// Whether drawing is enabled. (In comination with `topic`.
808  bool _enabled = true;
809 
810  /// The default layer (used if none is passed to the method).
811  std::string _layer = DEFAULT_LAYER;
812 
813  /// Scaling for positions, lengths and distances.
814  float _lengthScale = 1;
815 
816  /// Scaling for pose visualization (1 is good when drawing in millimeters).
817  float _poseScale = 1;
818 
819  /// The duration for shortSleep().
820  std::chrono::milliseconds _shortSleepDuration { 100 };
821 
822  };
823 
824 
825  template <typename DurationT>
826  void DebugDrawerTopic::sleepFor(const DurationT& duration)
827  {
828  if (enabled())
829  {
830  std::this_thread::sleep_for(duration);
831  }
832  }
833 
834  template <typename DurationT>
835  void DebugDrawerTopic::setShortSleepDuration(const DurationT& duration)
836  {
837  this->_shortSleepDuration = std::chrono::duration_cast<std::chrono::milliseconds>(duration);
838  }
839 
840  template <class ColorT>
841  DrawColor DebugDrawerTopic::toDrawColor(const ColorT& color, float alpha, bool byteToFloat)
842  {
843  const float scale = byteToFloat ? (1 / 255.f) : 1;
844  return { color.r * scale, color.g * scale, color.b * scale, alpha };
845  }
846 
847 
848  template <class PointCloudT>
850  const VisuID& id,
851  const PointCloudT& pointCloud,
852  const DrawColor& color,
853  float pointSize,
854  bool ignoreLengthScale)
855  {
856  drawPointCloud(id, pointCloud, [&color](const auto&)
857  {
858  return color;
859  },
860  pointSize, ignoreLengthScale);
861  }
862 
863  template<class PointCloudT>
865  const VisuID& id,
866  const PointCloudT& pointCloud,
867  float pointSize,
868  bool ignoreLengthScale)
869  {
870  drawPointCloud(id, pointCloud, [](const auto & p)
871  {
872  return toDrawColor(p, p.a);
873  },
874  pointSize, ignoreLengthScale);
875  }
876 
877  template <class PointCloudT>
879  const VisuID& id,
880  const PointCloudT& pointCloud,
881  float pointSize,
882  bool ignoreLengthScale)
883  {
884  drawPointCloud(id, pointCloud, [](const auto & p)
885  {
886  return getGlasbeyLUTColor(p.label);
887  },
888  pointSize, ignoreLengthScale);
889  }
890 
891  template <class PointCloudT, class ColorFuncT>
893  const VisuID& id,
894  const PointCloudT& pointCloud,
895  const ColorFuncT& colorFn,
896  float pointSize,
897  bool ignoreLengthScale)
898  {
899  if (!enabled())
900  {
901  return;
902  }
903 
904  const float lf = ignoreLengthScale ? 1.0 : _lengthScale;
905 
906  DebugDrawerColoredPointCloud dd;
907  dd.points.reserve(pointCloud.size());
908 
909  dd.pointSize = pointSize;
910 
911  for (const auto& p : pointCloud)
912  {
913  dd.points.push_back(DebugDrawerColoredPointCloudElement
914  {
915  lf * p.x, lf * p.y, lf * p.z, colorFn(p)
916  });
917  }
918 
919  drawPointCloud(id, dd);
920  }
921 
922 
923  template <class ScaledT>
924  ScaledT DebugDrawerTopic::scaledT(float scale, const Eigen::Vector3f& vector)
925  {
926  auto scaled = vector * scale;
927  return { scaled.x(), scaled.y(), scaled.z() };
928  }
929 
930  template <class XYZT>
931  void DebugDrawerTopic::scaleXYZ(float scale, XYZT& xyz)
932  {
933  xyz.x *= scale;
934  xyz.y *= scale;
935  xyz.z *= scale;
936  }
937 
938 }
armarx::DebugDrawerTopic::Defaults::colorFloor
DrawColor colorFloor
Definition: DebugDrawerTopic.h:220
armarx::DebugDrawerTopic::setTopic
void setTopic(const DebugDrawerInterfacePrx &topic)
Set the topic.
Definition: DebugDrawerTopic.cpp:53
armarx::DebugDrawerTopic::Defaults::colorBox
DrawColor colorBox
Definition: DebugDrawerTopic.h:212
armarx::DebugDrawerTopic::sleepFor
void sleepFor(const DurationT &duration)
If enabled, sleep for the given duration (e.g. a chrono duration).
Definition: DebugDrawerTopic.h:826
Eigen
Definition: Elements.h:36
armarx::DebugDrawerTopic::offeringTopic
void offeringTopic(ManagedIceObject &component, const std::string &topicNameOverride="") const
Call offeringTopic([topicName]) on the given component.
Definition: DebugDrawerTopic.cpp:73
armarx::DebugDrawerTopic::Defaults::lineWidth
float lineWidth
Definition: DebugDrawerTopic.h:227
armarx::DebugDrawerTopic::Defaults::colorSphere
DrawColor colorSphere
Definition: DebugDrawerTopic.h:215
armarx::DebugDrawerTopic
The DebugDrawerTopic wraps a DebugDrawerInterfacePrx and provides a more useful interface than the Ic...
Definition: DebugDrawerTopic.h:152
armarx::DebugDrawerTopic::getGlasbeyLUTColor
static DrawColor getGlasbeyLUTColor(int id, float alpha=1.f)
Get a color from the Glasbey look-up-table.
Definition: DebugDrawerTopic.cpp:1008
armarx::DebugDrawerTopic::VisuID::layer
std::string layer
The layer name (empty by default).
Definition: DebugDrawerTopic.h:201
armarx::DebugDrawerTopic::drawLineSet
void drawLineSet(const VisuID &id, const DebugDrawerLineSet &lineSet, bool ignoreLengthScale=false)
Draw a line set.
Definition: DebugDrawerTopic.cpp:503
armarx::DebugDrawerTopic::enabled
bool enabled() const
Indicate whether visualization is enabled, i.e. a topic is set and enabled flag is set.
Definition: DebugDrawerTopic.cpp:68
armarx::DebugDrawerTopic::drawPointCloudLabeled
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.
Definition: DebugDrawerTopic.h:878
VirtualRobot
Definition: FramedPose.h:43
armarx::DebugDrawerTopic::drawText
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.
Definition: DebugDrawerTopic.cpp:167
armarx::DebugDrawerTopic::DebugDrawerTopic
DebugDrawerTopic(const std::string &layer=DEFAULT_LAYER)
Construct without topic, and optional layer.
Definition: DebugDrawerTopic.cpp:44
armarx::DebugDrawerTopic::removeboxEdges
void removeboxEdges(const VisuID &id)
Remove box edges (as a line set).
Definition: DebugDrawerTopic.cpp:335
armarx::DebugDrawerTopic::drawLine
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.
Definition: DebugDrawerTopic.cpp:480
armarx::DebugDrawerTopic::drawFloor
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.
Definition: DebugDrawerTopic.cpp:887
armarx::DebugDrawerTopic::shortSleep
void shortSleep()
Sleep for the shortSleepDuration. Useful after clearing.
Definition: DebugDrawerTopic.cpp:133
armarx::DebugDrawerTopic::Defaults::colorPolygonEdge
DrawColor colorPolygonEdge
Definition: DebugDrawerTopic.h:218
armarx::DebugDrawerTopic::operator->
DebugDrawerInterfacePrx & operator->()
Pointer member access operator to access the raw debug drawer proxy.
Definition: DebugDrawerTopic.cpp:987
armarx::DebugDrawerTopic::setLengthScaleMillimetersToMeters
void setLengthScaleMillimetersToMeters()
Set the scale for positions, lengths and distances to 0.001.
Definition: DebugDrawerTopic.cpp:108
armarx::DebugDrawerTopic::VisuID::withName
VisuID withName(const std::string &name) const
Get a VisuID with the given name and same layer as `*this.
Definition: DebugDrawerTopic.cpp:28
armarx::DebugDrawerTopic::setLengthScale
void setLengthScale(float scale)
Set the scale for positions, lengths and distances.
Definition: DebugDrawerTopic.cpp:98
armarx::DebugDrawerTopic::toDrawColor
static DrawColor toDrawColor(const ColorT &color, float alpha=1, bool byteToFloat=false)
Construct a DrawColor from the given color type.
Definition: DebugDrawerTopic.h:841
armarx::DebugDrawerTopic::hsv2rgb
static Eigen::Vector3f hsv2rgb(const Eigen::Vector3f &hsv)
Convert a HSV color RGB.
Definition: DebugDrawerTopic.cpp:1002
armarx::DebugDrawerTopic::VisuID::VisuID
VisuID()
Empty constructor.
Definition: DebugDrawerTopic.cpp:18
armarx::DebugDrawerTopic::drawPointCloudRGBA
void drawPointCloudRGBA(const VisuID &id, const PointCloudT &pointCloud, float pointSize=DEFAULTS.pointCloudPointSize, bool ignoreLengthScale=false)
Draw a colored point cloud with RGBA information.
Definition: DebugDrawerTopic.h:864
armarx::DebugDrawerTopic::removeRobot
void removeRobot(const VisuID &id)
Remove a robot visualization.
Definition: DebugDrawerTopic.cpp:701
armarx::DebugDrawerTopic::updateRobotNodeColor
void updateRobotNodeColor(const VisuID &id, const std::string &nodeName, const DrawColor &color)
Update / set the color of a robot node.
Definition: DebugDrawerTopic.cpp:690
armarx::DebugDrawerTopic::Defaults::pointCloudPointSize
float pointCloudPointSize
Definition: DebugDrawerTopic.h:225
armarx::DebugDrawerTopic::clearColoredPointCloud
void clearColoredPointCloud(const VisuID &id)
Forces the "deletion" of a point cloud by drawing an empty one.
Definition: DebugDrawerTopic.cpp:881
armarx::DebugDrawerTopic::VisuID::VisuID
VisuID(const Source &name)
Construct a VisuID from a non-std::string source (e.g. char[]).
Definition: DebugDrawerTopic.h:189
armarx::DebugDrawerTopic::clearLayer
void clearLayer(bool sleep=false)
Clear the (set default) layer.
Definition: DebugDrawerTopic.cpp:150
armarx::DebugDrawerTopic::rgb2hsv
static Eigen::Vector3f rgb2hsv(const Eigen::Vector3f &rgb)
Convert a RGB color to HSV.
Definition: DebugDrawerTopic.cpp:997
armarx::DebugDrawerTopic::Defaults::boxEdgesColor
DrawColor boxEdgesColor
Definition: DebugDrawerTopic.h:229
armarx::DebugDrawerTopic::getLayer
const std::string & getLayer() const
Get the default layer (used if no layer is passed to a method).
Definition: DebugDrawerTopic.cpp:83
armarx::DebugDrawerTopic::updateRobotConfig
void updateRobotConfig(const VisuID &id, const std::map< std::string, float > &config)
Update / set the robot configuration (joint angles).
Definition: DebugDrawerTopic.cpp:670
armarx::DebugDrawerTopic::removeArrow
void removeArrow(const VisuID &id)
Remove an arrow.
Definition: DebugDrawerTopic.cpp:439
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
armarx::DebugDrawerTopic::drawCylinder
void drawCylinder(const VisuID &id, const Eigen::Vector3f &center, const Eigen::Vector3f &direction, float length, float radius, const DrawColor &color=DEFAULTS.colorCylinder, bool ignoreLengthScale=false)
Draw a cylinder with center and direction.
Definition: DebugDrawerTopic.cpp:341
armarx::DebugDrawerTopic::setLengthScaleMetersToMillimeters
void setLengthScaleMetersToMillimeters()
Set the scale for positions, lengths and distances to 1000.
Definition: DebugDrawerTopic.cpp:103
armarx::DebugDrawerTopic::removePolygon
void removePolygon(const VisuID &id)
Remove a polygon.
Definition: DebugDrawerTopic.cpp:471
armarx::DebugDrawerTopic::updateRobotColor
void updateRobotColor(const VisuID &id, const DrawColor &color)
Update / set the robot color.
Definition: DebugDrawerTopic.cpp:680
armarx::DebugDrawerTopic::drawArrowFromTo
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.
Definition: DebugDrawerTopic.cpp:425
armarx::DebugDrawerTopic::setPoseScaleMeters
void setPoseScaleMeters()
Set the pose scale to 0.001 (good when drawing in meters).
Definition: DebugDrawerTopic.cpp:123
armarx::DebugDrawerTopic::Defaults::colorLine
DrawColor colorLine
Definition: DebugDrawerTopic.h:214
armarx::DebugDrawerTopic::VisuID::name
std::string name
The visu name (empty by default).
Definition: DebugDrawerTopic.h:202
armarx::DebugDrawerTopic::getLengthScale
float getLengthScale() const
Get the scaling for positions, lengths and distances.
Definition: DebugDrawerTopic.cpp:93
armarx::DebugDrawerTopic::drawBox
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.
Definition: DebugDrawerTopic.cpp:179
armarx::DebugDrawerTopic::getPoseScale
float getPoseScale() const
Get the scale for pose visualization.
Definition: DebugDrawerTopic.cpp:113
armarx::PointCloudT
pcl::PointCloud< PointT > PointCloudT
Definition: Common.h:30
armarx::DebugDrawerTopic::setShortSleepDuration
void setShortSleepDuration(const DurationT &duration)
Set the duration for "short sleeps".
Definition: DebugDrawerTopic.h:835
armarx::DebugDrawerTopic::Defaults::colorCylinder
DrawColor colorCylinder
Definition: DebugDrawerTopic.h:213
armarx::DebugDrawerTopic::removeBox
void removeBox(const VisuID &id)
Remove a box.
Definition: DebugDrawerTopic.cpp:217
armarx::DebugDrawerTopic::Defaults::colorPolygonFace
DrawColor colorPolygonFace
Definition: DebugDrawerTopic.h:217
armarx::DebugDrawerTopic::drawPose
void drawPose(const VisuID &id, const Eigen::Matrix4f &pose, bool ignoreLengthScale=false)
Draw a pose (with the preset scale).
Definition: DebugDrawerTopic.cpp:586
armarx::DebugDrawerTopic::Defaults::colorPointCloud
DrawColor colorPointCloud
Definition: DebugDrawerTopic.h:222
armarx::ManagedIceObject
The ManagedIceObject is the base class for all ArmarX objects.
Definition: ManagedIceObject.h:163
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::DebugDrawerTopic::setPoseScale
void setPoseScale(float scale)
Set the scale for pose visualization.
Definition: DebugDrawerTopic.cpp:118
std
Definition: Application.h:66
armarx::DebugDrawerTopic::setLayer
void setLayer(const std::string &layer)
Set the default layer (used if no layer is passed to a method).
Definition: DebugDrawerTopic.cpp:88
armarx::DebugDrawerTopic::drawBoxEdges
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).
Definition: DebugDrawerTopic.cpp:225
armarx::Quaternion< float, 0 >
armarx::DebugDrawerTopic::removeLine
void removeLine(const VisuID &id)
Remove a line.
Definition: DebugDrawerTopic.cpp:494
armarx::DebugDrawerTopic::drawTriMesh
void drawTriMesh(const VisuID &id, const VirtualRobot::TriMeshModel &triMesh, const DrawColor &color={.5,.5,.5, 1}, bool ignoreLengthScale=false)
Draw a TriMeshModel as DebugDrawerTriMesh.
Definition: DebugDrawerTopic.cpp:710
armarx::DebugDrawerTopic::updateRobotPose
void updateRobotPose(const VisuID &id, const Eigen::Matrix4f &pose, bool ignoreScale=false)
Update / set the robot pose.
Definition: DebugDrawerTopic.cpp:651
armarx::DebugDrawerTopic::drawPointCloud
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.
Definition: DebugDrawerTopic.h:849
IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface >
armarx::DebugDrawerTopic::drawPolygon
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.
Definition: DebugDrawerTopic.cpp:448
armarx::DebugDrawerTopic::Defaults::colorText
DrawColor colorText
Definition: DebugDrawerTopic.h:209
armarx::DebugDrawerTopic::drawTriMeshAsPolygons
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.
Definition: DebugDrawerTopic.cpp:774
armarx::DebugDrawerTopic::removeCylinder
void removeCylinder(const VisuID &id)
Remove a cylinder.
Definition: DebugDrawerTopic.cpp:379
armarx::DebugDrawerTopic::setPoseScaleMillimeters
void setPoseScaleMillimeters()
Set the pose scale to 1 (good when drawing in millimeters).
Definition: DebugDrawerTopic.cpp:128
Eigen::Matrix
Definition: EigenForwardDeclarations.h:27
armarx::DebugDrawerTopic::Defaults::colorArrow
DrawColor colorArrow
Definition: DebugDrawerTopic.h:211
armarx::DebugDrawerTopic::drawSphere
void drawSphere(const VisuID &id, const Eigen::Vector3f &center, float radius, const DrawColor &color=DEFAULTS.colorSphere, bool ignoreLengthScale=false)
Draw a sphere.
Definition: DebugDrawerTopic.cpp:388
armarx::DebugDrawerTopic::Defaults::boxEdgesWidth
float boxEdgesWidth
Definition: DebugDrawerTopic.h:230
armarx::DebugDrawerTopic::getTopic
DebugDrawerInterfacePrx getTopic() const
Get the topic.
Definition: DebugDrawerTopic.cpp:58
armarx::DebugDrawerTopic::drawRobot
void drawRobot(const VisuID &id, const std::string &robotFile, const std::string &armarxProject, armarx::DrawStyle drawStyle=armarx::DrawStyle::FullModel)
Draw a robot.
Definition: DebugDrawerTopic.cpp:640
armarx::DebugDrawerTopic::VisuID::operator<<
friend std::ostream & operator<<(std::ostream &os, const VisuID &rhs)
Streams a short human-readable description of rhs to os.
Definition: DebugDrawerTopic.cpp:33
armarx::DebugDrawerTopic::setEnabled
void setEnabled(bool enabled)
Set whether drawing is enabled.
Definition: DebugDrawerTopic.cpp:63
armarx::DebugDrawerTopic::VisuID
A visualisation ID.
Definition: DebugDrawerTopic.h:175
armarx::DebugDrawerInterfacePrx
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface > DebugDrawerInterfacePrx
Definition: JointController.h:40
armarx::DebugDrawerTopic::removeSphere
void removeSphere(const VisuID &id)
Remove a sphere.
Definition: DebugDrawerTopic.cpp:402
armarx::DebugDrawerTopic::clearAll
void clearAll(bool sleep=false)
Clear all layers.
Definition: DebugDrawerTopic.cpp:138
armarx::DebugDrawerTopic::Defaults
Default values for drawing functions.
Definition: DebugDrawerTopic.h:207
armarx::DebugDrawerTopic::removePose
void removePose(const VisuID &id)
Remove a pose.
Definition: DebugDrawerTopic.cpp:631
armarx::DebugDrawerTopic::drawCylinderFromTo
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.
Definition: DebugDrawerTopic.cpp:365
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::DebugDrawerTopic::DEFAULTS
static const Defaults DEFAULTS
Definition: DebugDrawerTopic.h:232
armarx::DebugDrawerTopic::drawArrow
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.
Definition: DebugDrawerTopic.cpp:411
armarx::DebugDrawerTopic::removeLineSet
void removeLineSet(const VisuID &id)
Remove a line set.
Definition: DebugDrawerTopic.cpp:577