Corentin Chauvin-Hameau – 2019-2020
Coverage Path Planning for an underwater robot surveying a marine farm
farm_common.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  *
4  * \brief Declaration of common structures and functions for farm simulator
5  * \author Corentin Chauvin-Hameau
6  * \date 2019
7  */
8 
9 #ifndef FARM_COMMON_HPP
10 #define FARM_COMMON_HPP
11 
12 #include <tf2/LinearMath/Vector3.h>
13 #include <tf2/LinearMath/Quaternion.h>
14 #include <geometry_msgs/Point32.h>
15 #include <iostream>
16 #include <vector>
17 
18 
19 namespace mfcpp {
20  /**
21  * \brief Rope tensed between two 3D points
22  */
23  struct Rope
24  {
25  tf2::Vector3 p1; ///< Position of the first extremity of the rope
26  tf2::Vector3 p2; ///< Position of the second extremity of the rope
27  };
28 
29  /**
30  * \brief Alga hanging on a line
31  */
32  struct Alga
33  {
34  /**
35  * \brief Position of the alga on the line
36  *
37  * 0.0 -> center of the alga on one extremity of the line <br/>
38  * 1.0 -> center of the alga on the other extremity of the line
39  */
40  tf2::Vector3 position;
41 
42  float orientation; ///< Orientation of the alga
43  float length; ///< Length of the alga
44  float width; ///< Width of the alga
45 
46  /**
47  * \brief Heatmap representing disease across the alga
48  *
49  * 0.0 -> alga sane <br/>
50  * 1.0 -> alga sick
51  */
52  std::vector<std::vector<float>> disease_heatmap;
53  };
54 
55  /**
56  * \brief Line on which algae grow
57  */
58  struct AlgaeLine
59  {
60  Rope line; ///< Rope on wich the algae grow
61  Rope floating_rope; ///< Rope on wich the buoys are
62  tf2::Vector3 anchor1; ///< First anchor
63  tf2::Vector3 anchor2; ///< Second anchor
64  float thickness_ropes; ///< Thickness of each rope
65  float anchors_diameter; ///< Anchors diameter
66  float anchors_height; ///< Anchors height
67  unsigned int nbr_buoys; ///< Number of buoys on the floating rope
68  float buoys_diameter; ///< Diameter of a buoy
69  std::vector<Alga> algae; ///< List of algae hanging on the line
70  };
71 
72  /**
73  * \brief Computes the corner coordinates of an alga
74  *
75  * coord[0] | coord[1] --> line
76  * -------------------
77  * coord[3] | coord[2]
78  *
79  * \param line Algae line on which the algae is
80  * \param alga Alga to find the coordinates
81  * \return Coordinates of the alga
82  */
83  std::vector<tf2::Vector3> get_alga_coord(const AlgaeLine &line, const Alga &alga);
84 
85 
86  /**
87  * \brief Displays a vector
88  *
89  * \param stream Stream on which to display the vector
90  * \param v Vector to display
91  * \return Output stream
92  */
93  std::ostream &operator<<(std::ostream &stream, const tf2::Vector3 &v);
94 
95  /**
96  * \brief Convert a tf2::Vector3 to a geometry_msgs::Point32
97  *
98  * \note tf2::ToMsg() implements a conversion to Point, but not Point32
99  * \param p Vector3 to convert
100  * \return Converted Point32
101  */
102  inline geometry_msgs::Point32 vector3_to_point32(tf2::Vector3 p)
103  {
104  geometry_msgs::Point32 pt;
105  pt.x = p.getX();
106  pt.y = p.getY();
107  pt.z = p.getZ();
108 
109  return pt;
110  }
111 
112 } // namespace mfcpp
113 
114 #endif
tf2::Vector3 position
Position of the alga on the line.
Definition: farm_common.hpp:40
Definition: common.hpp:23
float buoys_diameter
Diameter of a buoy.
Definition: farm_common.hpp:68
Rope floating_rope
Rope on wich the buoys are.
Definition: farm_common.hpp:61
float thickness_ropes
Thickness of each rope.
Definition: farm_common.hpp:64
Rope tensed between two 3D points.
Definition: farm_common.hpp:23
float anchors_diameter
Anchors diameter.
Definition: farm_common.hpp:65
tf2::Vector3 anchor1
First anchor.
Definition: farm_common.hpp:62
tf2::Vector3 anchor2
Second anchor.
Definition: farm_common.hpp:63
std::vector< Alga > algae
List of algae hanging on the line.
Definition: farm_common.hpp:69
std::vector< std::vector< float > > disease_heatmap
Heatmap representing disease across the alga.
Definition: farm_common.hpp:52
float width
Width of the alga.
Definition: farm_common.hpp:44
geometry_msgs::Point32 vector3_to_point32(tf2::Vector3 p)
Convert a tf2::Vector3 to a geometry_msgs::Point32.
tf2::Vector3 p1
Position of the first extremity of the rope.
Definition: farm_common.hpp:25
tf2::Vector3 p2
Position of the second extremity of the rope.
Definition: farm_common.hpp:26
Rope line
Rope on wich the algae grow.
Definition: farm_common.hpp:60
float length
Length of the alga.
Definition: farm_common.hpp:43
unsigned int nbr_buoys
Number of buoys on the floating rope.
Definition: farm_common.hpp:67
float anchors_height
Anchors height.
Definition: farm_common.hpp:66
Line on which algae grow.
Definition: farm_common.hpp:58
Alga hanging on a line.
Definition: farm_common.hpp:32
std::ostream & operator<<(std::ostream &stream, const tf2::Vector3 &v)
Displays a vector.
std::vector< tf2::Vector3 > get_alga_coord(const AlgaeLine &line, const Alga &alga)
Computes the corner coordinates of an alga.
Definition: farm_common.cpp:20
float orientation
Orientation of the alga.
Definition: farm_common.hpp:42