simworld.traffic.manager package
Submodules
simworld.traffic.manager.intersection_manager module
Traffic intersection management module for traffic simulation.
This module handles the management of intersections, traffic signals, and vehicle/pedestrian routing through intersections.
- class simworld.traffic.manager.intersection_manager.IntersectionManager(intersections: List[Intersection], config)
Bases:
objectManages intersections and traffic signals in the simulation.
This class handles the initialization of intersections, traffic signal state management, and routing of vehicles and pedestrians through intersections.
- get_intersection_by_lane(lane: TrafficLane)
Find the intersection that contains a specific lane.
- Args:
lane: The traffic lane to find the intersection for.
- Returns:
The intersection containing the lane, or None if not found.
- get_intersection_by_sidewalk(sidewalk: Sidewalk, current_waypoint: Vector)
Find the closest intersection that contains a specific sidewalk.
- Args:
sidewalk: The sidewalk to find the intersection for. current_waypoint: The current position to determine closest intersection.
- Returns:
The closest intersection containing the sidewalk, or None if not found.
- get_next_lane_for_vehicle(lane: TrafficLane)
Determine the next lane for a vehicle to follow at an intersection.
This method chooses the next lane based on a weighted random selection, with straight paths given higher probability.
- Args:
lane: The current lane the vehicle is on.
- Returns:
A tuple of (intersection, next_lane) or (None, None) if no valid next lane.
- get_waypoints_for_pedestrian(sidewalk: Sidewalk, current_waypoint: Vector)
Get the next sidewalk, crosswalk and waypoints for a pedestrian.
- Args:
sidewalk: The current sidewalk the pedestrian is on. current_waypoint: The current position of the pedestrian.
- Returns:
A tuple of (next_sidewalk, crosswalk, waypoints, intersection) or (None, None, None, None).
- get_waypoints_for_vehicle(lane: TrafficLane)
Generate waypoints for a vehicle to navigate through an intersection.
- Args:
lane: The current lane the vehicle is on.
- Returns:
A tuple of (next_lane, waypoints, intersection, is_u_turn) or (None, None, None, None).
- init_intersections()
Initialize all intersections with their configuration.
Sets up lanes, sidewalks, and traffic lights for each intersection.
- set_traffic_signal_duration(communicator: Communicator)
Set the duration of all traffic signals.
- Args:
communicator: Interface for communicating with the simulation environment.
- spawn_traffic_signals(communicator: Communicator)
Spawn all traffic signals in the simulation environment.
- Args:
communicator: Interface for communicating with the simulation environment.
- update_intersections(communicator: Communicator)
Control the traffic lights at intersections.
Manages the cycle of traffic signals, switching between vehicle and pedestrian phases.
- Args:
communicator: Interface for communicating with the simulation environment.
simworld.traffic.manager.pedestrian_manager module
Pedestrian management module for traffic simulation.
This module handles the creation, spawning, and updating of pedestrians in the simulation. It manages pedestrian lifecycle, movement logic, and interaction with traffic signals.
- class simworld.traffic.manager.pedestrian_manager.PedestrianManager(roads, num_pedestrians, config)
Bases:
objectManages pedestrians in the traffic simulation.
This class handles spawning pedestrians on sidewalks, updating their positions and states, and managing their interactions with intersections and traffic signals.
- init_pedestrians()
Initialize the pedestrians and place them on the sidewalks.
Pedestrians are randomly placed on sidewalks, ensuring they maintain safe distances from other pedestrians and intersections.
- set_pedestrians_max_speed(communicator)
Set the maximum speed for each pedestrian in the simulation.
- Args:
communicator: Communication interface to the simulation environment.
- spawn_pedestrians(communicator)
Spawn pedestrians in the simulation environment.
- Args:
communicator: Communication interface to the simulation environment.
- stop_pedestrians(communicator)
Stop all pedestrians in the simulation.
- update_pedestrians(communicator, intersection_controller)
Update pedestrian states and movements based on environment conditions.
This method handles pedestrian movement logic, including waypoint following, intersection crossing, and traffic signal compliance.
- Args:
communicator: Interface for sending updates to the simulation. intersection_controller: Controller for managing intersection logic.
simworld.traffic.manager.vehicle_manager module
Vehicle management module for traffic simulation.
This module handles the creation, spawning, and updating of vehicles in the simulation. It manages vehicle lifecycle, movement logic, and interaction with traffic signals.
- class simworld.traffic.manager.vehicle_manager.VehicleManager(roads, num_vehicles, config)
Bases:
objectManages vehicles in the traffic simulation.
This class handles spawning vehicles on roads, updating their positions and states, and managing their interactions with other elements in the simulation.
- init_vehicles()
Initialize the vehicles and place them on the roads.
Vehicles are randomly placed on lanes, ensuring they maintain safe distances from other vehicles and intersections.
- spawn_vehicles(communicator)
Spawn vehicles in the simulation environment.
- Args:
communicator: Communication interface to the simulation environment.
- stop_vehicles(communicator)
Stop all vehicles in the simulation.
- update_vehicles(communicator, intersection_controller, pedestrians)
Update vehicle states and movements based on environment conditions.
This method handles vehicle movement logic, including waypoint following, intersection crossing, obstacle avoidance, and traffic signal compliance.
- Args:
communicator: Interface for sending updates to the simulation. intersection_controller: Controller for managing intersection logic. pedestrians: List of pedestrians to check for collision avoidance.
Module contents
Traffic management package for simulation components.
This package contains manager classes for simulation traffic components including: - IntersectionManager: Manages traffic intersections and signals - PedestrianManager: Manages pedestrian creation and movement - VehicleManager: Manages vehicle creation and movement