Closed gaodechen closed 1 year ago
Hi @gaodechen -
Thanks for the wrapping the PR with the detailed description π I was able to follow the set up guidelines and have the scenario runner
imported. When I am trying to run the scenario by
opencda-latest) ztu@lambda-quad:~/OpenCDA$ python opencda.py -t openscenario_carla -v 0.9.12
OpenCDA Version: 0.1.3
Process Process-1:
Traceback (most recent call last):
File "/home/ztu/miniconda3/envs/opencda-latest/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
self.run()
File "/home/ztu/miniconda3/envs/opencda-latest/lib/python3.7/multiprocessing/process.py", line 99, in run
self._target(*self._args, **self._kwargs)
File "/home/ztu/OpenCDA/opencda/scenario_testing/openscenario_carla.py", line 25, in exec_scenario_runner
scenario_runner = sr.ScenarioRunner(scenario_params.scenario)
AttributeError: module 'scenario_runner' has no attribute 'ScenarioRunner'
Waiting for the ego vehicle...
Waiting for the ego vehicle...
Waiting for the ego vehicle...
with the status on waiting for ego vehicle for a long time.
I have my Carla running on the side in another thread. We have our Carla set up with 0.9.12
Did I miss any steps or is that expected? Thanks!
Hi @gaodechen -
Thanks for the wrapping the PR with the detailed description π I was able to follow the set up guidelines and have the
scenario runner
imported. When I am trying to run the scenario byopencda-latest) ztu@lambda-quad:~/OpenCDA$ python opencda.py -t openscenario_carla -v 0.9.12 OpenCDA Version: 0.1.3 Process Process-1: Traceback (most recent call last): File "/home/ztu/miniconda3/envs/opencda-latest/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap self.run() File "/home/ztu/miniconda3/envs/opencda-latest/lib/python3.7/multiprocessing/process.py", line 99, in run self._target(*self._args, **self._kwargs) File "/home/ztu/OpenCDA/opencda/scenario_testing/openscenario_carla.py", line 25, in exec_scenario_runner scenario_runner = sr.ScenarioRunner(scenario_params.scenario) AttributeError: module 'scenario_runner' has no attribute 'ScenarioRunner' Waiting for the ego vehicle... Waiting for the ego vehicle... Waiting for the ego vehicle...
with the status on waiting for ego vehicle for a long time. I have my Carla running on the side in another thread. We have our Carla set up with
0.9.12
Did I miss any steps or is that expected? Thanks!
Thank you @ju40268 for reviewing!
Could you check if there is an empty __init__.py
under the ScenarioRunner folder? The file turns the ScenarioRunner folder into a regular Python package that can be imported by other Python codes.
Please try python -c 'import scenario_runner'
once __init__.py
is added to the folder and see if it can be imported then.
@ju40268
The path settings look good. Could you remove the __pycache__
folder and try importing again?
Or check out
>> import scenario_runner as sr
>> dir(sr)
['CarlaDataProvider', 'LooseVersion', 'OpenScenario', 'OpenScenarioConfiguration', 'RawTextHelpFormatter', 'RouteParser', 'RouteScenario', 'ScenarioConfigurationParser', 'ScenarioManager', 'ScenarioRunner', 'VERSION', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'argparse', 'carla', 'datetime', 'glob', 'importlib', 'inspect', 'json', 'main', 'os', 'pkg_resources', 'print_function', 'signal', 'sys', 'time', 'traceback']
and see if the classes were imported
I was able to run the code π seeing some scenarios showing up on my side. I'll have a detailed readme section on how to install the scenario running combing with our projects.
I was able to run the code π seeing some scenarios showing up on my side. I'll have a detailed readme section on how to install the scenario running combing with our projects.
Thank you for testing and reviewing our code!
Thanks @ju40268 for reviewing this pr! Thanks @gaodechen for the useful feature! I am thinking can we make the installation a bit more easier? I feel we can add a bash script to directly do the path insert things for users
Thanks @ju40268 for reviewing this pr! Thanks @gaodechen for the useful feature! I am thinking can we make the installation a bit more easier? I feel we can add a bash script to directly do the path insert things for users
Agreed. Wondering if there is an installation script for OpenCDA? We can integrate ScenarioRunner scripts into that one or if you prefer a separate script for the ScenarioRunner feature?
I think a separate bash script should be better as ScenarioRunner should be an optional feature in OpenCDA
I've read through the PR shortly but got basic question:
As I understand the main purpose of hooking up scenario runner with OpenCDA is that this should enable us to provide couple yaml / simple python file so that it's generating scenes, which an be inject into the OpenCDA. Later on OpenCDA could apply the rest algorithm. (ex. planning logic, apply ML models etc)
From the code - it seems like it's been applying the control / scenarios with Carla
directly instead of OpenCDA
.
ex, You have cav_world
and sim_api
but didn't performing further action based on this, and the major while loop is applying control of two vehicle following each other.
@DerrickXuNu Please correct me if I am wrong.
Hi @ju40268 , thanks for your careful check. I agree with you. Scenario Runner should be a component inject to the whole OpenCDA. The current code does not use OpenCDA code functions, which is not ready for merge
VehicleManager
support for OpenScenarioWe added VehicleManager
for openscenario_carla
to be consistent with other OpenCDA configurations. So the ego vehicle is controlled by OpenCDA.
To support VehicleManager
with the presence of ScenarioRunner
, we have to create a new API create_vehicle_manager_from_scenario_runner
in the second commit.
SR only supports single ego vehicle, and all the actors are initialized by the SR process. The original create_vehicle_manager
API supports multiple vehicles, and initializes all the actors regardless what have been created in SR. To avoid duplicates in configurations and initialization and also support the single ego vehicle case, we add the following member function in sim_api
following the same manner as create_vehicle_manager
.
def create_vehicle_manager_from_scenario_runner(self, vehicle):
"""
Create a single CAV with a loaded ego vehicle from SR.
Different from the create_vehicle_manager API creating Carla vehicle from scratch,
SR creates on its own only supports 'single' vehicle.
Parameters
----------
vehicle:
The Carla ego vehicle created by ScenarioRunner.
Returns
-------
single_cav_list : list
A list contains the singla CAV derived from the ego vehicle.
"""
...
We have integrated ScenarioRunner
support in the first commit of this thread. We created a new scenario for an overtake action based on ScenarioRunner
, where the ego vehicle needs to overtake a fast vehicle ahead and avoid collision with the background vehicles and two pedestrians.
To integrate any custom scenarios, configure the Python scripts (controlling the ego vehicle and actor behaviors) and .xml
file (defining all the actors in the scenario) paths in .yaml
.
scenario_runner:
configFile: './opencda/scenario_testing/scenarios/Overtake.xml'
# Absolute path needed here
additionalScenario: '/home/ucdavis/OpenCDA/opencda/scenario_testing/scenarios/overtake.py'
We added a boundary check in map_manager.py
since the nxt array at index 0 may not exist.
nxt = nxt.next(self.lane_sample_resolution)[0]
LGTM! Thanks for making this happen π π I just have two comments/questions -
<other_actor>
section and appending apply behavior, but I didn't see it showing up..py
and one .xml
file and additional Python code specifying their behavior, right? Would it be possible to have more for
loop which avoids a similar codebase?LGTM! Thanks for making this happen π π I just have two comments/questions -
- Could you list the steps required to add a new actor? I tried adding one in the
<other_actor>
section and appending apply behavior, but I didn't see it showing up.- Later on, for a new scenario, we'll need to have one
.py
and one.xml
file and additional Python code specifying their behavior, right? Would it be possible to have morefor
loop which avoids a similar codebase?
Thank you for the quick response, Christie!
overtake.py
scripts, i.e., the first 4 actors in Overtake.xml
. In other words, we have deterministic actors to test against here..py
script paired with a .xml
to be compatible with SR. The .py
defines the actor behaviors and testing criteria, and the .xml
consists of all the actors to play the scenario.
The commit adds a new module for
OpenCDA
that supports running unified autonomouos driving test with custom autonomous driving algorithms and pre-defined scenarios.Specifically, the program involves two pipeline executed concurrently: an ego vehicle algorithm runner where autonomous driving algorithms are adopted, and a ScenarioRunner pipeline that tests against preset scenarios.
To test the new module:
Changes
openscenario_carla
: Config scripts that pull up two subprocesses including a ScenarioRunner subprocess and a ego vehicle controlling subprocess.openscenario_carla.yaml
: YAML configurations.Prerequisites
We need to first install SenarioRunner: SenarioRunner documents.
Insert
SenarioRunner
to the Python API paths so that it can be imported.SenarioRunner
locates resource paths withSENARIO_RUNNER_ROOT
.Therefore, we can execute the following commands to set up ScenarioRunner environmental variables:
__init__.py
under theSenarioRunner
installation folder, so that the folder is treated as a package. You can create the file manually or use the command: