carla-simulator / scenario_runner

Traffic scenario definition and execution engine
https://carla-scenariorunner.readthedocs.io/en/latest/
MIT License
532 stars 364 forks source link

CONTROLLING EGO VEHICLE via scenario_runner.py or OpenScenario format #507

Closed iremonur closed 4 years ago

iremonur commented 4 years ago

I would like to control the ego vehicle (like give an initial speed or a route to ego vehicle) in the scenario via OpenScenario format or scenario_runner.py. In OpenScenario format, I tried to give an initial speed to ego vehicle(hero) within Storyboard --> Init --> Actions --> Private object="hero" --> Action --> Longitudinal --> Speed --> Dynamics shape="step"/ --> Target --> Absolute value="10"/. But it doesn't work. I think that i can define an initial speed for ego vehicle in the scenario_runner.py but i did not figure it out yet. Is it possible that give an initial speed or spesific route to ego vehicle in scenario_runner.py or via OpenScenario format (in .xml file) ?

glopezdiest commented 4 years ago

Hello. _Speaking only for the scenariorunner.py part, you can definitely send a route to the ego_vehicle, it just requires a bit of setting up. Try to run this example and see if it fits your needs:

python3 scenario_runner.py --route srunner/challenge/routes_training.xml srunner/challenge/all_towns_traffic_scenarios.json 0 --agent srunner/challenge/autoagents/npc_agent.py --debug

The first part after the route argument is an .xml file that defines the route. The second one is the definition of the scenario, in .json format and the third, the id of the route to be run (if this is blank, they are all sequentially run). Lastly, the agent is the responsible of moving the agent and the debug argument just prints the route (and prints a lot of stuff too).

Regarding the speed, there isn't a parameter to do so right now. If you want to make the ego vehicle start with a specific speed, you'd have to go to the .py file where the scenario in question is defined, and add a pytrees behavior to do so (you can go to srunner/scenariomanager/scenarioatomics/atomic_behaviors.py to see lots of examples)

fabianoboril commented 4 years ago

That is in fact a bug. Fixed with #519