SimDriver  0.1
Interface.h
1 // Copyright (c) 2020 Institute for Automotive Engineering (ika), RWTH Aachen University. All rights reserved.
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in all
11 // copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 // SOFTWARE.
20 //
21 //
22 // Created by Jens Klimke on 2020-04-07.
23 //
24 
25 
26 #ifndef AGENT_MODEL_INTERFACE_H
27 #define AGENT_MODEL_INTERFACE_H
28 
29 
30 namespace agent_model {
31 
32  static const unsigned int NOT = 32;
33  static const unsigned int NOL = 32;
34  static const unsigned int NOS = 32;
35  static const unsigned int NOH = 32;
36  static const unsigned int NORP = 2;
37  static const unsigned int NOCP = 3;
38  static const unsigned int NOA = 32;
39 
40  static const unsigned int NOTL = 32;
41 
42 
44  enum Accessibility { ACC_NOT_SET, ACC_ACCESSIBLE, ACC_NOT_ALLOWED, ACC_NOT_ACCESSIBLE };
45 
47  enum DrivingDirection { DD_FORWARDS, DD_BACKWARDS, DD_BOTH, DD_NONE, DD_NOT_SET };
48 
50  enum SignalType { SIGNAL_NOT_SET, SIGNAL_STOP, SIGNAL_TLS, SIGNAL_SPEED_LIMIT, SIGNAL_YIELD, SIGNAL_PRIORITY };
51  //For now just colors.Todo: Add different icon color combinations
53  enum TrafficLightColor { COLOR_RED, COLOR_YELLOW, COLOR_GREEN };
54  //For now just colors.Todo: Add different icon color combinations
56  enum TrafficLightIcon { ICON_OTHER, ICON_NONE, ICON_ARROW_STRAIGHT_AHEAD, ICON_ARROW_LEFT, ICON_ARROW_RIGHT };
57 
59  enum TargetPriority { TARGET_ON_PRIORITY_LANE, TARGET_ON_GIVE_WAY_LANE, TARGET_PRIORITY_NOT_SET };
60 
62  enum TargetPosition { TARGET_NOT_RELEVANT, TARGET_ON_PATH, TARGET_ON_INTERSECTION, TARGET_ON_OPPOSITE, TARGET_ON_RIGHT, TARGET_ON_LEFT };
63 
65  enum Maneuver { STRAIGHT, TURN_LEFT, TURN_RIGHT };
66 
67 
68 
70  struct Position {
71  double x;
72  double y;
73  Position(): x(0.0), y(0.0) {}
74  Position(double pX, double pY) : x(pX), y(pY) {}
75 
76  bool operator==(const Position& other)
77  {
78  return x == other.x && y == other.y;
79  }
80  };
81 
82 
83 
85  struct DynamicPosition {
86  double x;
87  double y;
88  double dx;
89  double dy;
90  };
91 
93  struct Point {
94  double distance;
95  double time;
96  double value;
97  };
98 
100  struct Dimensions {
101  double width;
102  double length;
103  };
104 
106  struct VehicleState {
107  double v;
108  double a;
109  double psi;
110  double dPsi;
111  double s;
112  double d;
113  double pedal;
114  double steering;
115  Maneuver maneuver;
116  double dsIntersection;
117 
118  };
119 
121  struct Horizon {
122  double ds[NOH];
123  double x[NOH];
124  double y[NOH];
125  double psi[NOH];
126  double kappa[NOH];
127  double egoLaneWidth[NOH];
128  double rightLaneOffset[NOH];
129  double leftLaneOffset[NOH];
131  };
132 
134  struct Lane {
135  int id;
136  double width;
137  double route;
138  double closed;
139  DrivingDirection dir;
140  Accessibility access;
142  // not defined (-1)
143  // not necessary (0) - already on target lane
144  // intended (1) - necessary, but also later possibility
145  // required (2) - last chance
146  };
147 
149  struct ControlPath {
150  double offset;
151  double factor;
152  DynamicPosition refPoints[NORP];
153  };
154 
156  struct FollowTarget {
157  double factor;
158  double lane;
159  double distance;
160  double velocity;
161  };
162 
164  struct Signal {
165  unsigned int id;
166  double ds;
167  SignalType type;
168  double value;
169  TrafficLightColor color;
170  TrafficLightIcon icon;
171  bool subsignal;
173  };
174 
175 
177  struct Target {
178  unsigned int id;
179  double ds;
181  double v;
182  double a;
183  double d;
184  double psi;
185  int lane;
187  double dsIntersection;
188  TargetPriority priority;
189  TargetPosition position;
190  };
191 
194  unsigned int id;
195  double position;
196  double standingTime;
197  };
198 
200  struct Decisions {
208  };
209 
212  double local;
213  double prediction;
214  };
215 
217  struct ConsciousStop {
218  double ds;
219  double dsMax;
220  bool standing;
221  bool priority;
222  bool give_way;
223  };
224 
227  FollowTarget targets[2];
228  bool standing;
229  };
230 
233  ControlPath paths[NOCP];
234  };
235 
237  struct Conscious {
242  };
243 
245  struct Subconscious {
246  double a;
247  double dPsi;
248  double kappa;
249  double pedal;
250  double steering;
251  };
252 
254  struct MemoryVehicle {
255  double s;
256  };
257 
259  struct MemoryLateral {
260  double time;
261  double startTime;
262  double distance;
263  double startDistance;
264  double offset;
265  };
266 
270  int decision;
271  double startTime;
272  };
273 
276  double thwMax;
277  double delta;
278  double deltaPred;
279  double a;
280  double b;
281  double vScale;
282  double ayMax;
283  double vComfort;
284  };
285 
288  double timeHeadway;
289  double dsStopped;
290  double thwMax;
291  };
292 
297  };
298 
301  double thw[NORP];
302  double dsMin[NORP];
303  double P[NORP];
304  double D[NORP];
305  };
306 
309  double dsGap;
310  double TMax;
311  double dsMax;
312  double T;
313  double tSign;
314  double vStopped;
316  };
317 
320  double bSafe;
321  double aThreshold;
323  double time;
324  };
325 
327  struct Input {
330  Signal signals[NOS];
331  Lane lanes[NOL];
332  Target targets[NOT];
333  };
334 
336  struct State {
337  double simulationTime;
341  double aux[NOA];
342  };
343 
345  struct Memory {
347  double velocity;
350  };
351 
353  struct Parameters {
360  };
361 
362 
367 class Interface {
368 
369 public:
370 
371  typedef agent_model::Input Input;
372  typedef agent_model::State State;
373  typedef agent_model::Memory Memory;
375 
376 
377 protected:
378 
379  Input _input{};
380  State _state{};
381  Memory _memory{};
382  Parameters _param{};
383 
384 public:
385 
387  Interface() = default;
388 
390  virtual ~Interface() = default;
391 
392 
397  Input *getInput() {
398  return &_input;
399  }
400 
405  const Input *getInput() const {
406  return &_input;
407  }
408 
409 
414  State *getState() {
415  return &_state;
416  }
417 
422  const State *getState() const {
423  return &_state;
424  }
425 
426 
431  Memory *getMemory() {
432  return &_memory;
433  }
434 
439  const Memory *getMemory() const {
440  return &_memory;
441  }
442 
443 
448  Parameters *getParameters() {
449  return &_param;
450  }
451 
456  const Parameters *getParameters() const {
457  return &_param;
458  }
459 
460 
461 
462 };
463 
464 } // namespace
465 
466 #endif // AGENT_MODEL_INTERFACE_H
double dPsi
Desired yaw rate. (in rad/s)
Definition: Interface.h:247
double time
Time to perform a lane change.
Definition: Interface.h:323
Parameters * getParameters()
Definition: Interface.h:448
Dimensions size
Size of the ego vehicle.
Definition: Interface.h:295
Definition: Interface.h:177
double velocity
The absolute velocity of the target to be followed. (in m/s)
Definition: Interface.h:160
double a
Desired acceleration. (in m/s^2)
Definition: Interface.h:246
DecisionStopping signal
The decision information caused by a signal.
Definition: Interface.h:204
double thwMax
The time headway the driver shall earliest react to follow (in s)
Definition: Interface.h:290
Definition: Interface.h:156
State * getState()
Definition: Interface.h:414
Accessibility access
The accessibility of the lane from the ego lane. - true if type driving.
Definition: Interface.h:140
int lane
Lane ID of the actual lane of the target relative to driver's lane.
Definition: Interface.h:185
const Memory * getMemory() const
Definition: Interface.h:439
Definition: Interface.h:232
double factor
The influence of the target.
Definition: Interface.h:157
double d
Lateral offset of the target in its corresponding lane. (in m)
Definition: Interface.h:183
double a
The acceleration of the vehicle in x direction. (in m/s^2)
Definition: Interface.h:108
Definition: Interface.h:193
double offset
The offset to be reached.
Definition: Interface.h:264
bool standing
A flag to define whether the driver wants to keep the vehicle in standstill.
Definition: Interface.h:228
SignalType type
Type of the signal.
Definition: Interface.h:167
Conscious conscious
Conscious states.
Definition: Interface.h:339
TrafficLightIcon icon
Icon/Shape of the traffic light.
Definition: Interface.h:170
double offset
The lateral offset from the reference line to be controlled to. (in m)
Definition: Interface.h:150
Definition: Interface.h:319
Definition: Interface.h:134
double standingTime
The time, the driver shall stand at the stop.
Definition: Interface.h:196
Definition: Interface.h:287
double simulationTime
The actual simulation time.
Definition: Interface.h:337
ParameterFollowing follow
Parameters for follow components.
Definition: Interface.h:358
double position
The absolute longitudinal position of the stop.
Definition: Interface.h:195
double bSafe
A safe deceleration.
Definition: Interface.h:320
int decision
The decisions to which lane the driver wants to change to.
Definition: Interface.h:270
double s
Absolute travelled distance since the last reset. (in m)
Definition: Interface.h:255
double startTime
The start time of the lateral motion.
Definition: Interface.h:261
const Parameters * getParameters() const
Definition: Interface.h:456
Definition: Interface.h:226
bool sign_is_in_use
indicates that subsign is in use (all paired TLS signals are out of service)
Definition: Interface.h:172
double ayMax
Maximum lateral acceleration (in m/s^2)
Definition: Interface.h:282
double time
The time to reach the lateral offset.
Definition: Interface.h:260
Definition: Interface.h:106
Maneuver maneuver
The general classification of the vehicle's path during the scenario.
Definition: Interface.h:115
double a
Absolute acceleration of the target. (in m/s^2)
Definition: Interface.h:182
double pedalDuringStanding
The pedal value, the driver controls during standing.
Definition: Interface.h:315
double vComfort
Maximum personal comfortable velocity (in m/s)
Definition: Interface.h:283
Definition: Interface.h:100
Definition: Interface.h:149
const Input * getInput() const
Definition: Interface.h:405
double steering
Desired steering angle.
Definition: Interface.h:250
double y
The y ordinate. (in m)
Definition: Interface.h:87
double v
The velocity of the vehicle in x direction. (in m/s)
Definition: Interface.h:107
Memory * getMemory()
Definition: Interface.h:431
double local
The local velocity. (in m/s)
Definition: Interface.h:212
double x
The x ordinate. (in m)
Definition: Interface.h:71
double velocity
The local maximum velocity. (in m/s)
Definition: Interface.h:347
bool priority
A flag to define if the driver drives on a priority lane.
Definition: Interface.h:221
ConsciousLateral lateral
A class to store the internal state for the conscious/lateral component.
Definition: Interface.h:241
unsigned int id
Unique ID of the target. id=0 indicates that the target is not defined in the array position...
Definition: Interface.h:178
Horizon horizon
The horizon.
Definition: Interface.h:329
double route
Distance on the lane until the lane splits from the current route. (in m) -1 if not set...
Definition: Interface.h:137
double steering
The actual steering value [-1..1]. Negative values define left turns.
Definition: Interface.h:114
ParameterStopping stop
Parameters for stop components.
Definition: Interface.h:356
Definition: Interface.h:353
Subconscious subconscious
Subconscious states.
Definition: Interface.h:340
double dy
The derivative of the y component. (in m/s)
Definition: Interface.h:89
double x
The x ordinate. (in m)
Definition: Interface.h:86
double y
The y ordinate. (in m)
Definition: Interface.h:72
double closed
Distance on the lane until the lane is closed. (in m) -1 if not set.
Definition: Interface.h:138
Definition: Interface.h:245
Position xy
Relative position of the target relative to the driver position and heading.
Definition: Interface.h:180
double distance
The distance to the target to be followed. (in m)
Definition: Interface.h:159
double b
The maximum deceleration (in m/s^2)
Definition: Interface.h:280
double dsMax
Maximum distance to react for stopping.
Definition: Interface.h:311
double dsIntersection
Distance along s to the intersection (if target is approaching an intersection)
Definition: Interface.h:187
The agent model interface. The class implements the data structure of the agent model, consisting of input, state, memory and parameters.
Definition: Interface.h:367
TargetPriority priority
Priority of the target's lane. Used to determine right of way.
Definition: Interface.h:188
double dx
The derivative of the x component. (in m/s)
Definition: Interface.h:88
Definition: Interface.h:164
Definition: Interface.h:200
double psi
The yaw angle of the vehicle which is the angle between the vehicle x axis and heading of the current...
Definition: Interface.h:109
double dsIntersection
Distance along s to the intersection (if ego is approaching an intersection)
Definition: Interface.h:116
double prediction
The prediction mean velocity. (in m/s)
Definition: Interface.h:213
bool give_way
A flag to define if the driver drives on a give way lane.
Definition: Interface.h:222
Definition: Interface.h:121
Definition: Interface.h:336
double length
The length of an object. (in m)
Definition: Interface.h:102
int id
Unique ID of the signal. The id is not just an identifier but also specifies the position of the lane...
Definition: Interface.h:135
int switchLane
The lane to be switched to.
Definition: Interface.h:269
const State * getState() const
Definition: Interface.h:422
Definition: Interface.h:254
ParameterVelocityControl velocity
Parameters for velocity components.
Definition: Interface.h:357
DecisionStopping lane
The decision information caused by a lane change.
Definition: Interface.h:207
Definition: Interface.h:300
double time
The relative time at which the value applies. (in s)
Definition: Interface.h:95
TargetPosition position
Area in junction of target. Used to determine right of way.
Definition: Interface.h:189
DrivingDirection dir
The driving direction of the lane related to the ego direction.
Definition: Interface.h:139
MemoryLaneChange laneChange
The memory for lane change components.
Definition: Interface.h:349
double value
The value of the point.
Definition: Interface.h:96
double destinationPoint
s coordinate of destination point (in m) -1 if not set
Definition: Interface.h:130
int lane_change
Flag if lane change is.
Definition: Interface.h:141
Definition: Interface.h:259
MemoryLateral lateral
The memory for lateral control components.
Definition: Interface.h:348
double factor
A factor to describe the influence of the point.
Definition: Interface.h:151
double pedal
Desired pedal value.
Definition: Interface.h:249
Definition: Interface.h:327
double distance
The distance at which the value applies. (in m)
Definition: Interface.h:94
Definition: DistanceTimeInterval.h:33
double deltaPred
The power for the predictive speed reaction.
Definition: Interface.h:278
double s
The distance, the vehicle travelled since the last reset. (in m)
Definition: Interface.h:111
double ds
Distance to the sign from the current position along the reference line. (in m)
Definition: Interface.h:166
ConsciousStop stop
A class to store the internal state for the conscious/stop component.
Definition: Interface.h:239
double dsGap
The gap between vehicle front and stop sign during a stop.
Definition: Interface.h:309
double psi
Relative yaw angle of the target vehicle to the ego yaw angle. (in rad)
Definition: Interface.h:184
double vScale
A scale factor to scale up or down the speed limit.
Definition: Interface.h:281
Definition: Interface.h:237
Input * getInput()
Definition: Interface.h:397
double startTime
The start time of the lane change. (in s)
Definition: Interface.h:271
double pedal
The actual pedal value [-1..1]. Negative values define a brake pedal.
Definition: Interface.h:113
Definition: Interface.h:85
Definition: Interface.h:70
Definition: Interface.h:308
double vStopped
The velocity at which the driver expects the vehicle to have stopped.
Definition: Interface.h:314
bool subsignal
if true sign is subsignal to TLS and only valid in certain situations
Definition: Interface.h:171
double width
Width of the lane (in m) -1 if not set.
Definition: Interface.h:136
double dsMax
The reference distance at which the driver decides to stop (in m)
Definition: Interface.h:219
Definition: Interface.h:217
double timeHeadway
The time headway the driver tries to reach during following (in s)
Definition: Interface.h:288
double startDistance
The start distance of the lateral motion.
Definition: Interface.h:263
unsigned int id
The ID of the stop.
Definition: Interface.h:194
double thwMax
The maximum time headway the driver starts to react (in s)
Definition: Interface.h:276
Definition: Interface.h:268
double d
The lateral offset of the vehicle to the current reference line of the track (e.g. lane center). (in m)
Definition: Interface.h:112
Dimensions size
Width and length of the target.
Definition: Interface.h:186
DecisionStopping target
The decision information caused by a target.
Definition: Interface.h:205
double TMax
Maximum time headway to react for stopping.
Definition: Interface.h:310
double ds
Distance along s to the target center point from the ego driver position. (in m)
Definition: Interface.h:179
double ds
The actual distance to the stop point. (in m)
Definition: Interface.h:218
ConsciousFollow follow
A class to store the internal state for the conscious/follow component.
Definition: Interface.h:240
Decisions decisions
Decision states.
Definition: Interface.h:338
double v
Absolute velocity of the target. (in m/s)
Definition: Interface.h:181
Position pos
The driver's position referenced to the center of the vehicle box defined by size ...
Definition: Interface.h:296
Definition: Interface.h:294
ParameterVehicle vehicle
Parameters for velocity components.
Definition: Interface.h:354
MemoryVehicle vehicle
The memory for vehicle states.
Definition: Interface.h:346
unsigned int id
Unique ID of the signal.
Definition: Interface.h:165
double delta
The power for the local speed reaction (see delta in IDM: https://en.wikipedia.org/wiki/Intelligent_d...
Definition: Interface.h:277
double kappa
Desired curvature. (in 1/m)
Definition: Interface.h:248
int laneChangeInt
The intention to perform a lane change. The sign defines the direction. The value defines the number ...
Definition: Interface.h:201
double T
A time headway to parameterize the dynamics of the approaching.
Definition: Interface.h:312
Definition: Interface.h:93
TrafficLightColor color
Color of the light bulb.
Definition: Interface.h:169
ParameterSteering steering
Parameters for steering components.
Definition: Interface.h:359
int laneChangeDec
The decision to perform a lane change. The sign defines the direction. The value defines the number o...
Definition: Interface.h:202
double tSign
The time the driver stop at a stop sign.
Definition: Interface.h:313
Point lateral
The decision to move to a defined lateral offset within a defined distance or time (mode=0: distance...
Definition: Interface.h:203
double aThreshold
Acceleration threshold.
Definition: Interface.h:321
double distance
The distance to reach the lateral offset.
Definition: Interface.h:262
double width
The width of an object. (in m)
Definition: Interface.h:101
VehicleState vehicle
The vehicle state.
Definition: Interface.h:328
Definition: Interface.h:211
double a
The maximum acceleration (in m/s^2)
Definition: Interface.h:279
double lane
Lane ID of the actual lane of the target relative to driver's lane.
Definition: Interface.h:158
double politenessFactor
Politeness factor.
Definition: Interface.h:322
ConsciousVelocity velocity
A class to store the internal state for the conscious/velocity component.
Definition: Interface.h:238
bool standing
A flag to define if the driver has stopped for the desired stop.
Definition: Interface.h:220
Definition: Interface.h:345
DecisionStopping destination
The decision information caused by a destination.
Definition: Interface.h:206
double value
Value of the signal.
Definition: Interface.h:168
Definition: Interface.h:275
ParameterLaneChange laneChange
Parameters for lane change components.
Definition: Interface.h:355
double dsStopped
The distance to the controlled target when stopped.
Definition: Interface.h:289
double dPsi
The time derivative of the yaw angle (yaw rate). (in rad/s)
Definition: Interface.h:110