From c01492c4a2ccd7d3d900ec089a79a54f694f075b Mon Sep 17 00:00:00 2001 From: nsubiron Date: Sat, 18 Nov 2017 20:23:59 +0100 Subject: [PATCH] Fix #31 Make CARLA start without client by default --- Docs/carla_settings.md | 5 -- Docs/how_to_build_on_linux.md | 2 +- Docs/how_to_run.md | 54 +++++++++++-------- Docs/troubleshooting.md | 11 ++-- Setup.sh | 3 +- .../Source/Carla/Settings/CarlaSettings.cpp | 3 ++ .../Source/Carla/Settings/CarlaSettings.h | 2 +- 7 files changed, 46 insertions(+), 34 deletions(-) diff --git a/Docs/carla_settings.md b/Docs/carla_settings.md index e5f13faf2..dca898a19 100644 --- a/Docs/carla_settings.md +++ b/Docs/carla_settings.md @@ -16,8 +16,3 @@ hierarchy overriding earlier values. Take a look at the [CARLA Settings example][settingslink]. [settingslink]: https://github.com/carla-simulator/carla/blob/master/Docs/Example.CarlaSettings.ini - -!!! tip - If you are in editor, you most probably want to disable networking. - Otherwise the game will hang until a client connects. Set - `UseNetworking=false` in "./Unreal/CarlaUE4/Config/CarlaSettings.ini". diff --git a/Docs/how_to_build_on_linux.md b/Docs/how_to_build_on_linux.md index 63410be08..537ffc9b0 100644 --- a/Docs/how_to_build_on_linux.md +++ b/Docs/how_to_build_on_linux.md @@ -6,7 +6,7 @@ How to build CARLA on Linux Install the build tools and dependencies - $ sudo apt-get install build-essential clang-3.9 git cmake ninja-build python3-pip python3-requests python-dev tzdata curl wget unzip autoconf libtool + $ sudo apt-get install build-essential clang-3.9 git cmake ninja-build python3-pip python3-requests python-dev tzdata sed curl wget unzip autoconf libtool $ sudo pip3 install protobuf To avoid compatibility issues between Unreal Engine and the CARLA dependencies, diff --git a/Docs/how_to_run.md b/Docs/how_to_run.md index 0fdad66a8..60b82f131 100644 --- a/Docs/how_to_run.md +++ b/Docs/how_to_run.md @@ -7,11 +7,27 @@ CARLA Simulator Welcome to CARLA simulator. This file contains the instructions to run the CARLA simulator binaries on -Linux. [Get the latest release here.][releaselink] +Linux. + +[Get the latest release here.][releaselink] For building CARLA from source, please check out the [CARLA Documentation][docslink]. +CARLA can be run directly by running the "CarlaUE4.sh" script provided in the +release package. + +There are currently two scenarios available, the desired scenario can be chosen +from the command-line + + $ ./CarlaUE4.sh /Game/Maps/Town01 + +or + + $ ./CarlaUE4.sh /Game/Maps/Town02 + +To run CARLA as server, see ["Running the server"](#running-the-server) below. + [releaselink]: https://github.com/carla-simulator/carla/releases/latest [docslink]: http://carla.readthedocs.io @@ -45,41 +61,33 @@ Run the help command to see options available Running the server ------------------ -!!! note - By default the game starts in networking mode. It will hang until a client - is connected. See below how to run it without client. +The server can be started by running the `CarlaUE4.sh` script with some extra +arguments. When run in server mode (controlled by the CARLA client), it is +highly recommended to run it at fixed time-step -The server can be started by running the `CarlaUE4.sh` script. When run in -networking mode (controlled by the CARLA client), it is highly recommended to -run it at fixed time-step - - $ ./CarlaUE4.sh /Game/Maps/Town01 -benchmark -fps=15 + $ ./CarlaUE4.sh /Game/Maps/Town01 -carla-server -benchmark -fps=15 The arguments `-benchmark -fps=15` make the engine run at a fixed time-step of 1/15 seconds. In this mode, game-time decouples from real-time and the simulation runs as fast as possible. -To run the game on the second city, just change the command to select the -"Town02" +To run the game on the second town, just change the command to select the +"Town02" map - $ ./CarlaUE4.sh /Game/Maps/Town02 -benchmark -fps=15 + $ ./CarlaUE4.sh /Game/Maps/Town02 -carla-server -benchmark -fps=15 -To run the game windowed at a given resolution +When run as server is sometimes useful to run the game in a smaller window, this +can be chosen with - $ ./CarlaUE4.sh /Game/Maps/Town01 -benchmark -fps=15 -windowed -ResX=800 -ResY=600 + $ ./CarlaUE4.sh /Game/Maps/Town01 -carla-server -benchmark -fps=15 -windowed -ResX=800 -ResY=600 -The game can also be run without a client, this way you can drive around the -city just using the keyboard (in this mode is not recommended to use fixed -frame-rate to get a more realistic feeling) - - $ ./CarlaUE4.sh /Game/Maps/Town02 -carla-no-networking - -#### CARLA command-line options +#### CARLA specific command-line options + * `-carla-server` Launches CARLA as server, the execution hangs until a client connects. * `-carla-settings=` Load settings from the given INI file. See Example.CarlaSettings.ini. - * `-carla-world-port=` Listen for client connections at , agent ports are set to +1 and +2 respectively. Activates networking. - * `-carla-no-networking` Disable networking. Overrides other settings. + * `-carla-world-port=` Listen for client connections at , agent ports are set to +1 and +2 respectively. Activates server. * `-carla-no-hud` Do not display the HUD by default. + * `-carla-no-networking` Disable networking. Overrides `-carla-server` if present. #### Running CARLA off-screen diff --git a/Docs/troubleshooting.md b/Docs/troubleshooting.md index 91880e9f3..3302d9829 100644 --- a/Docs/troubleshooting.md +++ b/Docs/troubleshooting.md @@ -3,9 +3,14 @@ Troubleshooting #### Editor hangs after hitting Play -By default, when CARLA is started it waits for a client to be connected and -control the vehicle. This is the intended behavior. This can be changed in -"./Unreal/CarlaUE4/Config/CarlaSettings.ini" changing `UseNetworking=false`. +This is most probably happening because CARLA is started in server mode. Check +in your CarlaSettings.ini file ("./Unreal/CarlaUE4/Config/CarlaSettings.ini") +and set + +```ini +[CARLA/Server] +UseNetworking=false +``` #### Very low FPS in editor when not in focus diff --git a/Setup.sh b/Setup.sh index 13ebabb9c..2835a27a3 100755 --- a/Setup.sh +++ b/Setup.sh @@ -175,7 +175,8 @@ popd >/dev/null CARLA_SETTINGS_FILE="./Unreal/CarlaUE4/Config/CarlaSettings.ini" if [[ ! -f $CARLA_SETTINGS_FILE ]]; then - cp -v ./Docs/Example.CarlaSettings.ini $CARLA_SETTINGS_FILE + echo "Copying CarlaSettings.ini..." + sed -e 's/UseNetworking=true/UseNetworking=false/' ./Docs/Example.CarlaSettings.ini > $CARLA_SETTINGS_FILE fi ./Util/Protoc.sh diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Settings/CarlaSettings.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Settings/CarlaSettings.cpp index 881d5f1d5..1bf356806 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Settings/CarlaSettings.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Settings/CarlaSettings.cpp @@ -155,6 +155,9 @@ void UCarlaSettings::LoadSettings() } // Override settings from command-line. { + if (FParse::Param(FCommandLine::Get(), TEXT("carla-server"))) { + bUseNetworking = true; + } uint32 Value; if (FParse::Value(FCommandLine::Get(), TEXT("-world-port="), Value) || FParse::Value(FCommandLine::Get(), TEXT("-carla-world-port="), Value)) { diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Settings/CarlaSettings.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Settings/CarlaSettings.h index 8ce73bb0b..37d130c32 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Settings/CarlaSettings.h +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Settings/CarlaSettings.h @@ -70,7 +70,7 @@ public: /** If active, wait for the client to connect and control the pawn. */ UPROPERTY(Category = "CARLA Server", VisibleAnywhere) - bool bUseNetworking = true; + bool bUseNetworking = false; /** World port to listen for client connections. */ UPROPERTY(Category = "CARLA Server", VisibleAnywhere, meta = (EditCondition = bUseNetworking))