torchdrivesim.traffic_lights ============================ .. py:module:: torchdrivesim.traffic_lights Attributes ---------- .. autoapisummary:: torchdrivesim.traffic_lights.logger torchdrivesim.traffic_lights.ActorStates Classes ------- .. autoapisummary:: torchdrivesim.traffic_lights.TrafficLightState torchdrivesim.traffic_lights.TrafficLightGroupState torchdrivesim.traffic_lights.TrafficLightStateMachine torchdrivesim.traffic_lights.TrafficLightController Functions --------- .. autoapisummary:: torchdrivesim.traffic_lights.current_light_state_tensor_from_controller Module Contents --------------- .. py:data:: logger .. py:class:: TrafficLightState Bases: :py:obj:`enum.Enum` Generic enumeration. Derive from this class to define new enumerations. .. py:attribute:: none .. py:attribute:: green .. py:attribute:: yellow .. py:attribute:: red .. py:data:: ActorStates .. py:class:: TrafficLightGroupState Representing a single state of a group of traffic lights. .. py:attribute:: actor_states :type: ActorStates .. py:attribute:: sequence_number :type: int .. py:attribute:: duration :type: float .. py:attribute:: next_state :type: int .. py:class:: TrafficLightStateMachine(group_states: List[TrafficLightGroupState]) .. py:method:: from_json(json_file_path: str) -> typing_extensions.Self :classmethod: Current json format: [ { "actor_states": { "4411": "red", "3411": "red", ......... }, "state": "0", "duration": 10, "next_state": "1" }, ... ] .. py:method:: to_json() -> str .. py:method:: reset() .. py:method:: set_to(state_index: int, time_remaining: float) Set the TrafficLightStateMachine to a specific state. .. py:method:: tick(dt: float) Update the time remaining for the current state. .. py:property:: states :type: List[TrafficLightGroupState] .. py:property:: duration :type: float .. py:property:: current_state :type: TrafficLightGroupState .. py:property:: time_remaining :type: float .. py:method:: get_current_actor_states() -> ActorStates .. py:class:: TrafficLightController(traffic_fsms: List[TrafficLightStateMachine]) .. py:method:: from_json(json_file_path: str) -> typing_extensions.Self :classmethod: Current json format: [ [ { "actor_states": { "4411": "red", "3411": "red", ......... }, "state": "0", "duration": 10, "next_state": "1" }, ... ], ... ] .. py:method:: to_json() -> str .. py:method:: tick(dt) .. py:method:: set_to(light_states: List[List[float]]) .. py:method:: reset() .. py:method:: update_current_state_and_time() .. py:property:: current_state .. py:property:: current_state_with_name .. py:property:: state_per_machine .. py:property:: time_remaining .. py:method:: get_number_of_light_groups() .. py:method:: collect_all_current_light_states() .. py:function:: current_light_state_tensor_from_controller(traffic_light_controller: TrafficLightController, traffic_light_ids: List[int]) -> torch.Tensor