-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleDriver.h
More file actions
133 lines (99 loc) · 3.68 KB
/
SimpleDriver.h
File metadata and controls
133 lines (99 loc) · 3.68 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/***************************************************************************
file : SimpleDriver.h
copyright : (C) 2007 Daniele Loiacono
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef SIMPLEDRIVER_H_
#define SIMPLEDRIVER_H_
#include <iostream>
#include <cmath>
#include "BaseDriver.h"
#include "CarState.h"
#include "CarControl.h"
#include "SimpleParser.h"
#include "WrapperBaseDriver.h"
#define PI 3.14159265
using namespace std;
class SimpleDriver : public WrapperBaseDriver
{
public:
// Constructor
SimpleDriver(){stuck=0;clutch=0.0;};
// SimpleDriver implements a simple and heuristic controller for driving
virtual CarControl wDrive(CarState cs, CNeuralNet* brain);
// Print a shutdown message
virtual void onShutdown();
// Print a restart message
virtual void onRestart();
// Initialization of the desired angles for the rangefinders
virtual void init(float *angles);
// Variables for info about the car state
float distRaced;
float damage;
private:
/* Gear Changing Constants*/
// RPM values to change gear
static const int gearUp[6];
static const int gearDown[6];
/* Stuck constants*/
// How many time steps the controller wait before recovering from a stuck position
static const int stuckTime;
// When car angle w.r.t. track axis is grather tan stuckAngle, the car is probably stuck
static const float stuckAngle;
/* Steering constants*/
// Angle associated to a full steer command
static const float steerLock;
// Min speed to reduce steering command
static const float steerSensitivityOffset;
// Coefficient to reduce steering command at high speed (to avoid loosing the control)
static const float wheelSensitivityCoeff;
/* Accel and Brake Constants*/
// max speed allowed
static const float maxSpeed;
// Min distance from track border to drive at max speed
static const float maxSpeedDist;
// pre-computed sin5
static const float sin5;
// pre-computed cos5
static const float cos5;
/* ABS Filter Constants */
// Radius of the 4 wheels of the car
static const float wheelRadius[4];
// min slip to prevent ABS
static const float absSlip;
// range to normalize the ABS effect on the brake
static const float absRange;
// min speed to activate ABS
static const float absMinSpeed;
/* Clutch constants */
static const float clutchMax;
static const float clutchDelta;
static const float clutchRange;
static const float clutchDeltaTime;
static const float clutchDeltaRaced;
static const float clutchDec;
static const float clutchMaxModifier;
static const float clutchMaxTime;
// counter of stuck steps
int stuck;
// current clutch
float clutch;
// Solves the gear changing subproblems
int getGear(CarState &cs);
// Solves the steering subproblems
float getSteer(CarState &cs);
// Solves the gear changing subproblems
float getAccel(CarState &cs);
// Apply an ABS filter to brake command
float filterABS(CarState &cs,float brake);
// Solves the clucthing subproblems
void clutching(CarState &cs, float &clutch);
};
#endif /*SIMPLEDRIVER_H_*/