Skip to content

Commit

Permalink
Merge branch 'master' into feature/variable_frame_rate
Browse files Browse the repository at this point in the history
  • Loading branch information
glopezdiest authored Apr 26, 2024
2 parents 0ef9115 + 459eead commit a7d2d88
Show file tree
Hide file tree
Showing 308 changed files with 106,549 additions and 21,154 deletions.
6 changes: 5 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ mkdocs:

formats: all

build:
os: ubuntu-22.04
tools:
python: "3.7"

python:
version: 3.7
install:
- requirements: Docs/requirements.txt

Expand Down
99 changes: 94 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,12 +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 @@ -453,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
123 changes: 123 additions & 0 deletions Docs/README_OpenSCENARIO_2.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# osc2-runner

We use OpenScenario 2.0 as the scenario description language specification to design and implement the corresponding compilation system, which can automatically convert the test scenario described with OpenScenario 2.0 into a test scenario based on scenario runner, so as to use carla for autonomous driving testing.

## Installation

**1. Install JDK**

```
sudo apt install openjdk-17-jdk
```
Confirm installation:
```
$ java -version
```
Output:
```
openjdk version "17.0.5" 2022-10-18
OpenJDK Runtime Environment (build 17.0.5+8-Ubuntu-2ubuntu120.04)
OpenJDK 64-Bit Server VM (build 17.0.5+8-Ubuntu-2ubuntu120.04, mixed mode, sharing)
```

**3、Install Antlr 4.10.1**

```
sudo apt install curl
curl -O https://www.antlr.org/download/antlr-4.10.1-complete.jar
```

Put the .jar file into local/lib
```
$ sudo cp antlr-4.10.1-complete.jar /usr/local/lib/
```

The following three steps are used to configure environment variables and create aliases so that antlr4 can be easily used from the command line.
```
$ sudo gedit ~/.bashrc
```
Add the following at the end:
```
export CLASSPATH=".:/usr/local/lib/antlr-4.10.1-complete.jar:$CLASSPATH"
alias antlr4='java -jar /usr/local/lib/antlr-4.10.1-complete.jar'
alias grun='java org.antlr.v4.gui.TestRig'
```
And then:
```
source ~/.bashrc
```

Enter antlr4 for verifying in the terminal:
```
$ antlr4
ANTLR Parser Generator Version 4.10.1
-o ___ specify output directory where all output is generated
-lib ___ specify location of grammars, tokens files
-atn generate rule augmented transition network diagrams
-encoding ___ specify grammar file encoding; e.g., euc-jp
-message-format ___ specify output style for messages in antlr, gnu, vs2005
-long-messages show exception details when available for errors and warnings
-listener generate parse tree listener (default)
-no-listener don't generate parse tree listener
-visitor generate parse tree visitor
-no-visitor don't generate parse tree visitor (default)
-package ___ specify a package/namespace for the generated code
-depend generate file dependencies
-D<option>=value set/override a grammar-level option
-Werror treat warnings as errors
-XdbgST launch StringTemplate visualizer on generated code
-XdbgSTWait wait for STViz to close before continuing
-Xforce-atn use the ATN simulator for all predictions
-Xlog dump lots of logging info to antlr-timestamp.log
-Xexact-output-dir all output goes into -o dir regardless of paths/package
```

**4、Install antlr4 runtime**
```
pip install antlr4-python3-runtime==4.10
```

**5、Install python dependency**
```
pip install -r requirements.txt
```

**6.Install graphviz**

```
sudo apt-get install graphviz
```


**7、Configurate carla**

(1) Download [carla release](https://carla-releases.s3.eu-west-3.amazonaws.com/Linux/CARLA_0.9.13.tar.gz)


(2) Extract the carla installation package to a directory.

On Ubuntu systems, the Carla environment variable is configured as follows:
```bash
export CARLA_ROOT=/home/dut-aiid/CARLA_0.9.13
export PYTHONPATH=$PYTHONPATH:${CARLA_ROOT}/PythonAPI/carla/dist/carla-0.9.13-py3.7-linux-x86_64.egg:${CARLA_ROOT}/PythonAPI/carla/agents:${CARLA_ROOT}/PythonAPI/carla/agents/navigation:${CARLA_ROOT}/PythonAPI/carla:${CARLA_ROOT}/PythonAPI/examples:${CARLA_ROOT}/PythonAPI
```

## Quickstart

**1、Run carla**

```bash
cd /home/xxx/CARLA_0.9.13
./CarlaUE4.sh
```

**2、Start manual_control**

```
python manual_control.py -a --rolename=ego_vehicle
```

**3、Run a OpenSCENARIO 2.0 scenario**
```
python scenario_runner.py --sync --openscenario2 srunner/examples/cut_in_and_slow_right.osc --reloadWorld
```
18 changes: 18 additions & 0 deletions Docs/getting_scenariorunner.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,24 @@ set PYTHONPATH=%PYTHONPATH%;%CARLA_ROOT%\PythonAPI\carla

To permanently set the environment variables, go to *edit the environment variables of this account*. This can be quickly accessed by writing *env* on the Windows' search panel.

If you need to run the scenario based on the OpenSCENARIO 2.0 format, please install graphviz and antlr first:
```
sudo apt-get install -y openjdk-17-jdk graphviz
curl -O https://www.antlr.org/download/antlr-4.10.1-complete.jar
sudo cp antlr-4.10.1-complete.jar /usr/local/lib/
sudo gedit ~/.bashrc
```
Add environment variables into ~/.bashrc:
```
export CLASSPATH=".:/usr/local/lib/antlr-4.10.1-complete.jar:$CLASSPATH"
alias antlr4='java -jar /usr/local/lib/antlr-4.10.1-complete.jar'
alias grun='java org.antlr.v4.gui.TestRig'
```
And make the changes into effect:
```
source ~/.bashrc
```

---
## Run a test

Expand Down
13 changes: 13 additions & 0 deletions Docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ python scenario_runner.py --openscenario <path/to/xosc-file>
Please note that the OpenSCENARIO support and the OpenSCENARIO format itself are still work in progress.
More information you can find in [OpenSCENARIO support](openscenario_support.md)

## Running scenarios using the OpenSCENARIO 2.0 format
To run a scenario, which is based on the OpenSCENARIO 2.0 format, please run the ScenarioRunner as follows:
```
python scenario_runner.py --openscenario2 <path/to/osc-file>
```

To control the ego vehicle within the scenario or observe it, open another terminal and run:
```
python manual_control.py -a --rolename=ego_vehicle
```

For more information about how to run a OpenSCENARIO 2.0 scenario, please refer to [README_OpenSCENARIO_2.0](README_OpenSCENARIO_2.0.md)

### Running scenarios using the OpenSCENARIO format with Global ParameterDeclaration overwrite
```
python scenario_runner.py --openscenario <path/to/xosc-file> --openscenarioparams 'param1: value1, param2: value2'
Expand Down
Binary file added Docs/img/metrics_example.jpg~
Binary file not shown.
2 changes: 1 addition & 1 deletion Docs/metrics_module.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ Returns a dictionary where the keys are the frame number, and the values are the

- <a name="get_vehicle_control"></a>__<font color="#7fb800">get_vehicle_control</font>__(<font color="#00a6ed">__self__</font>, <font color="#00a6ed">__vehicle_id__</font>, <font color="#00a6ed">__frame__</font>)
Returns the control of a vehicle at a given frame. The `manual_gear_shift` attribute will always be False.
- __Return —__ [carla.VehicleCotnrol](https://carla.readthedocs.io/en/latest/python_api/#carlavehiclecontrol)
- __Return —__ [carla.VehicleControl](https://carla.readthedocs.io/en/latest/python_api/#carlavehiclecontrol)
- __Parameters__
- `vehicle_id` (_int_) — `id` of the vehicle.
- `frame` (_int_) — Frame number.
Expand Down
Loading

0 comments on commit a7d2d88

Please sign in to comment.