Utils#
- class invertedai.utils.ScenePlotter(map_image: Optional[array] = None, fov: Optional[float] = None, xy_offset: Optional[Tuple[float, float]] = None, static_actors: Optional[List[StaticMapActor]] = None, open_drive: Optional[str] = None, resolution: Tuple[int, int] = (640, 480), dpi: float = 100, left_hand_coordinates: bool = False, **kwargs)[source]#
A class providing features for handling the data visualization of a scene involving IAI data.
- animate_scene(output_name: Optional[str] = None, start_idx: int = 0, end_idx: int = -1, ax: Optional[Axes] = None, numbers: Optional[List[int]] = None, direction_vec: bool = True, velocity_vec: bool = False, plot_frame_number: bool = False, agent_face_colors: Optional[List[Optional[Tuple[float, float, float]]]] = None, agent_edge_colors: Optional[List[Optional[Tuple[float, float, float]]]] = None) FuncAnimation [source]#
Produce an animation of sequentially recorded steps. A matplotlib animation object can be returned and/or a gif saved of the scene.
- Parameters:
output_name – File name of the gif to which the animation will be saved.
start_idx – The index of the time step from which the animation will begin. By default it is assumed all recorded steps are desired to be animated.
end_idx – The index of the time step from which the animation will end. By default it is assumed all recorded steps are desired to be animated.
ax – A matplotlib Axes object used to plot the animation. By default, an Axes object is created if a value of None is passed.
numbers – A list of agent ID’s that should be plotted in the image. By default this value is set to None.
direction_vec – Flag to determine if a vector showing the vehicles direction should be plotted in the animation. By default this flag is set to True.
velocity_vec – Flag to determine if the a vector showing the vehicles velocity should be plotted in the animation. By default this flag is set to False.
plot_frame_number – Flag to determine if the frame numbers should be plotted in the animation. By default this flag is set to False.
agent_face_colors – An optional parameter containing a list of either RGB tuples indicating the desired color of the agent with the corresponding index ID. A value of None in this list will use the default color. This value gets overwritten by the conditional agent color.
agent_edge_colors – An optional parameter containing a list of either RGB tuples indicating the desired color of a border around the agent with the corresponding index ID. A value of None in this list will use the default color. This value gets overwritten by the conditional agent color.
- initialize_recording(agent_states: List[AgentState], agent_attributes: Optional[List[AgentAttributes]] = None, agent_properties: Optional[List[AgentProperties]] = None, traffic_light_states: Optional[Dict[int, TrafficLightState]] = None, conditional_agents: Optional[List[int]] = None)[source]#
Record the initial state of the scene to be visualized. This function also acts as an implicit reset of the recording and removes previous agent state, agent attribute, conditional agent, traffic light, and agent style data.
- Parameters:
agent_states – A list of AgentState objects corresponding to the initial time step to be visualized.
agent_attributes – Static attributes of the agent, which don’t change over the course of a simulation. We assume every agent is a rectangle obeying a kinematic bicycle model.
agent_properties – Static attributes of the agent (with the AgentProperties data type), which don’t change over the course of a simulation. We assume every agent is a rectangle obeying a kinematic bicycle model.
traffic_light_states – Optional parameter containing the state of the traffic lights corresponding to the initial time step to be visualized. This parameter should only be used if the corresponding map contains traffic light static actors.
conditional_agents – Optional parameter containing a list of agent IDs corresponding to conditional agents to be visualized to distinguish themselves.
- plot_scene(agent_states: List[AgentState], agent_attributes: Optional[List[AgentAttributes]] = None, agent_properties: Optional[List[AgentProperties]] = None, traffic_light_states: Optional[Dict[int, TrafficLightState]] = None, conditional_agents: Optional[List[int]] = None, ax: Optional[Axes] = None, numbers: Optional[List[int]] = None, direction_vec: bool = True, velocity_vec: bool = False, agent_face_colors: Optional[List[Optional[Tuple[float, float, float]]]] = None, agent_edge_colors: Optional[List[Optional[Tuple[float, float, float]]]] = None)[source]#
Plot a single timestep of data then reset the recording.
- Parameters:
agent_states – A list of agents to be visualized in the image.
agent_attributes – Static attributes of the agent, which don’t change over the course of a simulation. We assume every agent is a rectangle obeying a kinematic bicycle model.
agent_properties – Static attributes of the agent (with the AgentProperties data type), which don’t change over the course of a simulation. We assume every agent is a rectangle obeying a kinematic bicycle model.
traffic_light_states – Optional parameter containing the state of the traffic lights to be visualized in the image. This parameter should only be used if the corresponding map contains traffic light static actors.
conditional_agents – Optional parameter containing a list of agent IDs of conditional agents to be visualized in the image to distinguish themselves.
ax – A matplotlib Axes object used to plot the image. By default, an Axes object is created if a value of None is passed.
numbers – A list of agent ID’s that should be plotted in the image. By default this value is set to None.
direction_vec – Flag to determine if a vector showing the vehicles direction should be plotted in the image. By default this flag is set to True.
velocity_vec – Flag to determine if the a vector showing the vehicles velocity should be plotted in the animation. By default this flag is set to False.
agent_face_colors – An optional parameter containing a list of either RGB tuples indicating the desired color of the agent with the corresponding index ID. A value of None in this list will use the default color. This value gets overwritten by the conditional agent color.
agent_edge_colors – An optional parameter containing a list of either RGB tuples indicating the desired color of a border around the agent with the corresponding index ID. A value of None in this list will use the default color. This value gets overwritten by the conditional agent color.
- record_step(agent_states: List[AgentState], traffic_light_states: Optional[Dict[int, TrafficLightState]] = None)[source]#
Record a single timestep of scene data to be used in a visualization
- Parameters:
agent_states – A list of AgentState objects corresponding to the initial time step to be visualized.
traffic_light_states – Optional parameter containing the state of the traffic lights corresponding to the initial time step to be visualized. This parameter should only be used if the corresponding map contains traffic light static actors.