Benchmarking simulated autonomous cars with OpenDS
To get started, you need to set up your system for OpenDS. We recommend using a recent Linux distro, as existing car controllers only work with Linux. Currently implemented cars are all implemented on Ubuntu 17/18 machines. Other Linux distros might work as well.
! Commands provided for installation below might vary depending on your environment. !
-
Install OpenJDK 1.8
sudo apt-get install openjdk-8-jdk
-
Install JavaFX/OpenJFX
sudo apt-get install openjfx
-
Clone this repository or download the zip file and extract to a folder of your choice. We call this folder
baseDir
now. -
Go to
baseDir/LearningAssets
and unpackassets.tar.xz
intoLearningAssets
folder -
Go to
baseDir/assets/Scenes/EisenbahnNew
and unpackdata.tar.xz
contents intoEisenbahnNew
folder -
Download, install, and start IntelliJ (Eclipse might work too).
https://www.jetbrains.com/idea/download/#section=linux
You can start/install Intellij by running
IntellijFolder/bin/idea.sh
. Import the project located atbaseDir
. (Import Project -> Create Project from existing sources -> Next -> Next -> Next -> Next -> Make sure that OpenJDK 1.8 is selected and press Next -> Finish) -
To verify the installation, run
src.eu.opends.main.Simulator
from inside IntelliJ, by right clicking the object and selecting "Run 'Simulator.main()'". After compilation, OpenDS opens and you can drive around in the 3D environment. -
If an error occurs you might need to change the Java language level to Java 8 (File -> Project structure -> Project. Set Project language level to "8 - Lambdas, type annotations etc.")
To run the existing car controllers, additional software is required.
-
A C++11 compatible compiler is required. IS-DESPOT-p has been developed using g++ 7.3.0. Newer version might work too.
sudo apt-get install build-essential
-
Makefile
sudo apt-get install make
-
Navigate to
baseDir/ISDESPOT/isdespot-car-sim-master/is-despot
and runmake
-
Navigate to
baseDir/ISDESPOT/isdespot-car-sim-master/is-despot/problems/isdespotp_car
and runmake
. This will create a binarycar
.
-
A C++11 compatible compiler is required. The reactive controller has been developed using g++ 7.3.0. Newer version might work too.
sudo apt-get install build-essential
-
Makefile
sudo apt-get install make
-
Navigate to
baseDir/ISDESPOT/reactive-smart/is-despot
and runmake
-
Navigate to
baseDir/ISDESPOT/reactive-smart/is-despot/problems/reactive_car
and runmake
. This will create a binarycar
.
-
Install Python3 if not installed. A recent Ubuntu distro should have Python3 already installed. Type
python3
to verify. NavA3C-p has been developed using Python 3.6 -
Install pip3 if not installed.
sudo apt install python3-pip
-
Additionally install following python libraries:
- numpy
- matplotlib
- scipy
- scikit-image
- ipython
- jupyter
- pandas
- sympy
- nose
Libraries can be installed with
pip3 install --user numpy scipy matplotlib ipython jupyter pandas sympy nose scikit-image
or
pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose scikit-image
depending on how your Python installation is called.
-
Install TensorFlow. NavA3C-p is implemented using Tensorflow 1.8. Newer versions might work too.
-
For general TensorFlow installation instructions:
https://www.tensorflow.org/install/pip
-
TensorFlow CPU might be fast enough for simple testing. For training and testing with multiple instances, Tensorflow GPU is recommended. All tests were performed with the GPU version installed. You might need to change the settings to make CPU version compatible.
-
To install TensorFlow 1.8 (CPU) run
pip3 install tensorflow==1.8
or to install the GPU version run
pip3 install tensorflow-gpu==1.8
-
Tensorflow GPU additionally requires CUDA 9.0 and cuDNN 7.0
-
See NavA3C-p.
See NavA3C-p. Additionally:
-
Navigate to
baseDir/ISDESPOT/smart-car-sim-master/is-despot
and runmake
-
Navigate to
baseDir/ISDESPOT/smart-car-sim-master/is-despot/problems/hybridVisual_car
and runmake
. This will create a binarycar
.
Existing car controllers can be run using their predefined helper classes located in baseDir/tools/
. There are 5 variables you can change:
- MAX_INSTANCES: Number of instances to run simultanously. Not for !ADRQN/HyLEAP!
- type: Experiment to run. This can be any of Varying ped. speeds and crossing distances
(= SPEED_DISTANCE)
, pedestrian walking in ZigZag line(= ZIGZAG_FOLLOW)
, or multiple pedestrians crossing the street(= MULTIPLE_PEDESTRIANS)
- mode: Running the simulation in testing mode
(= TESTING)
or training mode(= TRAINING)
- TRAINING_SET: The scenario to run.
- Parameter: Pedestrian crossing the street from
LEFT
orRIGHT
- Parameter: Intersection type. Car approaching an intersection
(= APPROACHING)
, leaving an instersection(= LEAVING)
, or no intersecton(= NONE)
- Parameter: Is the car turning on an intersection. If
true
, the other two parameters are ignored.
- Parameter: Pedestrian crossing the street from
- obstaclePosition: How to occlude the pedestrian. Obstacles can be on the street
(= ON_STREET),
on the pavement(= ON_PAVEMENT)
or no obstacle at all(= NONE)
- Run
StartupISDESPOTp.java
inside Intellij
- Run
StartupReactiveCar.java
inside Intellij
- Run
StartupNavA3Cp.java
inside Intellij - Make sure that
baseDir/Python/GA3C-DeepNavigationWithNavigation/Config.py
has the same number of agents set. - Run
python3 baseDir/Python/GA3C-DeepNavigationWithNavigation/GA3C.py
- Run
StartupADRQNp.java
inside Intellij - Run
python3 baseDir/Python/main_ADRQNp.py
- Run
python3 baseDir/Python/main_hybridVisual.py
- Run
StartupHybridCar.java
inside Intellij
OpenDS-CTS01 has two java source folders:
baseDir/src
: Contains mostly OpenDS related classes. The most important ones are located ineu/opends/main
(contains the simulator itself) andeu/opends/settingsController
(handles external connections in OpenDS; can be modified to generate new observations or add new car control)baseDir/tools/settingscontroller_client/src
: Contains the car controllers located inControllers
, path planner inPathPlanning
, and the evaluator inEvaluation
.
- You can modify the simulation parameters by setting one or multiple variables in the constructor of your OpenDS controller
Parameter name | Type | Description |
---|---|---|
MAX_TRIALS | Integer | Number of trials per scene when testing your application. After MAX_TRIALS trials the next scene is tested. (Only TESTING mode) |
MAX_SPEED | Float | The maximum speed the car is allowed to drive. Acceleration actions that try to go beyond this speed are ignored. |
observationDelimiter | String | The delimiter between the observation part of the message your external application receives |
useCarIntention | Boolean | Whether your external application wants to receive the carIntention as part of the message. |
If you are working with your own controller you can change the tested scenario and the simulation mode by setting type
, mode
, TRAINING_SET
, as defined above. Note, that you need to modify the values set in the Simulator class to be the same. It might be a good idea to implement your own helper class in the style of the Startup*
classes to set these values automatically.
-
Car controllers are defined inside
baseDir/tools/settingscontroller_client/src/Controllers
. Methods are mapped to controllers as follows: -
IS-DESPOT-p uses the ISDESPOTController class.
-
ADRQN-p/NavA3C-p both use the DiscretizedController class.
-
HyLEAP uses the HybridController class.
-
The reactive controller uses the ReactiveController class.
-
Additionally, many simulation and car related variables are defined inside the
baseDir/tools/settingscontroller_client/src/Parameters
.
-
To create your own controller, start by creating a new class inside
baseDir/tools/settingscontroller_client/src/Controllers
and extendingAbstractController
. We call the new controllerMySimpleController
-
To make your controller runnable, add a main function:
public static void main(String[] args) throws IOException { new MySimpleController().initController(); while (true) { try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } }
This will create an initialize an instance of your controller (load cost map, path planner, ...)
-
For testing purposes, we overwrite the existing
chooseAction
method. This function takes the current observation (location, rotation, speed of the car, and position of pedestrians) + the angle planned by the path planner and returns an action of the car to execute.@Override public AbstractAction chooseAction(SubscribedValues currentObservation, float plannedAngle){ return new SimpleAction(plannedAngle, ACCELERATE); }
In this example, we simply use the planned angle of the path planner and accelerate. This method is only used for simple testing. For non-toy examples, there is a Socket connection opened automatically. You can write your own controller applications and connect them to your OpenDS controller on port
CONTROLLER_PORT [= 1245]
. As soon as your external application is ready, you can send aRESET\n
message to reset the current scene. Observations will be send to this port and the controller needs to send back an text answer. -
Observations have the following form:
terminal;reward;converted_angle;observation[;car_intention]
where
- terminal: Is the current state a terminal state
- reward: The last received reward
- converted_angle: The planned steering angle between -1 and 1
- observation: The current oversvation of the form
carPositionX,carPositionY,carSpeed,ped_1.x,ped_1.y,...,ped_n.x,ped_n.z
where n is the number of pedestrians - car_intention: The car intention image of size 1001003, separated by
,
. Needs to be enabled by settinguseCarIntention = true
in your controller.
-
By default, an answer of the form
angle,acc
, where angle is a steering angle \in [-40, 40] and acc is an acceleration action \in {0,1,2}, where0 = ACCELERATE
,1 = MAINTAIN
,2 = DECELLERATE
is expected. To change the way the answer is processed on the Java side, overwrite thegetAction
method.@Override public AbstractAction getAction(String answer, float plannedAngle) { return SimpleAction(answer); }
You can also create your own action by implementing the baseDir/tools/settingscontroller_client/src/Actions/AbstractAction
interface.
-
To finish, you can implement your own reward function by overwriting the
calculateReward
method.@Override public Reward calculateReward(SubscribedValues currentState, AbstractAction lastAction, SubscribedValues lastState){ Reward r = new Reward(); r.reward = -1; return r; }
This reward will be computed automatically and is send back to your controller in the next iteration. By default the reward is always
0
. You can manually add new final states by settingr.terminal = true
. If the goal is reached, this will be set automatically. -
As soon as you have reached a terminal state, indicated by the
terminal
variable in the observation, you can process your results and then sendRESET\n
to reset the scene and continue. -
To run your new car, first start up the simulator and then continue with your controller. Finally, connect with your external program.
-
Only when testing your application (not as in testing the performance): To manually reset the scene use L, to continue with the next scene use K
You can modify existing scenarios by editing the corresponding OpenDS DrivingTasks inside baseDir/assets/DrivingTasks/Projects
. Note that this will change the scenario for all controllers automatically. You can only edit the starting positions, waypoints and segments of the pedestrians. For the movement speed variable is only used for the multiple pedestrian exerpiments in test mode and the zigzag experiment. For the Speed/Distance experiment, the movement speed is set by OpenDS online.