Class GtuSpawner
java.lang.Object
org.opentrafficsim.road.gtu.generator.GtuSpawner
Simple class to spawn GTUs.
Copyright (c) 2024-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Wouter Schakel, Christoph Thees
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionsetBookkeeping(LaneBookkeeping bookkeeping) Sets how lane bookkeeping at lane changes is done.setErrorHandler(GtuErrorHandler errorHandler) Sets the error handler.setNoLaneChangeDistance(Length noLaneChangeDistance) Sets no lane change distance.setStream(nl.tudelft.simulation.jstats.streams.StreamInterface stream) Sets random stream.setUseDefaultGtuTemplate(BiFunction<GtuType, nl.tudelft.simulation.jstats.streams.StreamInterface, Optional<GtuTemplate>> defaultGtuTemplate) Sets the default GTU templates.voidspawnGtu(String id, LaneBasedGtuCharacteristics templateGtuType, RoadNetwork network, Speed speed, LanePosition position) Create a single GTU.
-
Constructor Details
-
GtuSpawner
public GtuSpawner()Constructor.
-
-
Method Details
-
setUseDefaultGtuTemplate
public GtuSpawner setUseDefaultGtuTemplate(BiFunction<GtuType, nl.tudelft.simulation.jstats.streams.StreamInterface, Optional<GtuTemplate>> defaultGtuTemplate) Sets the default GTU templates.- Parameters:
defaultGtuTemplate- default GTU templates.- Returns:
- for method chaining.
-
setStream
Sets random stream.- Parameters:
stream- random stream.- Returns:
- for method chaining.
-
setNoLaneChangeDistance
Sets no lane change distance.- Parameters:
noLaneChangeDistance- no lane change distance.- Returns:
- for method chaining.
-
setBookkeeping
Sets how lane bookkeeping at lane changes is done.- Parameters:
bookkeeping- how lane bookkeeping at lane changes is done- Returns:
- for method chaining
-
setErrorHandler
Sets the error handler.- Parameters:
errorHandler- error handler.- Returns:
- for method chaining.
-
spawnGtu
public void spawnGtu(String id, LaneBasedGtuCharacteristics templateGtuType, RoadNetwork network, Speed speed, LanePosition position) throws GtuException, NetworkException Create a single GTU.- Parameters:
id- id.templateGtuType- characteristics.network- network.speed- speed.position- position.- Throws:
GtuException- when initial GTU values are not correctNetworkException- when the GTU cannot be placed on the given lane
-