Skip to content
Merged
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
10 changes: 8 additions & 2 deletions Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,10 @@ bool ASimHUD::getSettingsText(std::string& settingsText)
readSettingsTextFromFile(FString(msr::airlib::Settings::Settings::getUserDirectoryFullPath("settings.json").c_str()), settingsText));
}

// Attempts to parse the settings text from the command line
// Attempts to parse the settings file path or the settings text from the command line
// Looks for the flag "--settings". If it exists, settingsText will be set to the value.
// Example: AirSim.exe -s '{"foo" : "bar"}' -> settingsText will be set to {"foo": "bar"}
// Example (Path): AirSim.exe --settings "C:\path\to\settings.json"
// Example (Text): AirSim.exe -s '{"foo" : "bar"}' -> settingsText will be set to {"foo": "bar"}
// Returns true if the argument is present, false otherwise.
bool ASimHUD::getSettingsTextFromCommandLine(std::string& settingsText)
{
Expand All @@ -372,6 +373,11 @@ bool ASimHUD::getSettingsTextFromCommandLine(std::string& settingsText)
FString commandLineArgsFString = FString(commandLineArgs);
int idx = commandLineArgsFString.Find(TEXT("-settings"));
FString settingsJsonFString = commandLineArgsFString.RightChop(idx + 10);

if (readSettingsTextFromFile(settingsJsonFString.TrimQuotes(), settingsText)) {
return true;
}

Comment thread
madratman marked this conversation as resolved.
if (FParse::QuotedString(*settingsJsonFString, settingsTextFString)) {
settingsText = std::string(TCHAR_TO_UTF8(*settingsTextFString));
found = true;
Expand Down
16 changes: 12 additions & 4 deletions docs/settings.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
# AirSim Settings

## Where are Settings Stored?
Windows: `Documents\AirSim`
Linux: `~/Documents/AirSim`

The file is in usual [json format](https://en.wikipedia.org/wiki/JSON). On first startup AirSim would create `settings.json` file with no settings. To avoid problems, always use ASCII format to save json file.
AirSim is searching for the settings definition in 4 different ways in the following order. The first match will be used:

1. Looking at the (absolute) path specified by the `--settings` command line argument.
For example, in Windows: `AirSim.exe --settings 'C:\path\to\settings.json'`
In Linux `./Blocks.sh --settings '/home/$USER/path/to/settings.json'`
1. Looking for a json document passed as a command line argument by the `--settings` argument.
For example, in Windows: `AirSim.exe --settings '{"foo" : "bar"}'`
In Linux `./Blocks.sh --settings '{"foo" : "bar"}'`
1. Looking in the folder of the executable for a file called `settings.json`.
2. Looking in the users home folder for a file called `settings.json`. The AirSim subfolder is located at `Documents\AirSim` on Windows and `~/Documents/AirSim` on Linux systems.

The file is in usual [json format](https://en.wikipedia.org/wiki/JSON). On first startup AirSim would create `settings.json` file with no settings at the users home folder. To avoid problems, always use ASCII format to save json file.

## How to Chose Between Car and Multirotor?
The default is to use multirotor. To use car simple set `"SimMode": "Car"` like this:
Expand Down