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()
  • Method Details

    • setUseDefaultGtuTemplate

      public GtuSpawner setUseDefaultGtuTemplate(boolean useDefaultGtuTemplate)
      Sets the use of default NL GTU templates.
      Parameters:
      useDefaultGtuTemplate - boolean; use of default NL GTU templates.
      Returns:
      this; for method chaining.
    • setStream

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

      public GtuSpawner setNoLaneChangeDistance(org.djunits.value.vdouble.scalar.Length noLaneChangeDistance)
      Sets no lane change distance.
      Parameters:
      noLaneChangeDistance - Length; no lane change distance.
      Returns:
      this; for method chaining.
    • setInstantaneousLaneChanges

      public GtuSpawner setInstantaneousLaneChanges(boolean instantaneousLaneChanges)
      Sets instantaneous lane changes.
      Parameters:
      instantaneousLaneChanges - boolean; instantaneous lane changes.
      Returns:
      this; for method chaining.
    • setErrorHandler

      public GtuSpawner setErrorHandler(GtuErrorHandler errorHandler)
      Sets the error handler.
      Parameters:
      errorHandler - GtuErrorHandler; error handler.
      Returns:
      this; for method chaining.
    • spawnGtu

      public void spawnGtu(String id, LaneBasedGtuCharacteristics templateGtuType, RoadNetwork network, org.djunits.value.vdouble.scalar.Speed speed, LanePosition position) throws GtuException, OtsGeometryException, NetworkException
      Create a single GTU.
      Parameters:
      id - String; id.
      templateGtuType - LaneBasedGtuCharacteristics; characteristics.
      network - RoadNetwork; network.
      speed - Speed; speed.
      position - LanePosition; position.
      Throws:
      GtuException - when initial GTU values are not correct
      OtsGeometryException - when the initial path is wrong
      NetworkException - when the GTU cannot be placed on the given lane