Corentin Chauvin-Hameau – 2019-2020
Coverage Path Planning for an underwater robot surveying a marine farm
farm_common.cpp
Go to the documentation of this file.
1 /**
2  * @file
3  *
4  * \brief Definition of common functions for farm simulator
5  * \author Corentin Chauvin-Hameau
6  * \date 2019
7  */
8 
9 #include "farm_common.hpp"
10 #include <random>
11 #include <cstdlib>
12 #include <iostream>
13 
14 
15 using namespace std;
16 
17 namespace mfcpp {
18 
19 
20 vector<tf2::Vector3> get_alga_coord(const AlgaeLine &line, const Alga &alga)
21 {
22  tf2::Vector3 X1 = line.line.p1;
23  tf2::Vector3 X2 = line.line.p2;
24  tf2::Vector3 z(0, 0, 1);
25  tf2::Vector3 y = (X2-X1) / tf2::tf2Distance(X1, X2);
26  tf2::Vector3 x = tf2::tf2Cross(y, z);
27 
28  tf2::Vector3 X = alga.position;
29  float psi = alga.orientation;
30  float H = alga.length;
31  float W = alga.width;
32 
33  vector<tf2::Vector3> coord(4);
34  coord[0] = X - W/2*y;
35  coord[1] = X + W/2*y;
36  coord[2] = coord[1] - H*(cos(psi)*z - sin(psi)*x);
37  coord[3] = coord[0] - H*(cos(psi)*z - sin(psi)*x);
38 }
39 
40 
41 ostream &operator<<(ostream &stream, const tf2::Vector3 &v)
42 {
43  stream << "(x=" << v.getX() << " ; y=" << v.getY() << " ; z=" << v.getZ() << ")";
44 }
45 
46 
47 } // namespace mfcpp
tf2::Vector3 position
Position of the alga on the line.
Definition: farm_common.hpp:40
Definition: common.hpp:23
Declaration of common structures and functions for farm simulator.
float width
Width of the alga.
Definition: farm_common.hpp:44
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
ostream & operator<<(ostream &stream, const tf2::Vector3 &v)
Definition: farm_common.cpp:41
Line on which algae grow.
Definition: farm_common.hpp:58
Alga hanging on a line.
Definition: farm_common.hpp:32
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