smarts.sstudio.genscenario module

This script provides a Python interface to generate scenario artifacts. This includes route files sumo `*.rou.xml), missions, and bubbles.

class smarts.sstudio.genscenario.ActorAndMission(actor: Actor, mission: Mission | EndlessMission | LapMission)[source]

Holds an Actor object and its associated Mission.

actor: Actor

Specification for traffic actor.

mission: Mission | EndlessMission | LapMission

Mission for traffic actor.

smarts.sstudio.genscenario.gen_agent_missions(scenario: str, missions: Sequence, map_spec: MapSpec | None = None)[source]

Generates a route file to represent missions (a route per mission). Will create the output_dir if it doesn’t exist already. The output file will be named missions.

Parameters:
  • scenario – The scenario directory

  • missions – A sequence of missions for social agents to perform

  • map_spec – An optional map specification that takes precedence over scenario directory information.

smarts.sstudio.genscenario.gen_bubbles(scenario: str, bubbles: Sequence[Bubble])[source]

Generates ‘bubbles’ in the scenario that capture vehicles for actors. :param scenario: The scenario directory :param bubbles: The bubbles to add to the scenario.

smarts.sstudio.genscenario.gen_friction_map(scenario: str, surface_patches: Sequence[RoadSurfacePatch])[source]

Generates friction map file according to the surface patches defined in scenario file.

smarts.sstudio.genscenario.gen_group_laps(scenario: str, begin: Tuple[str, int, Any], end: Tuple[str, int, Any], grid_offset: int, used_lanes: int, vehicle_count: int, entry_tactic: EntryTactic | None, num_laps: int = 3, map_spec: MapSpec | None = None)[source]

Generates missions that start with a grid offset at the start-line and do a number of laps until finishing.

Parameters:
  • scenario – The scenario directory

  • begin – The edge and offset of the first vehicle

  • end – The edge and offset of the finish-line

  • grid_offset – The F1 starting line staggered with offset disadvantage imposed per vehicle

  • used_lanes – The number of lanes used for the starting-line from the innermost lane

  • vehicle_count – The number of vehicles to use

  • num_laps – The amount of laps before finishing

smarts.sstudio.genscenario.gen_map_spec_artifact(scenario: str, map_spec: MapSpec, output_dir: str | None = None)[source]

Saves a map spec to file.

smarts.sstudio.genscenario.gen_metadata(scenario: str, scenario_metadata: StandardMetadata)[source]

Generate the metadata for the scenario

Parameters:
smarts.sstudio.genscenario.gen_missions(scenario: str, missions: Sequence[Mission], actors: Sequence[Actor], name: str, output_dir: str, map_spec: MapSpec | None = None)[source]

Generates a route file to represent missions (a route per mission). Will create the output_dir if it doesn’t exist already.

smarts.sstudio.genscenario.gen_scenario(scenario: Scenario, output_dir: str | Path, seed: int = 42)[source]

This is now the preferred way to generate a scenario. Instead of calling the gen_* methods directly, we provide this higher-level abstraction that takes care of the sub-calls.

smarts.sstudio.genscenario.gen_social_agent_missions(scenario: str, missions: Sequence[Mission], social_agent_actor: SocialAgentActor | Sequence[SocialAgentActor], name: str, map_spec: MapSpec | None = None)[source]

Generates the social agent missions for the given scenario.

Parameters:
  • scenario – The scenario directory

  • missions – A sequence of missions for social agents to perform

  • social_agent_actor – The social agent actor(s) this scenario will use.

  • name – A short name for this grouping of social agents. Is also used as the name of the social agent traffic file

  • map_spec – An optional map specification that takes precedence over scenario directory information.

smarts.sstudio.genscenario.gen_traffic(scenario: str, traffic: Traffic, name: str, output_dir: str | None = None, seed: int = 42, map_spec: MapSpec | None = None)[source]

Generates the traffic routes for the given scenario. If the output directory is not provided, the scenario directory is used.

smarts.sstudio.genscenario.gen_traffic_histories(scenario: str, histories_datasets: Sequence[TrafficHistoryDataset | str], map_spec: MapSpec | None = None)[source]

Converts traffic history to a format that SMARTS can use. :param scenario: The scenario directory :param histories_datasets: A sequence of traffic history descriptors. :param map_spec: An optional map specification that takes precedence over scenario directory information.