Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with CARLA 0.10 #1133

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
* [CARLA ScenarioRunner 0.9.5](#carla-scenariorunner-095)
* [CARLA ScenarioRunner 0.9.2](#carla-scenariorunner-092)

## Upcoming

## CARLA ScenarioRunner 0.10
* Updated the scenarios to match the limitations of CARLA 0.10. This means moving them to Town10HD_Opt and updating the blueprints to the available ones.
* Added Scenic examples to the repo, and updated the [available ones in their repo](https://github.com/BerkeleyLearnVerify/Scenic/tree/main/examples/carla/Carla_Challenge) to match the new release.

* Improvements to the CarlaDataProvider:
- Added `spawn_actor` for a blueprint based actor creation similar to `World.spawn_actor`

Expand Down
2 changes: 0 additions & 2 deletions manual_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,6 @@ def destroy(self):
if sensor is not None:
sensor.stop()
sensor.destroy()
if self.player is not None:
self.player.destroy()


# ==============================================================================
Expand Down
12 changes: 6 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
py-trees==0.8.3
numpy==1.18.4; python_version >= '3.0'
networkx==2.2
Shapely==1.7.1
numpy==1.24.4; python_version >= '3.0'
networkx
Shapely
psutil
xmlschema==1.0.18
ephem
tabulate
opencv-python==4.2.0.32
opencv-python
matplotlib
six
simple-watchdog-timer
antlr4-python3-runtime==4.10
antlr4-python3-runtime
graphviz
xmlschema
12 changes: 12 additions & 0 deletions srunner/examples/BlockedIntersection.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<scenarios>
<scenario name="BlockedIntersection_1" type="BlockedIntersection" town="Town10HD_Opt">
<ego_vehicle x="0.7" y="28.1" z="0" yaw="0" model="vehicle.lincoln.mkz"/>
<direction value='right'/>
</scenario>
<scenario name="BlockedIntersection_2" type="BlockedIntersection" town="Town10HD_Opt">
<ego_vehicle x="-104" y="61" z="0" yaw="-90" model="vehicle.lincoln.mkz"/>
<direction value='right'/>
</scenario>
</scenarios>

23 changes: 23 additions & 0 deletions srunner/examples/ConstructionObstacle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<scenarios>
<scenario name="ConstructionObstacle_1" type="ConstructionObstacle" town="Town10HD_Opt">
<ego_vehicle x="-24.4" y="-57.8" z="0" yaw="0" model="vehicle.lincoln.mkz"/>
<start_actor_flow x="-27.0" y="-61.1" z="0"/>
<end_actor_flow x="59.3" y="-61.1" z="0"/>
<direction value='right'/>
<distance value='50'/>
<flow_speed value="6"/>
<source_dist_interval from="10" to="60"/>
</scenario>
<!-- ConstructionObstacle_2 means to illustrate that it can be used to make the ego cross into a opposite lane -->
<scenario name="ConstructionObstacle_2" type="ConstructionObstacle" town="Town10HD_Opt">
<ego_vehicle x="62.7" y="-64.6" z="0" yaw="180" model="vehicle.lincoln.mkz"/>
<start_actor_flow x="-27.0" y="-61.1" z="0"/>
<end_actor_flow x="59.3" y="-61.1" z="0"/>
<direction value='right'/>
<distance value='50'/>
<flow_speed value="6"/>
<source_dist_interval from="50" to="100"/>
</scenario>
</scenarios>

46 changes: 2 additions & 44 deletions srunner/examples/ControlLoss.xml
Original file line number Diff line number Diff line change
@@ -1,48 +1,6 @@
<?xml version="1.0"?>
<scenarios>
<scenario name="ControlLoss_1" type="ControlLoss" town="Town01">
<ego_vehicle x="392.5" y="195" z="0.5" yaw="90" model="vehicle.lincoln.mkz_2017" />
</scenario>
<scenario name="ControlLoss_2" type="ControlLoss" town="Town01">
<ego_vehicle x="-2.0" y="160" z="0.5" yaw="90" model="vehicle.lincoln.mkz_2017" />
</scenario>
<scenario name="ControlLoss_3" type="ControlLoss" town="Town01">
<ego_vehicle x="168.9" y="59.8" z="0.5" yaw="0" model="vehicle.lincoln.mkz_2017" />
</scenario>
<scenario name="ControlLoss_4" type="ControlLoss" town="Town02">
<ego_vehicle x="27" y="110" z="0.22" yaw="0" model="vehicle.lincoln.mkz_2017" />
</scenario>
<scenario name="ControlLoss_5" type="ControlLoss" town="Town02">
<ego_vehicle x="54.8" y="307.2" z="0.22" yaw="0" model="vehicle.lincoln.mkz_2017" />
</scenario>
<scenario name="ControlLoss_6" type="ControlLoss" town="Town02">
<ego_vehicle x="57.4" y="191.7" z="0.5" yaw="0" model="vehicle.lincoln.mkz_2017" />
</scenario>
<scenario name="ControlLoss_7" type="ControlLoss" town="Town03">
<ego_vehicle x="15" y="207.5" z="2" yaw="0" model="vehicle.lincoln.mkz_2017" />
</scenario>
<scenario name="ControlLoss_8" type="ControlLoss" town="Town03">
<ego_vehicle x="-74" y="-12" z="0.1" yaw="270" model="vehicle.lincoln.mkz_2017" />
</scenario>
<scenario name="ControlLoss_9" type="ControlLoss" town="Town03">
<ego_vehicle x="-85.1" y="-87.4" z="0.3" yaw="89" model="vehicle.lincoln.mkz_2017" />
</scenario>
<scenario name="ControlLoss_10" type="ControlLoss" town="Town04">
<ego_vehicle x="218.4" y="193" z="0" yaw="338" model="vehicle.lincoln.mkz_2017" />
</scenario>
<scenario name="ControlLoss_11" type="ControlLoss" town="Town04">
<ego_vehicle x="-40.4" y="-229.5" z="0" yaw="131" model="vehicle.lincoln.mkz_2017" />
</scenario>
<scenario name="ControlLoss_12" type="ControlLoss" town="Town04">
<ego_vehicle x="-45" y="37.2" z="11" yaw="0" model="vehicle.lincoln.mkz_2017" />
</scenario>
<scenario name="ControlLoss_13" type="ControlLoss" town="Town05">
<ego_vehicle x="90.9" y="-66" z="0" yaw="67" model="vehicle.lincoln.mkz_2017" />
</scenario>
<scenario name="ControlLoss_14" type="ControlLoss" town="Town05">
<ego_vehicle x="-54.7" y="110.9" z="0.1" yaw="90" model="vehicle.lincoln.mkz_2017" />
</scenario>
<scenario name="ControlLoss_15" type="ControlLoss" town="Town05">
<ego_vehicle x="119.1" y="-142.7" z="0.1" yaw="-170" model="vehicle.lincoln.mkz_2017" />
<scenario name="ControlLoss_1" type="ControlLoss" town="Town10HD_Opt">
<ego_vehicle x="-17" y="140" z="0.5" yaw="0" model="vehicle.lincoln.mkz" />
</scenario>
</scenarios>
23 changes: 0 additions & 23 deletions srunner/examples/FreeRide.xml

This file was deleted.

7 changes: 0 additions & 7 deletions srunner/examples/NoSignalJunction.xml

This file was deleted.

6 changes: 6 additions & 0 deletions srunner/examples/OppositeVehicleRunningRedLight.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0"?>
<scenarios>
<scenario name="OppositeVehicleRunningRedLight_1" type="OppositeVehicleRunningRedLight" town="Town10HD_Opt">
<ego_vehicle x="23.1" y="13.0" z="0" yaw="180" model="vehicle.lincoln.mkz" />
</scenario>
</scenarios>
17 changes: 17 additions & 0 deletions srunner/examples/ParkingExit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<scenarios>
<scenario name="ParkingExit_1" type="ParkingExit" town="Town10HD_Opt">
<ego_vehicle x="46.7" y="13.4" z="0" yaw="180" model="vehicle.lincoln.mkz"/>
<start_actor_flow x="81.8" y="13.4" z="0"/>
<end_actor_flow x="14.5" y="13.4" z="0"/>
<front_vehicle_distance value="9"/>
<behind_vehicle_distance value="9"/>
<flow_speed value="5"/>
<flow_distance value="20"/>
</scenario>
<scenario name="ParkingExit_2" type="ParkingExit" town="Town10HD_Opt">
<ego_vehicle x="-104" y="61" z="0" yaw="-90" model="vehicle.lincoln.mkz"/>
<direction value='right'/>
</scenario>
</scenarios>

21 changes: 4 additions & 17 deletions srunner/examples/SignalizedJunctionLeftTurn.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
<?xml version="1.0"?>
<scenarios>
<scenario name="SignalizedJunctionLeftTurn_1" type="SignalizedJunctionLeftTurn" town="Town03">
<ego_vehicle x="-133.7" y="137.4" z="0.2" yaw="0" model="vehicle.lincoln.mkz_2017" />
</scenario>
<scenario name="SignalizedJunctionLeftTurn_2" type="SignalizedJunctionLeftTurn" town="Town04">
<ego_vehicle x="202.8" y="-209.8" z="0.3" yaw="270" model="vehicle.lincoln.mkz_2017" />
</scenario>
<scenario name="SignalizedJunctionLeftTurn_3" type="SignalizedJunctionLeftTurn" town="Town04">
<ego_vehicle x="274.1" y="-246.2" z="0.3" yaw="0" model="vehicle.lincoln.mkz_2017" />
</scenario>
<scenario name="SignalizedJunctionLeftTurn_4" type="SignalizedJunctionLeftTurn" town="Town05">
<ego_vehicle x="-145.5" y="-1" z="0.3" yaw="180" model="vehicle.lincoln.mkz_2017" />
</scenario>
<scenario name="SignalizedJunctionLeftTurn_5" type="SignalizedJunctionLeftTurn" town="Town05">
<ego_vehicle x="-76.5" y="-0.8" z="0.3" yaw="180" model="vehicle.lincoln.mkz_2017" />
</scenario>
<scenario name="SignalizedJunctionLeftTurn_6" type="SignalizedJunctionLeftTurn" town="Town05">
<ego_vehicle x="76.4" y="83" z="0.3" yaw="157" model="vehicle.lincoln.mkz_2017" />
<scenario name="SignalizedJunctionLeftTurn_1" type="SignalizedJunctionLeftTurn" town="Town10HD_Opt">
<ego_vehicle x="10" y="16.9" z="0.0" yaw="180" model="vehicle.lincoln.mkz" />
<flow_speed value="10"/>
<source_dist_interval from="15" to="50"/>
</scenario>
</scenarios>
9 changes: 9 additions & 0 deletions srunner/examples/StaticCutIn.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<scenarios>
<scenario name="StaticCutIn_1" type="StaticCutIn" town="Town10HD_Opt">
<ego_vehicle x="-24" y="-61" z="0" yaw="0" model="vehicle.lincoln.mkz"/>
<direction value='right'/>
<distance value='50'/>
</scenario>
</scenarios>

5 changes: 3 additions & 2 deletions srunner/examples/VehicleOpensDoor.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0"?>
<scenarios>
<scenario name="VehicleOpensDoorTwoWays_1" type="VehicleOpensDoorTwoWays" town="Town10HD_Opt">
<ego_vehicle x="-19.4" y="69.5" z="0.3" yaw="0" model="vehicle.lincoln.mkz_2017" />
<direction value="right"/>
<ego_vehicle x="84.4" y="124.1" z="0.3" yaw="150" model="vehicle.lincoln.mkz" />
<distance value="50"/>
<frequency from="25" to="90"/>
</scenario>
</scenarios>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 1 addition & 22 deletions srunner/scenariomanager/carla_data_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,21 +610,6 @@ def check_attribute_value(blueprint, name, value):

return False

_actor_blueprint_categories = {
'car': 'vehicle.tesla.model3',
'van': 'vehicle.volkswagen.t2',
'truck': 'vehicle.carlamotors.carlacola',
'trailer': '',
'semitrailer': '',
'bus': 'vehicle.volkswagen.t2',
'motorbike': 'vehicle.kawasaki.ninja',
'bicycle': 'vehicle.diamondback.century',
'train': '',
'tram': '',
'pedestrian': 'walker.pedestrian.0001',
'misc': 'static.prop.streetbarrier'
}

# Set the model
try:
blueprints = CarlaDataProvider._blueprint_library.filter(model)
Expand All @@ -634,13 +619,7 @@ def check_attribute_value(blueprint, name, value):

blueprint = CarlaDataProvider._rng.choice(blueprints)
except ValueError:
# The model is not part of the blueprint library. Let's take a default one for the given category
bp_filter = "vehicle.*"
new_model = _actor_blueprint_categories[actor_category]
if new_model != '':
bp_filter = new_model
print("WARNING: Actor model {} not available. Using instead {}".format(model, new_model))
blueprint = CarlaDataProvider._rng.choice(CarlaDataProvider._blueprint_library.filter(bp_filter))
raise ValueError("Actor model {} not available".format(model))

# Set the color
if color:
Expand Down
22 changes: 12 additions & 10 deletions srunner/scenariomanager/scenario_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from srunner.scenariomanager.carla_data_provider import CarlaDataProvider
from srunner.scenariomanager.result_writer import ResultOutputProvider
from srunner.scenariomanager.timer import GameTime
from srunner.scenariomanager.watchdog import Watchdog
# from srunner.scenariomanager.watchdog import Watchdog


class ScenarioManager(object):
Expand Down Expand Up @@ -54,7 +54,7 @@ def __init__(self, debug_mode=False, sync_mode=False, timeout=2.0):
self._debug_mode = debug_mode
self._agent = None
self._sync_mode = sync_mode
self._watchdog = None
# self._watchdog = None
self._timeout = timeout

self._running = False
Expand All @@ -81,9 +81,9 @@ def cleanup(self):
This function triggers a proper termination of a scenario
"""

if self._watchdog is not None:
self._watchdog.stop()
self._watchdog = None
# if self._watchdog is not None:
# self._watchdog.stop()
# self._watchdog = None

if self.scenario is not None:
self.scenario.terminate()
Expand Down Expand Up @@ -121,8 +121,8 @@ def run_scenario(self):
self.start_system_time = time.time()
start_game_time = GameTime.get_time()

self._watchdog = Watchdog(float(self._timeout))
self._watchdog.start()
# self._watchdog = Watchdog(float(self._timeout))
# self._watchdog.start()
self._running = True

while self._running:
Expand Down Expand Up @@ -156,7 +156,7 @@ def _tick_scenario(self, timestamp):
if self._timestamp_last_run < timestamp.elapsed_seconds and self._running:
self._timestamp_last_run = timestamp.elapsed_seconds

self._watchdog.update()
# self._watchdog.update()

if self._debug_mode:
print("\n--------- Tick ---------\n")
Expand All @@ -182,15 +182,17 @@ def _tick_scenario(self, timestamp):
if self.scenario_tree.status != py_trees.common.Status.RUNNING:
self._running = False

if self._sync_mode and self._running and self._watchdog.get_status():
# if self._sync_mode and self._running and self._watchdog.get_status():
if self._sync_mode and self._running:
CarlaDataProvider.get_world().tick()

def get_running_status(self):
"""
returns:
bool: False if watchdog exception occured, True otherwise
"""
return self._watchdog.get_status()
return True
# return self._watchdog.get_status()

def stop_scenario(self):
"""
Expand Down
33 changes: 7 additions & 26 deletions srunner/scenarios/actor_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,20 @@
from srunner.scenariomanager.scenarioatomics.atomic_trigger_conditions import (InTriggerDistanceToLocation,
WaitEndIntersection,
WaitUntilInFrontPosition)

from srunner.scenarios.basic_scenario import BasicScenario

from srunner.tools.background_manager import (SwitchRouteSources,
ChangeOppositeBehavior,
HandleJunctionScenario,
RemoveRoadLane)
from srunner.tools.scenario_helper import get_same_dir_lanes, generate_target_waypoint_in_route

def convert_dict_to_location(actor_dict):
"""
Convert a JSON string to a Carla.Location
"""
location = carla.Location(
x=float(actor_dict['x']),
y=float(actor_dict['y']),
z=float(actor_dict['z'])
)
return location

def get_value_parameter(config, name, p_type, default):
if name in config.other_parameters:
return p_type(config.other_parameters[name]['value'])
else:
return default

def get_interval_parameter(config, name, p_type, default):
if name in config.other_parameters:
return [
p_type(config.other_parameters[name]['from']),
p_type(config.other_parameters[name]['to'])
]
else:
return default
from srunner.tools.scenario_helper import (get_same_dir_lanes,
generate_target_waypoint_in_route,
get_value_parameter,
get_interval_parameter,
convert_dict_to_location)


class EnterActorFlow(BasicScenario):
"""
Expand Down
Loading
Loading