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