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.
Is there something I’m missing in order to run a dynamic composing scenario like this?
For context, I’m running the scenario programmatically with the MetaDrive simulator:
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=max_steps, maxIterations=maxIterations)