forked from shubhamgoyal/Motion-Planning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPotentialPlanner3.h
77 lines (62 loc) · 1.67 KB
/
PotentialPlanner3.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef POTENTIAL_PLANNER2
#define POTENTIAL_PLANNER2
#include "Planner.h"
#define CHARGE 3.0
/* This planner will consider the repulsion force from
the pedestrian and environment and convert it into control.
For force in Y direction, there is a default field towards
the goal, and we will consider only one pedestrian field
that is the maximum.
**For temporary, we don't implement force to X direction**
For force in X direction, we will sum up from all seen pedestrian
and there will be a field quite similar to resistance in the road.
*/
class PotentialPlanner2 : public Planner {
public:
//constructor
PotentialPlanner2():m_charge(3.0) {};
PotentialPlanner2(Car& acar, std::vector<Pedestrian> apedestrians):Planner(acar, apedestrians),m_charge(3.0){}
//public functions
void plan(std::vector<Pedestrian> &apedestrians);
protected:
//private struct and variable
struct Vector2D {
dd x;
dd y;
} ;
struct Cell {
dd x;
dd y;
dd q;
} ;
Vector2D addVector2D(Vector2D a, Vector2D b) {
Vector2D c;
c.x = a.x + b.x;
c.y = a.y + b.y;
return c;
}
void setVector2D(Vector2D &v, dd x, dd y)
{
v.x = x;
v.y = y;
}
Vector2D m_force;
Control m_control;
/* This is to implement force in the X direction.
We need to discretize the pedestrian (many pedestrian
in one place should be condsidered as one
*/
/*
int cellIndex[2][500];
vector <Cell> cells;
*/
//private functions
bool isDangerous(State astate);
//Vector2D calcPartialForce(State astate);
dd goalForce();
Vector2D calcForce(Pedestrian &apedestrian);
void calcTotalForce();
Control convertForceToControl(Vector2D f);
dd m_charge;
};
#endif