]> rtime.felk.cvut.cz Git - hubacji1/iamcar.git/blob - incl/rrtnode.h
Add RRTNode, RRTBase class
[hubacji1/iamcar.git] / incl / rrtnode.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 RRTNODE_H
19 #define RRTNODE_H
20
21 #include <vector>
22
23 class RRTNode {
24         private:
25                 float x_ = 0;
26                 float y_ = 0;
27                 float h_ = 0;
28
29                 float dcost_ = 0; // direct cost (of edge) to parent
30                 float ccost_ = 0; // cumulative cost from root
31
32                 RRTNode *parent_ = nullptr;
33                 std::vector<RRTNode *> children_;
34
35                 bool visited_ = false; // for DFS
36         public:
37                 RRTNode();
38                 RRTNode(float x, float y);
39                 RRTNode(float x, float y, float h);
40
41                 // getter
42                 float x() const;
43                 float y() const;
44                 float h() const;
45
46                 float ccost() const;
47                 float dcost() const;
48
49                 std::vector<RRTNode *> &children();
50                 RRTNode *parent() const;
51
52                 bool visited();
53
54                 // setter
55                 bool add_child(RRTNode *node, float cost);
56
57                 float ccost(float cost);
58                 float dcost(float cost);
59
60                 bool parent(RRTNode *parent);
61                 bool visit(bool v);
62
63                 // other
64                 static bool comp_ccost(RRTNode *n1, RRTNode *n2);
65                 bool visit();
66 };
67
68 #endif