Skip to content

Dynamic behaviors in composed scenarios don't execute in the MetaDrive simulator #397

@kevinchang73

Description

@kevinchang73

System Details

  1. Python Version: Python 3.8.10
  2. Scenic Version: Scenic 3.1.0a1
  3. Operating System / Platform: I use a Python virtual environment on Ubuntu 20.04.6 LTS
  4. Simulator Version: MetaDrive 0.4.3

Detailed Description

I’m trying to define a composing scenario in Scenic as follows. In the Main scenario, the ego vehicle is created with FollowLaneBehavior, and in the TrailingCar scenario, a trailing vehicle is created behind the ego, also with FollowLaneBehavior.

param map = localPath('maps/Town05.xodr')
model scenic.domains.driving.model

scenario TrailingCar(gap=0.5):
    setup:
        trailingCar = new Car behind ego by gap, with behavior FollowLaneBehavior(target_speed=5)

scenario Main():
    setup:
        ego = new Car with behavior FollowLaneBehavior(target_speed=5)
        tc = TrailingCar(gap=0.5)
    compose:
        do tc

Main()

When I run the simulation, the ego vehicle behaves as expected with FollowLaneBehavior. The trailing car is correctly positioned behind the ego, but it does not follow the behavior—it just stays at its initial position throughout the simulation. It seems this issue is related to the MetaDrive simulator. The trailing car follows the lane correctly when I switch to the Newtonian simulator.

Steps To Reproduce

Run the above Scenic code programmatically with the MetaDrive simulator:

import scenic
from scenic.simulators.metadrive import MetaDriveSimulator

scenario = scenic.scenarioFromFile(file_path, model="scenic.simulators.metadrive.model", mode2D=True)
scene, _ = scenario.generate()
simulator = MetaDriveSimulator(sumo_map='../maps/Town05.net.xml')
simulation = simulator.simulate(scene, maxSteps=100)

Then, we can inspect the agents’ behaviors via simulation.trajectory.

Issue Submission Checklist

  • I am reporting an issue, not asking a question
  • I checked the open and closed issues, forum, etc. and have not found any solution
  • I have provided all necessary code, etc. to reproduce the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: validIssue is valid and will be worked ontype: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions