-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpath_planner.h
81 lines (66 loc) · 2.26 KB
/
path_planner.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
78
79
80
81
//
// Created by Ken Power on 16/07/2021.
//
#ifndef PATH_PLANNING_PATH_PLANNER_H
#define PATH_PLANNING_PATH_PLANNER_H
#include <vector>
#include <string>
#include "cost_function_calculator.h"
using namespace std;
enum Lane {Left, Middle, Right};
class PathPlanner
{
public:
/**
* Plan a path by deciding whether to move left, right, or stay in the same lane. A negative number indicates the
* distance in meters to move left, a positive number indicates the distance in meters to move right, 0 means keep
* moving forward.
*
* @param s
* @param d
* @param sensor_fusion
* @return distance in meters to move (left, right, or stay on same trajectory)
*/
int MoveDistance(double s, double d, const vector<vector<double>> & sensor_fusion);
/**
* Calculates if d value corresponds to left, right, or center lane.
*
* @param d
* @return
*/
int GetLane(double d);
/**
* Calculates the nearest vehicle either in front or behind the car in a given lane.
*
* @param s
* @param lane
* @param sensor_fusion
* @param direction
* @return distance and speed of the nearest vehicle
*/
vector<double> NearestVehicle(double s, int lane, vector<vector<double>> sensor_fusion, bool direction);
/**
* Decide which lane to be in for the next step of the path.
*
* @param s s value
* @param current_lane the lane the car is in now
* @param sensor_fusion sensor fusion data
* @return the lane to be in for the next step in the path, which might be the same as the current lane
*/
int ChooseLaneForNextStep(double s, int current_lane, const vector<vector<double>> & sensor_fusion);
int CurrentLane() const;
double LeadVehicleCurrentSpeed() const;
double TargetVehicleSpeed() const;
void SetTargetVehicleSpeed(double targetVehicleSpeed);
/**
* @return the current average lane scores
*/
const vector<double> & AverageLaneScores() const;
private:
int current_lane;
double lead_vehicle_current_speed = 22.352 - 0.5;
double target_vehicle_speed;
vector<double> average_lane_scores = {0, 0, 0}; // Assumes a 3-lane road
int GetNextLane(int current_lane);
};
#endif //PATH_PLANNING_PATH_PLANNER_H