huawei-noah / SMARTS

Scalable Multi-Agent RL Training School for Autonomous Driving
MIT License
955 stars 190 forks source link

[Feature request] [SStudio] Define terminal scenario time condition #1991

Open Gamenot opened 1 year ago

Gamenot commented 1 year ago

Motivation

Scenarios that should have a specific duration of time to complete should be able to declare that amount of time in the definition of the scenario. This should either be possible through the scenario or the agent missions.

I believe that the agent interface should be able to choose if to respect the scenario time limit or not.

Proposal

I would propose the following for a mission-related ending:

scenarios/sumo/figure_eight/scenario.py

...
agent_mission = t.Mission(
  ...,
  simulation_time_limit_s = 10,
)

gen_scenario(
  t.Scenario(
    agent_missions = [agent_mission],
    ...
  ),
)

examples/control/laner.py

For the agent interface I would propose the following solution:

# Default to 10.5 seconds if not defined in scenario
agent_interface = AgentInterface.from_type(AgentType.Buddha, simulation_time_limit=TimeLimitSec(default=10.5))
# Always 10.5 seconds.
agent_interface = AgentInterface.from_type(AgentType.Buddha, simulation_time_limit=TimeLimitSec(10.5, use_scenario=False))
# Go for 1000 steps instead (existing)
agent_interface = AgentInterface.from_type(AgentType.Buddha, max_episode_steps=1000, simulation_time_limit=False)

Alternatives

No response

Additional context

No response