1 package org.opentrafficsim.road.gtu.lane.tactical.lmrs;
2
3 import org.djunits.value.vdouble.scalar.Length;
4 import org.djunits.value.vdouble.scalar.Speed;
5 import org.opentrafficsim.base.parameters.ParameterException;
6 import org.opentrafficsim.base.parameters.Parameters;
7 import org.opentrafficsim.core.gtu.plan.operational.OperationalPlanException;
8 import org.opentrafficsim.road.gtu.lane.LaneBasedGtu;
9 import org.opentrafficsim.road.gtu.lane.perception.FilteredIterable;
10 import org.opentrafficsim.road.gtu.lane.perception.LanePerception;
11 import org.opentrafficsim.road.gtu.lane.perception.RelativeLane;
12 import org.opentrafficsim.road.gtu.lane.perception.categories.IntersectionPerception;
13 import org.opentrafficsim.road.gtu.lane.perception.headway.HeadwayTrafficLight;
14 import org.opentrafficsim.road.gtu.lane.plan.operational.SimpleOperationalPlan;
15 import org.opentrafficsim.road.gtu.lane.tactical.following.CarFollowingModel;
16 import org.opentrafficsim.road.gtu.lane.tactical.util.TrafficLightUtil;
17 import org.opentrafficsim.road.network.speed.SpeedLimitInfo;
18
19
20
21
22
23
24
25
26
27
28 public class AccelerationTrafficLights implements AccelerationIncentive
29 {
30
31
32 @Override
33 public final void accelerate(final SimpleOperationalPlan simplePlan, final RelativeLane lane, final Length mergeDistance,
34 final LaneBasedGtu gtu, final LanePerception perception, final CarFollowingModel carFollowingModel,
35 final Speed speed, final Parameters params, final SpeedLimitInfo speedLimitInfo)
36 throws ParameterException, OperationalPlanException
37 {
38 Iterable<HeadwayTrafficLight> it =
39 perception.getPerceptionCategory(IntersectionPerception.class).getTrafficLights(lane);
40 if (!lane.isCurrent() && mergeDistance.gt0())
41 {
42 it = new FilteredIterable<>(it, (
43 trafficLight
44 ) ->
45 { return trafficLight.getDistance().gt(mergeDistance); });
46 }
47 it = onRoute(it, gtu);
48 simplePlan.minimizeAcceleration(
49 TrafficLightUtil.respondToTrafficLights(params, it, carFollowingModel, speed, speedLimitInfo));
50 }
51
52
53 @Override
54 public final String toString()
55 {
56 return "AccelerationTrafficLights";
57 }
58
59 }