Scenario

Scenario#

Two agents crosses along a corridor and should avoid stepping on the red pad at the same time. The agents can move straight without incurring in collisions: the scenario is effectively one dimensional.

[1]:
from navground import core, sim
from navground.learning.scenarios.pad import PadScenario, render_kwargs

scenario = PadScenario()
world = scenario.make_world(seed=0)
[2]:
from navground.sim.notebook import display_in_notebook

display_in_notebook(world, **render_kwargs())
[2]:
../../_images/tutorials_pad_Scenario_2_0.svg

By default the agents follow a Dummy behavior, ignoring the pad and the other agent. In the video below, the agents turn red when they violate the one-agent-on-pad rule.

[3]:
from navground.sim.ui.video import display_video

display_video(world, time_step=0.1, duration=10, factor=4, **render_kwargs())
[3]:
[4]:
from navground.sim.ui.video import record_video

world = scenario.make_world(seed=0)
record_video('videos/scenario.mp4', world, time_step=0.1, duration=10, factor=4, **render_kwargs())

The agents start at fixed lateral position, spaced enough not to worry about collisions. Their starting longitudinal position is randomly sampled.

For testing, the agents always start on opposing sides of the pad, like in the picture above. Instead, for training, we may let the agent start uniformly along the corridor. In this case, only about 25% of the cases lead to a conflict.

[5]:
train_scenario = PadScenario(start_in_opposite_sides=False)
train_world = train_scenario.make_world(seed=0)
display_in_notebook(train_world, **render_kwargs())
[5]:
../../_images/tutorials_pad_Scenario_7_0.svg

More generallu, the width of the pad and the areas where the agents are spawned are configurable. A small tolerance is applied on the edges of the pad.

[6]:
print(sim.dump(scenario))
type: Pad
length: 2
pad_tolerance: 0.00999999978
pad_width: 0.5
start_in_opposite_sides: true
start_max_x: .inf
start_min_x: -.inf
width: 0.600000024
with_walls: true
obstacles:
  []
[ ]: