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 {
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 
153  {
154  public:
155 
156 
175  struct VisuID
176  {
177  public:
178 
180  VisuID();
181 
183  VisuID(const std::string& name);
185  VisuID(const std::string& layer, const std::string& name);
186 
188  template <typename Source>
189  VisuID(const Source& name) : VisuID(std::string(name))
190  {}
191 
192 
194  VisuID withName(const std::string& name) const;
195 
197  friend std::ostream& operator<<(std::ostream& os, const VisuID& rhs);
198 
199  public:
200 
201  std::string layer = "";
202  std::string name = "";
203  };
204 
205 
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 
240  DebugDrawerTopic(const std::string& layer = DEFAULT_LAYER);
242  DebugDrawerTopic(const DebugDrawerInterfacePrx& topic, const std::string& layer = DEFAULT_LAYER);
243 
244 
246  void setTopic(const DebugDrawerInterfacePrx& topic);
249 
254  void setEnabled(bool enabled);
256  bool enabled() const;
257 
264  void offeringTopic(ManagedIceObject& component, const std::string& topicNameOverride = "") const;
271  void getTopic(ManagedIceObject& component, const std::string& topicNameOverride = "");
272 
274  const std::string& getLayer() const;
276  void setLayer(const std::string& layer);
277 
279  float getLengthScale() const;
281  void setLengthScale(float scale);
286 
288  float getPoseScale() const;
291  void setPoseScale(float scale);
293  void setPoseScaleMeters();
296 
297 
298 
299  // SLEEP
300 
302  void shortSleep();
303 
305  template <typename DurationT>
306  void sleepFor(const DurationT& duration);
307 
309  template <typename DurationT>
310  void setShortSleepDuration(const DurationT& duration);
311 
312 
313  // CLEAR
314 
317  void clearAll(bool sleep = false);
318 
321  void clearLayer(bool sleep = false);
322 
325  void clearLayer(const std::string& layer, bool sleep = false);
326 
327 
328  // PRIMITIVES
329 
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 
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);
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 
349  void drawBox(const VisuID& id,
350  const VirtualRobot::BoundingBox& boundingBox,
351  const DrawColor& color = DEFAULTS.colorBox,
352  bool ignoreLengthScale = false);
353 
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 
362  void removeBox(const VisuID& id);
363 
364 
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 
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 
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 
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 
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 
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 
403  void removeboxEdges(const VisuID& id);
404 
405 
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 
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 
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 
435  void removeCylinder(const VisuID& id);
436 
437 
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 
446  void removeSphere(const VisuID& id);
447 
448 
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 
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 
464  void removeArrow(const VisuID& id);
465 
466 
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 
476  void removePolygon(const VisuID& id);
477 
478 
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 
487  void removeLine(const VisuID& id);
488 
489 
491  void drawLineSet(
492  const VisuID& id,
493  const DebugDrawerLineSet& lineSet,
494  bool ignoreLengthScale = false);
495 
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 
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 
519  void removeLineSet(const VisuID& id);
520 
521 
522  // POSE
523 
525  void drawPose(const VisuID& id, const Eigen::Matrix4f& pose,
526  bool ignoreLengthScale = false);
528  void drawPose(const VisuID& id, const Eigen::Vector3f& pos, const Eigen::Quaternionf& ori,
529  bool ignoreLengthScale = false);
530 
532  void drawPose(const VisuID& id, const Eigen::Matrix4f& pose, float scale,
533  bool ignoreLengthScale = false);
535  void drawPose(const VisuID& id, const Eigen::Vector3f& pos, const Eigen::Quaternionf& ori,
536  float scale,
537  bool ignoreLengthScale = false);
538 
540  void removePose(const VisuID& id);
541 
542 
543  // ROBOT
544 
554  void drawRobot(
555  const VisuID& id,
556  const std::string& robotFile, const std::string& armarxProject,
557  armarx::DrawStyle drawStyle = armarx::DrawStyle::FullModel);
558 
560  void updateRobotPose(
561  const VisuID& id,
562  const Eigen::Matrix4f& pose,
563  bool ignoreScale = false);
564 
566  void updateRobotPose(
567  const VisuID& id,
568  const Eigen::Vector3f& pos, const Eigen::Quaternionf& ori,
569  bool ignoreScale = false);
570 
572  void updateRobotConfig(
573  const VisuID& id,
574  const std::map<std::string, float>& config);
575 
577  void updateRobotColor(const VisuID& id, const DrawColor& color);
580  const VisuID& id, const std::string& nodeName, const DrawColor& color);
581 
583  void removeRobot(const VisuID& id);
584 
585 
586  // TRI MESH
587 
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 
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 
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 
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 
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 
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 
657  template <class PointCloudT>
659  const VisuID& id,
660  const PointCloudT& pointCloud,
661  float pointSize = DEFAULTS.pointCloudPointSize,
662  bool ignoreLengthScale = false);
663 
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 
685  void drawPointCloud(const VisuID& id, const DebugDrawerPointCloud& pointCloud);
686 
688  void drawPointCloud(const VisuID& id, const DebugDrawerColoredPointCloud& pointCloud);
689 
691  void drawPointCloud(const VisuID& id, const DebugDrawer24BitColoredPointCloud& pointCloud);
692 
693 
695  void clearColoredPointCloud(const VisuID& id);
696 
697 
698  // CUSTOM
699 
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 
718  operator bool() const;
719 
721  operator DebugDrawerInterfacePrx& ();
722  operator const DebugDrawerInterfacePrx& () const;
723 
726  const DebugDrawerInterfacePrx& operator->() const;
727 
728 
729  public: // STATIC
730 
736  static Eigen::Vector3f rgb2hsv(const Eigen::Vector3f& rgb);
737 
743  static Eigen::Vector3f hsv2rgb(const Eigen::Vector3f& hsv);
744 
745 
757  template <class ColorT>
758  static DrawColor toDrawColor(const ColorT& color, float alpha = 1, bool byteToFloat = false);
759 
760 
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 
770  const std::string& layer(const std::string& passedLayer) const;
771 
773  const std::string& layer(const VisuID& id) const;
774 
775 
777  float lengthScale(bool ignore = false) const;
778 
780  static float scaled(float scale, float value);
782  static Vector3BasePtr scaled(float scale, const Eigen::Vector3f& vector);
784  static PoseBasePtr scaled(float scale, const Eigen::Matrix4f& pose);
785 
788  template <class ScaledT>
789  static ScaledT scaledT(float scale, const Eigen::Vector3f& vector);
790 
792  template <class XYZT>
793  static void scaleXYZ(float scale, XYZT& xyz);
794 
795 
796  private:
797 
799  static const std::string TOPIC_NAME;
801  static const std::string DEFAULT_LAYER;
802 
803 
805  DebugDrawerInterfacePrx topic = nullptr;
806 
808  bool _enabled = true;
809 
811  std::string _layer = DEFAULT_LAYER;
812 
814  float _lengthScale = 1;
815 
817  float _poseScale = 1;
818 
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
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