]> rtime.felk.cvut.cz Git - hubacji1/iamcar.git/blob - incl/obstacle.h
Output JSON goals as RRT found goal
[hubacji1/iamcar.git] / incl / obstacle.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 _OBSTACLE_H
19 #define _OBSTACLE_H
20
21 #include <vector>
22 #include "rrtnode.h"
23
24 class Obstacle {
25         public:
26                 virtual bool collide(RRTNode *n) = 0;
27                 virtual bool collide(RRTEdge *e) = 0;
28                 virtual bool collide(std::vector<RRTEdge *> &lines) = 0;
29                 virtual float dist_to(RRTNode *n) = 0;
30 };
31
32 class CircleObstacle : public RRTNode, Obstacle {
33         public:
34                 using RRTNode::RRTNode;
35                 float r();
36                 bool collide(RRTNode *n);
37                 bool collide(RRTEdge *e);
38                 bool collide(std::vector<RRTEdge *> &edges);
39                 float dist_to(RRTNode *n);
40 };
41
42 class PolygonObstacle : public Obstacle {
43         private:
44                 std::vector<RRTNode *> bnodes_;
45         public:
46                 void add_bnode(RRTNode *n);
47                 bool collide(RRTNode *n);
48                 bool collide(RRTEdge *e);
49                 bool collide(std::vector<RRTEdge *> &edges);
50                 bool collide(std::vector<RRTEdge *> edges);
51                 float dist_to(RRTNode *n);
52                 std::vector<RRTEdge *> frame();
53
54                 // getter
55                 std::vector<RRTNode *> &bnodes();
56 };
57
58 class SegmentObstacle : public RRTEdge, Obstacle {
59         public:
60                 using RRTEdge::RRTEdge;
61                 bool collide(RRTNode *n);
62                 bool collide(RRTEdge *e);
63                 bool collide(std::vector<RRTEdge *> &edges);
64                 float dist_to(RRTNode *n);
65 };
66
67 #endif