Class GtuSpawner

java.lang.Object
org.opentrafficsim.road.gtu.generator.GtuSpawner

public class GtuSpawner extends Object
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 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

      public GtuSpawner setStream(nl.tudelft.simulation.jstats.streams.StreamInterface stream)
      Sets random stream.
      Parameters:
      stream - random stream.
      Returns:
      for method chaining.
    • setNoLaneChangeDistance

      public GtuSpawner setNoLaneChangeDistance(Length noLaneChangeDistance)
      Sets no lane change distance.
      Parameters:
      noLaneChangeDistance - no lane change distance.
      Returns:
      for method chaining.
    • setBookkeeping

      public GtuSpawner setBookkeeping(LaneBookkeeping bookkeeping)
      Sets how lane bookkeeping at lane changes is done.
      Parameters:
      bookkeeping - how lane bookkeeping at lane changes is done
      Returns:
      for method chaining
    • setErrorHandler

      public GtuSpawner setErrorHandler(GtuErrorHandler errorHandler)
      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 correct
      NetworkException - when the GTU cannot be placed on the given lane