Corentin Chauvin-Hameau – 2019-2020
Coverage Path Planning for an underwater robot surveying a marine farm
rviz_visualisation.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  *
4  * \brief Declaration of common Rviz display functions
5  * \author Corentin Chauvin-Hameau
6  * \date 2019
7  */
8 
9 #ifndef RVIZ_VISUALISATION_HPP
10 #define RVIZ_VISUALISATION_HPP
11 
12 #include <std_msgs/ColorRGBA.h>
13 #include <visualization_msgs/Marker.h>
14 #include <visualization_msgs/MarkerArray.h>
15 #include <tf2/LinearMath/Vector3.h>
16 #include <ros/ros.h>
17 
18 
19 namespace mfcpp {
20  /**
21  * \brief Arguments used to create a Rviz maker
22  */
23  struct MarkerArgs
24  {
25  ros::Time stamp; ///< Time stamp for the ROS message
26  std::string frame_id; ///< Frame in which position/orientation of the object is
27  std::string ns; ///< Namespace for the Rviz marker
28  ros::Duration duration; ///< Duration of the marker (in sec)
29  std_msgs::ColorRGBA color; ///< Color of the marker
30  };
31 
32  /**
33  * \brief Fill header of marker
34  *
35  * \param marker The marker to fill
36  * \param common_args Common arguments to fill ROS message
37  */
38  void fill_marker_header(visualization_msgs::Marker &marker,
39  const MarkerArgs &common_args);
40 
41  /**
42  * \brief Creates a blank Rviz marker to display spheres
43  *
44  * \param diameter Diameter of the spheres (in m)
45  * \param common_args Common arguments to fill ROS message
46  * \return Corresponding Rviz marker
47  */
48  visualization_msgs::Marker rviz_marker_spheres(float thickness,
49  const MarkerArgs &common_args);
50 
51  /**
52  * \brief Creates a blank Rviz marker to display lines
53  *
54  * \param thickness Thickness of the lines (in m)
55  * \param common_args Common arguments to fill ROS message
56  * \return Corresponding Rviz marker
57  */
58  visualization_msgs::Marker rviz_marker_line(float thickness,
59  const MarkerArgs &common_args);
60 
61  /**
62  * \brief Creates a Rviz marker to display a line
63  *
64  * \param p1 First extremity of the line
65  * \param p2 Second extremity of the line
66  * \param thickness Thickness of the line (in m)
67  * \param common_args Common arguments to fill ROS message
68  * \return Corresponding Rviz marker
69  */
70  visualization_msgs::Marker rviz_marker_line(tf2::Vector3 p1, tf2::Vector3 p2,
71  float thickness, const MarkerArgs &common_args);
72 
73  /**
74  * \brief Creates a Rviz marker to display a cylinder
75  *
76  * The cylinder will be aligned with the z axis of the frame provided
77  * in `common_args`.
78  *
79  * \param p Position of the center of the cylinder
80  * \param diameter Diameter (in m)
81  * \param height Height (in m)
82  * \param common_args Common arguments to fill ROS message
83  * \return Corresponding Rviz marker
84  */
85  visualization_msgs::Marker rviz_marker_cylinder(tf2::Vector3 p, float diameter,
86  float height, const MarkerArgs &common_args);
87 
88  /**
89  * \brief Creates a blank Rviz marker to display triangles
90  *
91  * \param common_args Common arguments to fill ROS message
92  * \return Corresponding Rviz marker
93  */
94  visualization_msgs::Marker rviz_marker_triangles(const MarkerArgs &common_args);
95 
96 
97  /**
98  * \brief Creates a blank Rviz marker to display rectangles
99  *
100  * The rectangles will be made of two triangles
101  *
102  * \param common_args Common arguments to fill ROS message
103  * \return Corresponding Rviz marker
104  */
105  visualization_msgs::Marker rviz_marker_rect(const MarkerArgs &common_args);
106 
107  /**
108  * \brief Creates a Rviz marker to display a rectangle
109  *
110  * The rectangle will be made of two triangles
111  *
112  * \param p1 First point
113  * \param p2 Second point
114  * \param p3 Third point
115  * \param p4 Fourth point
116  * \param common_args Common arguments to fill ROS message
117  * \return Corresponding Rviz marker
118  */
119  visualization_msgs::Marker rviz_marker_rect(tf2::Vector3 p1, tf2::Vector3 p2,
120  tf2::Vector3 p3, tf2::Vector3 p4, const MarkerArgs &common_args);
121 
122  /**
123  * \brief Populates id of all the markers in a marker array
124  *
125  * \note The id of each marker needs to be different for Rviz to display it
126  * correctly.
127  */
128  void pop_marker_ids(visualization_msgs::MarkerArray &array);
129 
130 } // namespace mfcpp
131 
132 #endif
Definition: common.hpp:23
visualization_msgs::Marker rviz_marker_line(float thickness, const MarkerArgs &common_args)
Creates a blank Rviz marker to display lines.
Arguments used to create a Rviz maker.
ros::Time stamp
Time stamp for the ROS message.
void pop_marker_ids(visualization_msgs::MarkerArray &array)
Populates id of all the markers in a marker array.
std::string frame_id
Frame in which position/orientation of the object is.
visualization_msgs::Marker rviz_marker_rect(const MarkerArgs &common_args)
Creates a blank Rviz marker to display rectangles.
visualization_msgs::Marker rviz_marker_cylinder(tf2::Vector3 p, float diameter, float height, const MarkerArgs &common_args)
Creates a Rviz marker to display a cylinder.
void fill_marker_header(visualization_msgs::Marker &marker, const MarkerArgs &common_args)
Fill header of marker.
visualization_msgs::Marker rviz_marker_triangles(const MarkerArgs &common_args)
Creates a blank Rviz marker to display triangles.
ros::Duration duration
Duration of the marker (in sec)
visualization_msgs::Marker rviz_marker_spheres(float thickness, const MarkerArgs &common_args)
Creates a blank Rviz marker to display spheres.
std::string ns
Namespace for the Rviz marker.
std_msgs::ColorRGBA color
Color of the marker.