Skip to content

Commit

Permalink
Release 0.9.15 merge (#1032)
Browse files Browse the repository at this point in the history
* New parsing (#858)

* Improved junction scenarios to work on routes

* Added basic agent to the SyncArrival behavior

* Improved all routes

* Updated to use new route planner

* Improved synchornization for S7 adn S9

* WIP: Added new background activity

* Minor fixes

* Planner changes

* Added compatibility with CARLA 0.9.12

* Pretty code

* Changed S9 to an actor flow

* Improved synchronization of crossing scenarios

* WIP: Improve synchronization

* First working behavior

* Fixed other leading vehicle scenario speed bug

* Created new S2 for routes and added it to routes

* Better ControlLoss + fix missplaced route scenarios

* Improved actor flows with new  python agent

* Minor fixes

* Cleanup and some example changes

* Added CHANGELOG

* Removed unused atomic behaviors

* Pretty code

* Added missing BA code

* Removed constant velocity agent

* Added other parameters

* Pretty code

* Fixed CHANGELOG

* Pretty code

* Fixed sceario parsing bug

* Minor fixes

* CHANGELOG

* Minor fixes

* Fixed bug with agent's route

* Improve actor flow scenarios (#859)

* Improved actor flow behavior

* CHANGELOG

Co-authored-by: Guillermo <[email protected]>

* Changes in Actor Flow, implementation of Accident and Construction, changes to BA (#863)

* Initial testing

* Changed ActorFlow to Town04

* WIP: ActorFLow at routes

* WIP2: Actor Flow

* Changes to Accident and Construction blocking scenarios
Implementation of chages in BA to allow TM lane changes through set_path

* Improve road behavior, actor flow and accident scenarios

* Construction scenario implementation

Co-authored-by: Guillermo <[email protected]>

* Changed ActorFlow to use the TrafficManager

* Routes can now have scenario specific criterias

* Scenarios are now route specific

* Added urban bicycle flow prototype

* Added CHANGELOG (#870)

Co-authored-by: Guillermo <[email protected]>

* Added VehicleOpensDoor scenario

* Minor changes

* Fixed bug with new JucntionScenarioManager (#873)

Co-authored-by: Guillermo <[email protected]>

* Added dynamic weathers to routes

* Improved traffic event handling (#877)

Co-authored-by: Guillermo <[email protected]>

* Added HighwayExit scenario

* Added minimum speed criteria

* Pretty code

* New Parking Exit scenario

* General improvements (#884)

Co-authored-by: Guillermo <[email protected]>

* Improve bycicle flow scenario

* Changed BA 'RemoveLane' for 'SwitchLane'

* New LB2.0 scenario improvements

* Refined BA's target speed

Co-authored-by: Guillermo <[email protected]>

* Added HighwayCutIn scenario

* Improved HighwayCutIn

* CHANGELOG

Co-authored-by: Guillermo <[email protected]>

* Added Idle (#898)

Co-authored-by: Guillermo <[email protected]>

* Added ParkingCutIn scenario

* New MergerIntoSlowTraffic scenario

* Updated  _remove_junction_entry

* Update highway_cut_in.py

* Added MergerIntoSlowTraffic scenario

* Update background_manager.py

* Added MergerIntoSlowTraffic route

* Added MergerIntoSlowTraffic scenario

* Improve night mode (#902)

* Added lights beahvior to rotues

* Improved lights and automatic TM lights

Co-authored-by: Guillermo <[email protected]>

* Add yield to emergency vehicle scenario

* Add new scenario PedestrianCrossing

* New Blocked intersection scenario

* Added InvadingTurn scenario

* Added Static cut in scenario

* Added BicycleAtSideLane scenario

* Improved route's timeout

* Leaderboard 2.0 scenario improvements

* Fixed several merge errors

* New scenario improvements

* Removed debug messages

* Added scenario timeouts

* Added frame to traffic events

* Added realtime to OutsideRouteLanesTest

* More Leaderboard 2.0 scenario improvements

* Route obstacles + parked vehicle destruction

* Scenarios no longer spawn old vehicles

* Added variable flow to route obstacles

* Added VehicleTurningRotue variations

* Added noise to control loss

* Route improvements

* MinSpeed criteria checkpoints + Pedestrian patch

* Fix bug PedestrianCrossing

* Fixed bug pedestrians and parked vehicles (#933)

* Added parking removal to crossing actors

* Fixed bug pedestrians and parked vehicles

* Improved pedestrian code

Co-authored-by: Guillermo <[email protected]>

* Removed old test routes

* Fixed bug with YieldtoEV criteria

* Minor parameter changes

* Improved scenarios

* Added hand brake to BlockedIntersection

* Revereted some of the constructions changes

* Some parameter changes

* Removed unused code

* Prettyfied some criteria

* Fixed units bug

* Parameter change

* Changed opposite flow parameters

* Minor robustness changes

* Removed police car from several scenarios

* Updated highway cut in parameters

* Final parameter changes + some minor BA changes

* Added vehicle opens door stop

* Fixed VehicleOpensDoor

* Added ActroFlow patch

* Minor sensor destruction change

* Changes numpy version to match CARLA's

* Minor fix

* Added tm ports to BA

* Added the port to all set autopilots

* Minor improvement to result writer and debug

* Added missing sensor destruction

* Added spawn transforms to CDP actors

* Added ratio to min speed

* fix duplicate env initialization during runtime

* check location in DriveDistance

* add is_runtime_init_mode process

* fix weather

* Added ScenariOTrigger blackboard

* removed whitespaces

* Added a lock at CDP

* Added Leaderboard 2.0 changelog

* Added Leaderboard 2.0 routes

* Fixed bug with MinimumSpeedRouteTest

* Added Release 0.9.15

---------

Co-authored-by: Guillermo <[email protected]>
Co-authored-by: Jacopo Bartiromo <[email protected]>
Co-authored-by: Tay Yim <[email protected]>
Co-authored-by: yuting <[email protected]>
Co-authored-by: dudu_fang <[email protected]>
Co-authored-by: threewater-wang <[email protected]>
Co-authored-by: joel-mb <[email protected]>
  • Loading branch information
8 people committed Nov 16, 2023
1 parent 3522896 commit d12d8bb
Show file tree
Hide file tree
Showing 67 changed files with 43,113 additions and 21,094 deletions.
93 changes: 88 additions & 5 deletions Docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Table of Contents
* [Latest Changes](#latest-changes)
* [CARLA ScenarioRunner 0.9.15](#carla-scenariorunner-0915)
* [CARLA ScenarioRunner 0.9.13](#carla-scenariorunner-0913)
* [CARLA ScenarioRunner 0.9.12](#carla-scenariorunner-0912)
* [CARLA ScenarioRunner 0.9.11](#carla-scenariorunner-0911)
Expand All @@ -12,18 +12,100 @@
* [CARLA ScenarioRunner 0.9.5](#carla-scenariorunner-095)
* [CARLA ScenarioRunner 0.9.2](#carla-scenariorunner-092)

## Latest changes
## CARLA ScenarioRunner 0.9.15
### :rocket: New Features
* Minor improvements to some example scenarios. These include FollowLeadingVehicle, VehicleTurning, DynamicObjectCrossing and SignalizedJunctionRightTurn and RunningRedLight. Their behaviors are now more smooth, robust and some outdated mechanics have been removed
* SignalizedJunctionLeftTurn has been remade. It now has an actor flow on which the ego has to merge into, instead of a single vehicle.
* The BackgroundActivity has been readded to the routes, which the objective of creating the sensation of traffic around the ego
* Add waypoint reached threshold so that the precision of the actor reaching to waypoints can be adjusted based on object types.
* OpenSCENARIO support:
- Added both init and story support for `EntityAction`
- Added story support for `TrafficSignalControllerAction`
- Added both init and story support for `LateralDistanceAction`
- Added support for `TrafficSignalControllerCondition`
* Supported OpenSCENARIO 2.0 standard.
* New scenarios:
- InvadingTurn: vehicles at the opposite direction lane partially invade the ego's one, forcing it to leave space for them,moving slightly off-center.
- EnterActorFlow: the ego has to enter a highway lane filled with incoming traffic
- MergerIntoslowtraffic. variation of `EnterActorFlow` but with slow traffic.
- InterurbanActorFlow and InterurbanAdvancedActorFlow: actor flow scenarios for the new interurban intersections with dedicated lanes present at Town12 and Town13.
- Accident: the ego is met with an accident, forcing it to lane change to avoid it.
- AccidentTwoWays: same as `Accident` but having to invade an opposite direction lane.
- ParkedObstacle: similar to `Accident` but with a parked obstacle instead.
- ParkedObstacleTwoWays: same as `ParkedObstacle` but having to invade an opposite direction lane.
- HazardAtSideLane: similar to `Accident` but with a moving group of bicycles in the rightmost park of the lane
- HazardAtSideLaneTwoWays: same as `HazardAtSideLane` but having to invade an opposite direction lane.
- ConstructionObstacleTwoWays: same as `ConstructionObstacle` but having to invade an opposite direction lane.
- VehicleOpensDoorTwoWays: similar to `Accident` but this time the blockage is cause by a vehicle opening its door.
- StaticCutIn: the ego is meant with an adversary that exits a stopped lane, cutting in front of the ego.
- ParkingCutIn: similar to `StaticCutIn` but the adversary starts at a parking lane.
- HighwayCutIn: the ego is met with a vehicle that tries to enter the highway by cutting in front of it.
- ParkingExit: Only usable at the beginning of the routes, makes the ego start at a parking lane.
- HardBreakRoute: uses the BackgroundActivity to make all vehicles in front of the ego hard break.
- YieldToEmergencyVehicle: the ego finds an emergency vehicle behind, having to lane chane to give way.
- VehicleTurningRoutePedestrian: variation of `VehicleTurningRoute` but with a pedestrian crossing instead of a bycicle.
- BlockedIntersection: with low visibility, the ego performs a turn only to find out that the end is blocked by another vehicle.
- CrossingBicycleFlow: the ego has to do a turn at an intersection but it has to cross a bycicle lane full of traffic.
- PedestrianCrossing: a group of pedestrians crossing a crosswalk. Easier version of `DynamicObjectCrossing` with no occluder.
- ParkingCrossingPedestrian: variation of `DynamicObjectCrossing`, but using a parked vehicle as the occluder.
- OppositeVehicleTakingPriority: variation of `OppositeVehicleRunningRedLight` but without traffic lights.
- NonSignalizedJunctionLeftTurn: variation of `SignalizedJunctionLeftTurn` but without traffic lights.
- NonSignalizedJunctionRightTurn: variation of `SignalizedJunctionRightTurn` but without traffic lights.
- PriorityAtJunction: utility scenario during routes to add a green traffic light at the next intersection.
- NoSignalJunctionCrossingRoute: Does nothing but wait for the ego to exit an intersection.
* Improvements to old scenarios:
- ControlLoss: Added actual noise to the ego's control (currently only during routes).
- All VehicleTurning variations: more robustness and better synchronization.
- OppositeVehicleRunningRedLight: Improvement synchronization and the opposite vehicle's behavior.
- SignalizedJunctionLeftTurn: it is now an actor flow that ego has to cross.
- SignalizedJunctionRightTurn. it is now an actor flow that the ego has to merge into.
- Renamed `ConstructionSetupCrossing` to `ConstructionObstacle`, and prepared it for routes.
* Improvements to the CarlaDataProvider:
- Added a lock when checking the dictionaries to avoid issues in multithreading
- Added the `transform` argument to all register function to avoid returning None during the first frame
- Added the `get_global_route_planner` and `get_all_actors` to avoid repeating these costly calls more than necessary
- Added `set_runtime_init_mode` and `is_runtime_init_mode`, used by the Leaderboard to initialize scenarios during the simulation
- At the `create_blueprint` function, replaced the `safe` argument with the `attribute_filter`, for a more generic parsing of any of the blueprint attributes.
- Removed the `CarlaDataProvider.get_ego_vehicle_route()` and `CarlaDataProvider.set_ego_vehicle_route()` functions as this is now information available to all scenarios.
* Improvements to the routes:
- Scenarios are no longer position based, but instead part of a route's xml.
- Routes now also include the criteria of its scenarios.
- `waypoint` have been renamed to `position` and are part of the `waypoints` category.
- More than one `weather` are allowed, creating a dynamic one based on the ego vehicle's completed percentage of the route.
- Changed the timeout to also be dependent on the distance driven by the ego vehicle.
- Added the `RouteLightsBehavior` to control of all scene and vehicle lights during runtime
- Added a new criteria for routes, `CheckMinSpeed`, that checks the ego's speed and compares it with the rest of the traffic
- Separated the route argument into two, `route` for the file path, and `route-id`, for the name of route. the functionality remains unchanged.
- Simplified the overall parsing.
* The BackgroundActivity part of the routes has been completely remade, with the objective of creating the sensation of traffic around the ego will increasing the performance
* Added a Backgroundmanager to interact with the new BackgroundActivity, to allow it to adapt to incoming scenarios
* Added new atomic behaviors:
- SyncArrivalWithAgent
- CutIn
- AddNoiseToRouteEgo
- ConstantVelocityAgentBehavior
- AdaptiveConstantVelocityAgentBehavior
- WaitForever
- BatchActorTransformSetter
- OppositeActorFlow
- InvadingActorFlow
- BicycleFlow
- OpenVehicleDoor
- SwitchWrongDirectionTest
- SwitchMinSpeedCriteria
- WalkerFlow
- AIWalkerBehavior
- ScenarioTimeout
- MovePedestrianWithEgo
* Improved the Criterion class for a more comprehensive base criteria and easier use in the `results_writer` class.
* Added new atomic criteria:
- MinimumSpeedRouteTest
- YieldToEmergencyVehicleTest
- ScenarioTimeoutTest
* Added new atomic trigger conditions
- WaitUntilInFrontPosition
* Merged the `Scenario` class into the `BasicScenario` one.
* Scenarios can now have parameters as part of the their xml definition, which is saved as a dictionary at `config.other_parameters`
* Simplified and improved how routes are parsed.
* Added the `wait-for-repetitions` argument at the manual control for a smoother transition between scenarios / repetitions
* Updated numpy's version to avoid issues with newer version of Python 3

### :bug: Bug Fixes
* Fixed bug at OtherLeadingVehicle scenario causing the vehicles to move faster than intended
Expand Down Expand Up @@ -459,3 +541,4 @@
- WaitForTrafficLightState: wait for the traffic light to have a given state
- SyncArrival: sync the arrival of two vehicles to a given target
- AddNoiseToVehicle: Add noise to steer as well as throttle of the vehicle
- CutInWithStaticVehicle:Based on the code of ParkingCutIn,realized the cutin function of a static vehicle on the highway
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ branch contains the latest fixes and features, and may be required to use the la

It is important to also consider the release version that has to match the CARLA version.

* [Version 0.9.15](https://github.com/carla-simulator/scenario_runner/releases/tag/v0.9.15) and the 0.9.15 Branch: Compatible with [CARLA 0.9.15](https://github.com/carla-simulator/carla/releases/tag/0.9.15)
* [Version 0.9.13](https://github.com/carla-simulator/scenario_runner/releases/tag/v0.9.13) and the 0.9.13 Branch: Compatible with [CARLA 0.9.13](https://github.com/carla-simulator/carla/releases/tag/0.9.13)
* [Version 0.9.12](https://github.com/carla-simulator/scenario_runner/releases/tag/v0.9.12) and the 0.9.12 Branch: Compatible with [CARLA 0.9.12](https://github.com/carla-simulator/carla/releases/tag/0.9.12)
* [Version 0.9.11](https://github.com/carla-simulator/scenario_runner/releases/tag/v0.9.11) and the 0.9.11 Branch: Compatible with [CARLA 0.9.11](https://github.com/carla-simulator/carla/releases/tag/0.9.11)
Expand Down
31 changes: 13 additions & 18 deletions manual_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
from pygame.locals import K_F1
from pygame.locals import KMOD_CTRL
from pygame.locals import KMOD_SHIFT
from pygame.locals import K_BACKSPACE
from pygame.locals import K_TAB
from pygame.locals import K_SPACE
from pygame.locals import K_UP
Expand Down Expand Up @@ -114,8 +113,6 @@ def get_actor_display_name(actor, truncate=250):

class World(object):

restarted = False

def __init__(self, carla_world, hud, args):
self.world = carla_world
try:
Expand All @@ -140,10 +137,6 @@ def __init__(self, carla_world, hud, args):

def restart(self, args):

if self.restarted:
return
self.restarted = True

self.player_max_speed = 1.589
self.player_max_speed_fast = 3.713

Expand All @@ -161,7 +154,7 @@ def restart(self, args):
print("Ego vehicle found")
self.player = vehicle
break

self.player_name = self.player.type_id

# Set up the sensors.
Expand All @@ -177,9 +170,14 @@ def restart(self, args):

self.world.wait_for_tick()

def tick(self, clock):
def tick(self, clock, wait_for_repetitions):
if len(self.world.get_actors().filter(self.player_name)) < 1:
return False
if not wait_for_repetitions:
return False
else:
self.player = None
self.destroy()
self.restart()

self.hud.tick(self, clock)
return True
Expand Down Expand Up @@ -232,13 +230,6 @@ def parse_events(self, client, world, clock):
elif event.type == pygame.KEYUP:
if self._is_quit_shortcut(event.key):
return True
elif event.key == K_BACKSPACE:
if self._autopilot_enabled:
world.player.set_autopilot(False)
world.restart()
world.player.set_autopilot(True)
else:
world.restart()
elif event.key == K_F1:
world.hud.toggle_info()
elif event.key == K_TAB:
Expand Down Expand Up @@ -917,7 +908,7 @@ def game_loop(args):
clock.tick_busy_loop(60)
if controller.parse_events(client, world, clock):
return
if not world.tick(clock):
if not world.tick(clock, args.wait_for_repetitions):
return
world.render(display)
pygame.display.flip()
Expand Down Expand Up @@ -978,6 +969,10 @@ def main():
'--keep_ego_vehicle',
action='store_true',
help='do not destroy ego vehicle on exit')
argparser.add_argument(
'--wait-for-repetitions',
action='store_true',
help='Avoids stopping the manual control when the scenario ends.')
args = argparser.parse_args()

args.width, args.height = [int(x) for x in args.res.split('x')]
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
py-trees==0.8.3
numpy==1.18.4; python_version >= '3.0'
networkx==2.2
Shapely==1.7.1
psutil
xmlschema==1.0.18
ephem
tabulate
opencv-python==4.2.0.32
numpy
matplotlib
six
simple-watchdog-timer
Expand Down
35 changes: 15 additions & 20 deletions scenario_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def __init__(self, args):
self.client = carla.Client(args.host, int(args.port))
self.client.set_timeout(self.client_timeout)
dist = pkg_resources.get_distribution("carla")
if LooseVersion(dist.version) < LooseVersion('0.9.12'):
raise ImportError("CARLA version 0.9.12 or newer required. CARLA version found: {}".format(dist))
if LooseVersion(dist.version) < LooseVersion('0.9.15'):
raise ImportError("CARLA version 0.9.15 or newer required. CARLA version found: {}".format(dist))

# Load agent if requested via command line args
# If something goes wrong an exception will be thrown by importlib (ok here)
Expand Down Expand Up @@ -236,7 +236,10 @@ def _prepare_ego_vehicles(self, ego_vehicles):

for i, _ in enumerate(self.ego_vehicles):
self.ego_vehicles[i].set_transform(ego_vehicles[i].transform)
CarlaDataProvider.register_actor(self.ego_vehicles[i])
self.ego_vehicles[i].set_target_velocity(carla.Vector3D())
self.ego_vehicles[i].set_target_angular_velocity(carla.Vector3D())
self.ego_vehicles[i].apply_control(carla.VehicleControl())
CarlaDataProvider.register_actor(self.ego_vehicles[i], ego_vehicles[i].transform)

# sync state
if CarlaDataProvider.is_sync_mode():
Expand Down Expand Up @@ -401,11 +404,11 @@ def _load_and_run_scenario(self, config):
timeout=100000)
else:
scenario_class = self._get_scenario_class_or_fail(config.type)
scenario = scenario_class(self.world,
self.ego_vehicles,
config,
self._args.randomize,
self._args.debug)
scenario = scenario_class(world=self.world,
ego_vehicles=self.ego_vehicles,
config=config,
randomize=self._args.randomize,
debug_mode=self._args.debug)
except Exception as exception: # pylint: disable=broad-except
print("The scenario cannot be loaded")
traceback.print_exc()
Expand Down Expand Up @@ -471,15 +474,8 @@ def _run_route(self):
"""
result = False

if self._args.route:
routes = self._args.route[0]
scenario_file = self._args.route[1]
single_route = None
if len(self._args.route) > 2:
single_route = self._args.route[2]

# retrieve routes
route_configurations = RouteParser.parse_routes_file(routes, scenario_file, single_route)
route_configurations = RouteParser.parse_routes_file(self._args.route, self._args.route_id)

for config in route_configurations:
for _ in range(self._args.repetitions):
Expand Down Expand Up @@ -576,11 +572,10 @@ def main():
parser.add_argument('--openscenario', help='Provide an OpenSCENARIO definition')
parser.add_argument('--openscenarioparams', help='Overwrited for OpenSCENARIO ParameterDeclaration')
parser.add_argument('--openscenario2', help='Provide an openscenario2 definition')
parser.add_argument('--route', help='Run a route as a scenario', type=str)
parser.add_argument('--route-id', help='Run a specific route inside that \'route\' file', default='', type=str)
parser.add_argument(
'--route', help='Run a route as a scenario (input: (route_file,scenario_file,[route id]))', nargs='+', type=str)

parser.add_argument(
'--agent', help="Agent used to execute the scenario. Currently only compatible with route-based scenarios.")
'--agent', help="Agent used to execute the route. Not compatible with non-route-based scenarios.")
parser.add_argument('--agentConfig', type=str, help="Path to Agent's configuration file", default="")

parser.add_argument('--output', action="store_true", help='Provide results on stdout')
Expand Down
Loading

0 comments on commit d12d8bb

Please sign in to comment.