1 package org.opentrafficsim.core.gtu; 2 3 import java.awt.Color; 4 import java.io.Serializable; 5 6 import org.djunits.value.vdouble.scalar.Acceleration; 7 import org.djunits.value.vdouble.scalar.Length; 8 import org.djunits.value.vdouble.scalar.Speed; 9 import org.opentrafficsim.core.dsol.OTSDEVSSimulatorInterface; 10 import org.opentrafficsim.core.gtu.behavioralcharacteristics.BehavioralCharacteristics; 11 import org.opentrafficsim.core.gtu.plan.operational.OperationalPlan; 12 import org.opentrafficsim.core.gtu.plan.strategical.StrategicalPlanner; 13 import org.opentrafficsim.core.gtu.plan.tactical.TacticalPlanner; 14 15 import nl.tudelft.simulation.dsol.animation.Locatable; 16 import nl.tudelft.simulation.event.EventProducerInterface; 17 import nl.tudelft.simulation.event.EventType; 18 import nl.tudelft.simulation.immutablecollections.ImmutableMap; 19 import nl.tudelft.simulation.immutablecollections.ImmutableSet; 20 21 /** 22 * Generalized Travel Unit. <br> 23 * A GTU is an object (person, car, ship) that can travel over the infrastructure. It has a (directed) location, dimensions, and 24 * some properties that all GTUs share. The GTU is not bound to any infrastructure and can travel freely in the world. <br> 25 * For its movement, a GTU uses an OperationalPlan, which indicates a shape in the world with a speed profile that the GTU will 26 * use to move. The OperationalPlan can be updated or replaced, for which a tactical planner is responsible. A tactical plan can 27 * for instance be for a car to change two lanes to the left during the next 200 m to be able to make a left turn in 200 m. The 28 * operational plans are then the implementation of segments of the movement (time, location, speed, acceleration) that the car 29 * will make to drive on the road and (safely) make the lane changes. On the highest level, a StrategicPlan puts boundary 30 * conditions on the tactical plans. The strategic plan contains for instance the destination we want to reach and possibly some 31 * constraints on solutions that the tactical plans have to comply with. 32 * <p> 33 * Copyright (c) 2013-2016 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br> 34 * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>. 35 * <p> 36 * @version $Revision: 2838 $, $LastChangedDate: 2016-12-11 14:07:37 +0100 (Sun, 11 Dec 2016) $, by $Author: averbraeck $, 37 * initial version May 15, 2014 <br> 38 * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a> 39 * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a> 40 */ 41 public interface GTU extends Locatable, Serializable, EventProducerInterface 42 { 43 /** @return the id of the GTU */ 44 String getId(); 45 46 /** @return the maximum length of the GTU (parallel with driving direction). */ 47 Length getLength(); 48 49 /** @return the maximum width of the GTU (perpendicular to driving direction). */ 50 Length getWidth(); 51 52 /** @return the maximum speed of the GTU, in the direction of movement. */ 53 Speed getMaximumSpeed(); 54 55 /** @return the maximum acceleration of the GTU, in the linear direction. */ 56 Acceleration getMaximumAcceleration(); 57 58 /** @return the maximum deceleration of the GTU, in the linear direction, stored as a negative number. */ 59 Acceleration getMaximumDeceleration(); 60 61 /** @return the type of GTU, e.g. TruckType, CarType, BusType. */ 62 GTUType getGTUType(); 63 64 /** @return the simulator of the GTU. */ 65 OTSDEVSSimulatorInterface getSimulator(); 66 67 /** @return the reference position of the GTU, by definition (0, 0, 0). */ 68 RelativePosition getReference(); 69 70 /** @return the front position of the GTU, relative to its reference point. */ 71 RelativePosition getFront(); 72 73 /** @return the rear position of the GTU, relative to its reference point. */ 74 RelativePosition getRear(); 75 76 /** @return the center position of the GTU, relative to its reference point. */ 77 RelativePosition getCenter(); 78 79 /** @return the contour points of the GTU. */ 80 ImmutableSet<RelativePosition> getContourPoints(); 81 82 /** @return the positions for this GTU, but not the contour points. */ 83 ImmutableMap<RelativePosition.TYPE, RelativePosition> getRelativePositions(); 84 85 /** @return the current speed of the GTU, along the direction of movement. */ 86 Speed getSpeed(); 87 88 /** @return the current acceleration of the GTU, along the direction of movement. */ 89 Acceleration getAcceleration(); 90 91 /** @return Length; the current odometer value. */ 92 Length getOdometer(); 93 94 /** @return Behavioral characteristics. */ 95 BehavioralCharacteristics getBehavioralCharacteristics(); 96 97 /** 98 * @return StrategicalPlanner; the planner responsible for the overall 'mission' of the GTU, usually indicating where it 99 * needs to go. It operates by instantiating tactical planners to do the work. 100 */ 101 StrategicalPlanner getStrategicalPlanner(); 102 103 /** @return TacticalPlanner; the current tactical planner that can generate an operational plan */ 104 TacticalPlanner getTacticalPlanner(); 105 106 /** @return the current operational plan for the GTU. */ 107 OperationalPlan getOperationalPlan(); 108 109 /** @return the status of the turn indicator. */ 110 TurnIndicatorStatus getTurnIndicatorStatus(); 111 112 /** 113 * Set the status of the turn indicator. 114 * @param turnIndicatorStatus the new status of the turn indicator. 115 * @throws GTUException when GTUType does not have a turn indicator 116 */ 117 void setTurnIndicatorStatus(TurnIndicatorStatus turnIndicatorStatus) throws GTUException; 118 119 /** Destroy the GTU from the simulation and animation. */ 120 void destroy(); 121 122 /** 123 * Return the base color of the GTU (not the state-based color). 124 * @return Color; the base color of the GTU (not the state-based color) 125 */ 126 Color getBaseColor(); 127 128 /** 129 * The event type for pub/sub indicating the initialization of a new GTU. <br> 130 * Payload: [String id, DirectedPoint initialPosition, Length length, Length width, Color gtuBaseColor] 131 */ 132 EventType INIT_EVENT = new EventType("GTU.INIT"); 133 134 /** 135 * The event type for pub/sub indicating a move. <br> 136 * Payload: [String id, DirectedPoint position, Speed speed, Acceleration acceleration, TurnIndicatorStatus 137 * turnIndicatorStatus, Length odometer] 138 */ 139 EventType MOVE_EVENT = new EventType("GTU.MOVE"); 140 141 /** 142 * The event type for pub/sub indicating destruction of the GTU. <br> 143 * Payload: [String id, DirectedPoint lastPosition, Length odometer] 144 */ 145 EventType DESTROY_EVENT = new EventType("GTU.DESTROY"); 146 }