carla-simulator / scenario_runner

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

OpenSCENARIO + Agent support #577

Open lucasnmatias opened 4 years ago

lucasnmatias commented 4 years ago

Hi,

I have one question about the support for OpenSCENARIO. I would like to know why we cannot run a scenario from OpenSCENARIO with an agent implemented?

Agents are currently only compatible with route scenarios

It would be interesting to define a scenario with OpenSCENARIO and test my agent on it. Also, right now I don't see how to define the ego car on OpenSCENARIO and setup sensors on it, so the OpenSCENARIO does not help me to collect sensor data from the specified scenarios.

fabianoboril commented 4 years ago

Hi, you can make use of an agent via OSCControllers (please see the corresponding example here: https://github.com/carla-simulator/scenario_runner/blob/master/srunner/examples/OscControllerExample.xosc) The controllers are defined here: https://github.com/carla-simulator/scenario_runner/tree/master/srunner/scenariomanager/actorcontrols You can implement your own (derived from BasicControl) to be your agent. The ego vehicle is simply flag with an ego_vehicle property (see also the OSC examples).

lucasnmatias commented 4 years ago

That is great! I just miss one thing, different from BasicAgent, BasicControl does not implement the function setup_sensors. I work at IVEX which is a company mainly focused on evaluating the safety of autonomous systems in order to improve the vehicle's decision making towards safer behavior. Since we work with assessing of autonomous vehicle safety we have been implementing scenarios and using the sensor's output to evaluate vehicle behavior.

We want to assess the vehicle behavior in two ways with the simulator:

1 - Assess the agent safety with OpenSCENARIO scenes (control the ego with an implemented agent and collect data from sensors) 2 - Implement a specific behavior on the ego vehicle with OpenSCENARIO (control the ego with OpenSCENARIO and also collect data from sensors)

Since I could not find a way to setup sensors on the ego vehicle and build scenarios with OpenSCENARIO, right now our solution has been a modification on the original code, we remove the if condition that blocks the use of agent + OpenSCENARIO and passes our implemented agent as a parameter normally (so we can setup sensors to the ego car and control it without OpenSCENARIO). Also, we add a new flag dummyAgent to allow setup sensors on the ego vehicle and control it through OpenSCENARIO. But I'm trying to understand better the original code to see if we can have those functionalities without these adaptations.

fabianoboril commented 4 years ago

Setting up sensors can be done through the control as well. You just have to pass the sensors as properties in the XOSC file, or you hard-code them in your control implementation. I did that for the one I am currently using for my own purpose.

SiNa-Dehbari commented 3 years ago

Hello Everyone,

I have the same challenge. I am new in Carla and ScenarioRunner. My problem is: I want to define a scenario in Openscenario Format and run it automatically. (I don't want to use manual_control.py could you please give me the commands?

Thank you in advance

jiheddachraoui commented 1 year ago

hello can you provide us with an example how you implemented sensors pls?

Setting up sensors can be done through the control as well. You just have to pass the sensors as properties in the XOSC file, or you hard-code them in your control implementation. I did that for the one I am currently using for my own purpose.