1 package org.opentrafficsim.road.gtu.lane.perception.headway; 2 3 import org.djunits.value.vdouble.scalar.Acceleration; 4 import org.djunits.value.vdouble.scalar.Length; 5 import org.djunits.value.vdouble.scalar.Speed; 6 import org.opentrafficsim.base.parameters.Parameters; 7 import org.opentrafficsim.core.gtu.GtuException; 8 import org.opentrafficsim.core.gtu.GtuType; 9 import org.opentrafficsim.core.network.route.Route; 10 import org.opentrafficsim.road.gtu.lane.tactical.following.CarFollowingModel; 11 import org.opentrafficsim.road.network.speed.SpeedLimitInfo; 12 13 /** 14 * Container for a reference to information about a (lane based) GTU and a headway. The Headway can store information about GTUs 15 * or objects ahead of the reference GTU, behind the reference GTU, or (partially) parallel to the reference GTU. In addition to 16 * the (perceived) headway, several other pieces of information can be stored, such as (perceived) speed, (perceived) 17 * acceleration, (perceived) turn indicators, and (perceived) braking lights. <br> 18 * This particular version has only limited behavioral information about the observed GTU.<br> 19 * Special care must be taken in curves when perceiving headway of a GTU or object on an adjacent lane.The question is whether 20 * we perceive the parallel or ahead/behind based on a line perpendicular to the front/back of the GTU (rectangular), or 21 * perpendicular to the center line of the lane (wedge-shaped in case of a curve). The difficulty of a wedge-shaped situation is 22 * that reciprocity might be violated: in case of a clothoid, for instance, it is not sure that the point on the center line 23 * when projected from lane 1 to lane 2 is the same as the projection from lane 2 to lane 1. The same holds for shapes with 24 * sharp bends. Therefore, algorithms implementing headway should only project the <i>reference point</i> of the reference GTU 25 * on the center line of the adjacent lane, and then calculate the forward position and backward position on the adjacent lane 26 * based on the reference point. Still, our human perception of what is parallel and what not, is not reflected by fractional 27 * positions. 28 * <p> 29 * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br> 30 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>. 31 * </p> 32 * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a> 33 * @author <a href="https://github.com/peter-knoppers">Peter Knoppers</a> 34 * @author <a href="https://github.com/wjschakel">Wouter Schakel</a> 35 */ 36 public class HeadwayGtuSimple extends AbstractHeadwayGtu 37 { 38 /** */ 39 private static final long serialVersionUID = 20160527L; 40 41 /** 42 * Construct a new Headway information object, for a moving GTU ahead of us or behind us. 43 * @param id the id of the GTU for comparison purposes, can not be null. 44 * @param gtuType the perceived GTU Type, or null if unknown. 45 * @param distance if this constructor is used, distance cannot be null. 46 * @param length if this constructor is used, length cannot be null. 47 * @param width the (perceived) width of the other object; can not be null. 48 * @param speed the (perceived) speed of the other object; can be null if unknown. 49 * @param acceleration the (perceived) acceleration of the other object; can be null if unknown. 50 * @param desiredSpeed desired speed 51 * @param gtuStatus the observable characteristics of the GTU. 52 * @throws GtuException when id is null, objectType is null, or parameters are inconsistent 53 */ 54 public HeadwayGtuSimple(final String id, final GtuType gtuType, final Length distance, final Length length, 55 final Length width, final Speed speed, final Acceleration acceleration, final Speed desiredSpeed, 56 final GtuStatus... gtuStatus) throws GtuException 57 { 58 super(id, gtuType, distance, true, length, width, speed, acceleration, desiredSpeed, gtuStatus); 59 } 60 61 /** 62 * Construct a new Headway information object, for a non-moving GTU ahead of us or behind us. 63 * @param id the id of the GTU for comparison purposes, can not be null. 64 * @param gtuType the perceived GTU Type, or null if unknown. 65 * @param distance the distance to the other Gtu; if this constructor is used, distance cannot be null. 66 * @param length if this constructor is used, length cannot be null. 67 * @param width the (perceived) width of the other object; can not be null. 68 * @param desiredSpeed desired speed 69 * @param gtuStatus the observable characteristics of the GTU. 70 * @throws GtuException when id is null, or parameters are inconsistent 71 */ 72 public HeadwayGtuSimple(final String id, final GtuType gtuType, final Length distance, final Length length, 73 final Length width, final Speed desiredSpeed, final GtuStatus... gtuStatus) throws GtuException 74 { 75 super(id, gtuType, distance, true, length, width, desiredSpeed, gtuStatus); 76 } 77 78 /** 79 * Construct a new Headway information object, for a moving GTU parallel with us. 80 * @param id the id of the GTU for comparison purposes, can not be null. 81 * @param gtuType the perceived GTU Type, or null if unknown. 82 * @param overlapFront the front-front distance to the other Gtu; if this constructor is used, this value cannot be null. 83 * @param overlap the 'center' overlap with the other Gtu; if this constructor is used, this value cannot be null. 84 * @param overlapRear the rear-rear distance to the other Gtu; if this constructor is used, this value cannot be null. 85 * @param length if this constructor is used, length cannot be null. 86 * @param width the (perceived) width of the other object; can not be null. 87 * @param speed the (perceived) speed of the other Gtu; can be null if unknown. 88 * @param acceleration the (perceived) acceleration of the other Gtu; can be null if unknown. 89 * @param desiredSpeed desired speed 90 * @param gtuStatus the observable characteristics of the GTU. 91 * @throws GtuException when id is null, or parameters are inconsistent 92 */ 93 @SuppressWarnings("checkstyle:parameternumber") 94 public HeadwayGtuSimple(final String id, final GtuType gtuType, final Length overlapFront, final Length overlap, 95 final Length overlapRear, final Length length, final Length width, final Speed speed, 96 final Acceleration acceleration, final Speed desiredSpeed, final GtuStatus... gtuStatus) throws GtuException 97 { 98 super(id, gtuType, overlapFront, overlap, overlapRear, true, length, width, speed, acceleration, desiredSpeed, 99 gtuStatus); 100 } 101 102 /** 103 * Construct a new Headway information object, for a non-moving GTU parallel with us. 104 * @param id the id of the GTU for comparison purposes, can not be null. 105 * @param gtuType the perceived GTU Type, or null if unknown. 106 * @param overlapFront the front-front distance to the other Gtu; if this constructor is used, this value cannot be null. 107 * @param overlap the 'center' overlap with the other Gtu; if this constructor is used, this value cannot be null. 108 * @param overlapRear the rear-rear distance to the other Gtu; if this constructor is used, this value cannot be null. 109 * @param length if this constructor is used, length cannot be null. 110 * @param width the (perceived) width of the other object; can not be null. 111 * @param desiredSpeed desired speed 112 * @param gtuStatus the observable characteristics of the GTU. 113 * @throws GtuException when id is null, or parameters are inconsistent 114 */ 115 public HeadwayGtuSimple(final String id, final GtuType gtuType, final Length overlapFront, final Length overlap, 116 final Length overlapRear, final Length length, final Length width, final Speed desiredSpeed, 117 final GtuStatus... gtuStatus) throws GtuException 118 { 119 super(id, gtuType, overlapFront, overlap, overlapRear, true, length, width, desiredSpeed, gtuStatus); 120 } 121 122 @Override 123 public final CarFollowingModel getCarFollowingModel() 124 { 125 throw new UnsupportedOperationException("HeadwayGtuSimple does not support the getCarFollowingModel() method."); 126 } 127 128 @Override 129 public final Parameters getParameters() 130 { 131 throw new UnsupportedOperationException("HeadwayGtuSimple does not support the getParameters() method."); 132 } 133 134 @Override 135 public final SpeedLimitInfo getSpeedLimitInfo() 136 { 137 throw new UnsupportedOperationException("HeadwayGtuSimple does not support the getSpeedLimitInfo() method."); 138 } 139 140 @Override 141 public final Route getRoute() 142 { 143 return null; 144 } 145 146 @Override 147 public final AbstractHeadwayGtu moved(final Length headway, final Speed speed, final Acceleration acceleration) 148 { 149 try 150 { 151 return new HeadwayGtuSimple(getId(), getGtuType(), headway, getLength(), getWidth(), speed, acceleration, 152 getDesiredSpeed(), getGtuStatus()); 153 } 154 catch (GtuException exception) 155 { 156 // input should be consistent 157 throw new RuntimeException("Exception while copying Headway GTU.", exception); 158 } 159 } 160 161 @Override 162 public final String toString() 163 { 164 return "HeadwayGtuSimple [length=" + super.getLength() + "]"; 165 } 166 167 }