mrs_lib
Various reusable classes, functions and utilities for use in MRS projects
visual_object.h
Go to the documentation of this file.
1 
6 #ifndef BATCH_VISUALIZER__VISUAL_OBJECT_H
7 #define BATCH_VISUALIZER__VISUAL_OBJECT_H
8 
9 #include <Eigen/Core>
10 #include <ros/time.h>
11 #include <std_msgs/ColorRGBA.h>
12 #include <geometry_msgs/Point.h>
14 #include <mrs_msgs/Path.h>
15 #include <mrs_msgs/TrajectoryReference.h>
16 
17 #define DEFAULT_ELLIPSE_POINTS 64
18 
19 namespace mrs_lib
20 {
21 
22 enum MarkerType
23 {
24  POINT = 0,
25  LINE = 1,
26  TRIANGLE = 2
27 };
28 
29 class VisualObject {
30 
31 
32 public:
33  VisualObject(const Eigen::Vector3d& point, const double r, const double g, const double b, const double a, const ros::Duration& timeout,
34  const unsigned long& id);
35 
36  VisualObject(const mrs_lib::geometry::Ray& ray, const double r, const double g, const double b, const double a, const ros::Duration& timeout,
37  const unsigned long& id);
38 
39  VisualObject(const mrs_lib::geometry::Triangle& triangle, const double r, const double g, const double b, const double a, const ros::Duration& timeout,
40  const bool filled, const unsigned long& id);
41 
42  VisualObject(const mrs_lib::geometry::Rectangle& rectangle, const double r, const double g, const double b, const double a, const ros::Duration& timeout,
43  const bool filled, const unsigned long& id);
44 
45  VisualObject(const mrs_lib::geometry::Cuboid& cuboid, const double r, const double g, const double b, const double a, const ros::Duration& timeout,
46  const bool filled, const unsigned long& id);
47 
48  VisualObject(const mrs_lib::geometry::Ellipse& ellipse, const double r, const double g, const double b, const double a, const ros::Duration& timeout,
49  const bool filled, const unsigned long& id, const int num_points = DEFAULT_ELLIPSE_POINTS);
50 
51  VisualObject(const mrs_lib::geometry::Cylinder& cylinder, const double r, const double g, const double b, const double a, const ros::Duration& timeout,
52  const bool filled, const bool capped, const unsigned long& id, const int num_sides = DEFAULT_ELLIPSE_POINTS);
53 
54  VisualObject(const mrs_lib::geometry::Cone& cone, const double r, const double g, const double b, const double a, const ros::Duration& timeout,
55  const bool filled, const bool capped, const unsigned long& id, const int num_sides = DEFAULT_ELLIPSE_POINTS);
56 
57  VisualObject(const mrs_msgs::Path& p, const double r, const double g, const double b, const double a, const ros::Duration& timeout, const bool filled,
58  const unsigned long& id);
59 
60  VisualObject(const mrs_msgs::TrajectoryReference& traj, const double r, const double g, const double b, const double a, const ros::Duration& timeout,
61  const bool filled, const unsigned long& id);
62 
63 
64 public:
65  unsigned long getID() const;
66  int getType() const;
67  bool isTimedOut() const;
68 
69  const std::vector<geometry_msgs::Point> getPoints() const;
70  const std::vector<std_msgs::ColorRGBA> getColors() const;
71 
72  bool operator<(const VisualObject& other) const {
73  return id_ < other.id_;
74  }
75 
76  bool operator>(const VisualObject& other) const {
77  return id_ > other.id_;
78  }
79 
80  bool operator==(const VisualObject& other) const {
81  return id_ == other.id_;
82  }
83 
84 private:
85  const unsigned long id_;
86  MarkerType type_;
87  std::vector<geometry_msgs::Point> points_;
88  std::vector<std_msgs::ColorRGBA> colors_;
89  ros::Time timeout_time_;
90 
91  void addRay(const mrs_lib::geometry::Ray& ray, const double r, const double g, const double b, const double a);
92 
93  void addTriangle(const mrs_lib::geometry::Triangle& triangle, const double r, const double g, const double b, const double a, const bool filled);
94 
95  void addEllipse(const mrs_lib::geometry::Ellipse& ellipse, const double r, const double g, const double b, const double a, const bool filled,
96  const int num_points);
97 
98 }; // namespace batch_visualizer
99 
100 } // namespace mrs_lib
101 
102 #endif
mrs_lib::geometry::Ray
geometric representation of a ray. Instantiate it by two input Vector3. Use static methods for from-t...
Definition: shapes.h:26
mrs_lib::geometry::Cuboid
geometric representation of a cuboid
Definition: shapes.h:319
mrs_lib::geometry::Ellipse
geometric representation of an ellipse
Definition: shapes.h:428
mrs_lib
All mrs_lib functions, classes, variables and definitions are contained in this namespace.
Definition: attitude_converter.h:29
mrs_lib::geometry::Rectangle
geometric representation of a rectangle (can represent any quadrilateral)
Definition: shapes.h:189
shapes.h
Defines various geometrical shapes and their relations.
mrs_lib::geometry::Triangle
geometric representation of a triangle. Instantiate a new triangle by providing three vertices
Definition: shapes.h:100
mrs_lib::geometry::Cylinder
geometric representation of a cylinder
Definition: shapes.h:492
mrs_lib::VisualObject
Definition: visual_object.h:29
mrs_lib::geometry::Cone
geometric representaiton of a cone
Definition: shapes.h:575