plafosim.vehicle module

plafosim.vehicle.ArrayLike

alias of float

class plafosim.vehicle.CF_Model(value)[source]

Bases: Enum

Car Following models that vehicles can use for their mobility.

ACC = 1
CACC = 2
HUMAN = 0
class plafosim.vehicle.Vehicle(simulator: Simulator, vid: int, vehicle_type: VehicleType, depart_position: int, arrival_position: int, desired_speed: float, depart_lane: int, depart_speed: float, depart_time: float, depart_delay: float, communication_range: int, pre_filled: bool = False)[source]

Bases: object

A collection of state information for a vehicle in the simulation.

A vehicle can really be anything that can move and can be defined by a vehicle type. It does not necessarily be driven by a computer (i.e., autonomous). However, by default it does have V2X functionality.

__init__(simulator: Simulator, vid: int, vehicle_type: VehicleType, depart_position: int, arrival_position: int, desired_speed: float, depart_lane: int, depart_speed: float, depart_time: float, depart_delay: float, communication_range: int, pre_filled: bool = False)[source]

Initialize a vehicle instance.

Parameters:
  • simulator (Simulator) – The global simulator object

  • vid (int) – The id of the vehicle

  • vehicle_type (VehicleType) – The vehicle type of the vehicle

  • depart_position (int) – The departure position of the vehicle

  • arrival_position (int) – The arrival position of the vehicle

  • desired_speed (float) – The desired driving speed of the vehicle

  • depart_lane (int) – The departure lane of the vehicle

  • depart_speed (float) – The departure speed of the vehicle

  • depart_time (float) – The actual departure time of the vehicle

  • depart_delay (float) – The time the vehicle had to wait before starting its trip

  • communication_range (int) – The maximum communication range of the vehicle

  • pre_filled (bool) – Whether this vehicle was pre-filled

_action(step: float)[source]

Triggers specific actions of a vehicle.

Parameters:

step (float) – The current simulation step

_calculate_emission(a: float, v: float, f: list, scale: float) float[source]

Calculate the actual emission of the vehicle.

Parameters:
  • a (float) – The current acceleration

  • v (float) – The current speed

  • f (list) – The emission factors to use for current emission variable to be calculated

  • scale (float) – The scale to normalize the calculated value

Returns:

float

Return type:

The calculcated emission in ml/mg per s

_calculate_emissions()[source]

Calculate the emitted pollutant amount using the given speed and acceleration based on the HBEFA3 model.

As the functions are defining emissions in g/hour, the function’s result is normed by 3.6 (seconds in an hour/1000) yielding mg/s. For fuel ml/s is returned. Negative acceleration results directly in zero emission.

The amount emitted by the given emission class when moving with the given velocity and acceleration [mg/s or ml/s]

_start()[source]

Start this Vehicle.

_statistics()[source]

Write continuous statistics for the vehicle.

action(step: int)[source]

Triggers actions of a vehicle.

Parameters:

step (int) – The current simulation step

finish()[source]

Clean up the instance of the vehicle.

This includes mostly statistic recording.

info() str[source]

Return information about the vehicle.

property arrival_position: int

Return the arrival position of the vehicle.

property blocked_front: bool

Return whether the vehicle is currently blocked by a slow vehicle in the front.

property cf_model: CF_Model

Return the currently activated car following model of the vehicle.

property color: tuple

Return the current color of the vehicle.

property depart_lane: int

Return the departure lane of the vehicle.

property depart_position: int

Return the departure position of the vehicle.

property depart_speed: float

Return the departure speed of the vehicle.

property depart_time: float

Return the departure time of the vehicle.

property desired_gap: float

Return the desired gap to the vehicle in front of the vehicle.

This is based on the desired headway time and the current driving speed.

property desired_headway_time: float

Return the desired headway time of the vehicle.

property desired_speed: float

Return the desired driving speed of the vehicle.

property headway_time: float

Return the human headway time of the vehicle.

This is based on the vehicle type.

property lane: int

Return the current lane of the vehicle.

property length: int

Return the length of the vehicle.

This is based on the vehicle type.

property max_acceleration: float

Return the maximum acceleration of the vehicle.

This is based on the vehicle type.

property max_deceleration: float

Return the maximum deceleration of the vehicle.

This is based on the vehicle type.

property max_speed: float

Return the maximum speed of the vehicle.

This is based on the vehicle type.

property min_gap: float

Return the minimum safety gap to the vehicle in front of the vehicle.

This is based on the vehicle type.

property position: float

Return the current position of the vehicle.

property rear_position: int

Return the current rear position of the vehicle.

property speed: float

Return the current driving speed of the vehicle.

property travel_distance: float

Return the current traveled distance of the vehicle.

property travel_time: float

Return the current traveled time of the vehicle.

property vehicle_type: VehicleType

Return the VehicleType of the vehicle.

property vid: int

Return the id of the vehicle.

class plafosim.vehicle.VehicleType(name: str, length: int, max_speed: float, max_acceleration: float, max_deceleration: float, min_gap: float, headway_time: float, emission_class: str)[source]

Bases: object

A collection of parameters for a concrete vehicle type.

__init__(name: str, length: int, max_speed: float, max_acceleration: float, max_deceleration: float, min_gap: float, headway_time: float, emission_class: str)[source]

Initialize a specific vehicle type.

Parameters:
  • name (str) – The name of the vehicle type

  • length (int) – The length of the vehicle type

  • max_speed (float) – The maximum speed of the vehicle type

  • max_acceleration (float) – The maximum acceleration of the vehicle type

  • max_deceleration (float) – The maximum deceleration of the vehicle type

  • min_gap (float) – The minimum safety gap to the vehicle in front of the vehicle type

  • headway_time (float) – The human headway time of the vehicle type

  • emission_class (EmissionClass) – The emission class of the vehicle type

property emission_class: EmissionClass

Return the emission class of a vehicle type.

property emission_factors: dict

Return the emission factors of a vehicle type.

property headway_time: float

Return the desired human headway time of a vehicle type.

property length: int

Return the length of a vehicle type.

property max_acceleration: float

Return the maximum acceleration of a vehicle type.

property max_deceleration: float

Return the maximum deceleration of a vehicle type.

property max_speed: float

Return the maximum speed of a vehicle type.

property min_gap: float

Return the minimum gap of a vehicle type.

property name: str

Return the name of a vehicle type.

plafosim.vehicle.record_emission_trace_prefix(basename: str, step: float, vid: int)[source]
plafosim.vehicle.record_emission_trace_suffix(basename: str)[source]
plafosim.vehicle.record_emission_trace_value(basename: str, value: float)[source]
plafosim.vehicle.record_vehicle_emission(basename: str, vehicle: Vehicle)[source]
plafosim.vehicle.record_vehicle_trace(basename: str, step: int, vehicle: Vehicle)[source]
plafosim.vehicle.record_vehicle_trip(basename: str, vehicle: Vehicle, depart_delay: int, time_loss: int, expected_travel_time: float, travel_time_ratio: float, average_driving_speed: float, average_deviation_desired_speed: float)[source]
plafosim.vehicle.speed2distance(speed: float, time_interval: float = 1.0) float[source]

Convert a driving speed to a distance driven within a given time interval.

Parameters:
  • speed (float) – The speed to be converted

  • time_interval (float, optional) – The time to consider

Returns:

float

Return type:

The converted value