1 package org.opentrafficsim.road.gtu.lane;
2
3 import org.djunits.value.vdouble.scalar.Acceleration;
4 import org.djunits.value.vdouble.scalar.Duration;
5 import org.djunits.value.vdouble.scalar.Speed;
6 import org.opentrafficsim.core.network.Network;
7
8
9
10
11
12
13
14
15
16
17
18 public class AccelerationChecker extends AbstractLaneBasedMoveChecker
19 {
20
21
22 private final Acceleration min;
23
24
25 private final Acceleration max;
26
27
28 private final Speed minSpeed;
29
30
31
32
33
34 public AccelerationChecker(final Network network)
35 {
36 this(network, Acceleration.instantiateSI(-10.0), Acceleration.instantiateSI(5), Speed.instantiateSI(2.5));
37 }
38
39
40
41
42
43
44
45
46 public AccelerationChecker(final Network network, final Acceleration min, final Acceleration max, final Speed minSpeed)
47 {
48 super(network);
49 this.min = min;
50 this.max = max;
51 this.minSpeed = minSpeed;
52 }
53
54
55 @Override
56 public void checkMove(final LaneBasedGtu gtu) throws Exception
57 {
58 Acceleration a = gtu.getOperationalPlan().getAcceleration(Duration.ZERO);
59 if (gtu.getOperationalPlan().getSpeed(Duration.ZERO).si > this.minSpeed.si
60 && (a.si < this.min.si || a.si > this.max.si))
61 {
62 gtu.getSimulator().getLogger().always().error("GTU: {} acceleration out of bounds ({}, {})", this.min, this.max);
63 }
64 }
65
66 }