-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbehaviour.hpp
More file actions
93 lines (64 loc) · 2 KB
/
behaviour.hpp
File metadata and controls
93 lines (64 loc) · 2 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#pragma once
#include <constants.hpp>
#include <map.hpp>
#include <prediction.hpp>
#include <vehicle.hpp>
#include <util/collections.hpp>
#include <util/conversion.hpp>
#include <util/time.hpp>
#include <tl/optional.hpp>
#include <array>
namespace behaviour {
enum class Action {
INIT,
KEEP_LANE,
CHANGE_LANE_LEFT,
CHANGE_LANE_RIGHT
};
class State {
public:
State(Action action, const Vehicle &target)
: action_(action), target_(target), ts_(util::unix_ts()) {}
Action action() const {
return action_;
};
const Vehicle &target() const {
return target_;
}
long ts() const {
return ts_;
}
private:
Action action_;
Vehicle target_;
long long int ts_;
};
class Behaviour {
public:
explicit Behaviour(const Map &map);
virtual ~Behaviour() = default;
State nextState(const Vehicle &ego, const prediction::Predictions &);
const State& state() const {
return previous_state_;
}
private:
bool transitioning(const Vehicle &vehicle);
std::vector<Action> successions(const Vehicle &vehicle);
using Trajectory = std::vector<Vehicle>;
Trajectory generateTrajectory(Action state, const Vehicle &ego, const prediction::Predictions &);
Trajectory keepLaneTrajectory(const Vehicle &ego, const prediction::Predictions &predictions);
Trajectory changeLaneTrajectory(const Vehicle &ego, Action action, const prediction::Predictions &predictions);
struct Kinematics {
double s;
double v;
double a;
};
Behaviour::Kinematics getKinematics(const Vehicle &ego, const prediction::Predictions &predictions, int targetLane, double t = 5);
tl::optional<Vehicle>
getVehicleAhead(const Vehicle &ego, const prediction::Predictions &predictions, int targetLane);
tl::optional<Vehicle>
getVehicleBehind(const Vehicle &ego, const prediction::Predictions &predictions, int targetLane);
const Map &map_;
State previous_state_;
};
} // namespace behaviour