]> rtime.felk.cvut.cz Git - hubacji1/iamcar.git/blob - incl/rrtbase.h
Merge branch 'feature/rrt'
[hubacji1/iamcar.git] / incl / rrtbase.h
1 /*
2 This file is part of I am car.
3
4 I am car is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 I am car is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with I am car. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef RRTBASE_H
19 #define RRTBASE_H
20
21 #include <chrono>
22 #include <cmath>
23 #include <vector>
24 #include "rrtnode.h"
25
26 class RRTBase {
27         private:
28                 RRTNode *root_ = nullptr;
29                 RRTNode *goal_ = nullptr;
30
31                 std::vector<RRTNode *> nodes_;
32                 std::vector<RRTNode *> samples_;
33
34                 bool goal_found_ = false;
35                 std::chrono::high_resolution_clock::time_point tstart_;
36                 std::chrono::high_resolution_clock::time_point tend_;
37
38                 std::vector<std::vector<RRTNode *>> tlog_; // trajectories
39         public:
40                 const float GOAL_FOUND_DISTANCE = 1;
41                 const float GOAL_FOUND_ANGLE = 2 * M_PI;
42                 const float TMAX = 100; // computation time limit
43
44                 RRTBase();
45                 RRTBase(RRTNode *init, RRTNode *goal);
46
47                 // getter
48                 RRTNode *root();
49                 RRTNode *goal();
50                 std::vector<RRTNode *> &nodes();
51                 std::vector<RRTNode *> &samples();
52                 std::vector<std::vector<RRTNode *>> &tlog();
53                 bool goal_found();
54                 float elapsed();
55
56                 // setter
57                 bool tlog(std::vector<RRTNode *> t);
58                 void tstart();
59                 void tend();
60
61                 // other
62                 bool goal_found(
63                                 RRTNode *node,
64                                 float (*cost)(RRTNode *, RRTNode *));
65 };
66
67 #endif