Skip to content

Commit

Permalink
added ClockSpeed setting
Browse files Browse the repository at this point in the history
  • Loading branch information
sytelus committed Oct 9, 2017
1 parent 661c74b commit d156c5d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
22 changes: 15 additions & 7 deletions Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,24 @@ void ASimModeBase::BeginPlay()
{
Super::BeginPlay();

setStencilIDs();

record_tick_count = 0;
setupInputBindings();

UAirBlueprintLib::LogMessage(TEXT("Press F1 to see help"), TEXT(""), LogDebugLevel::Informational);

try {
readSettings();
}
catch (std::exception& ex) {
UAirBlueprintLib::LogMessageString("Error occured while reading the Settings: ", ex.what(), LogDebugLevel::Failure);
}

if (clock_speed != 1.0f) {
this->GetWorldSettings()->SetTimeDilation(clock_speed);
UAirBlueprintLib::LogMessageString("Clock Speed: ", std::to_string(clock_speed), LogDebugLevel::Informational);
}

setStencilIDs();

record_tick_count = 0;
setupInputBindings();

UAirBlueprintLib::LogMessage(TEXT("Press F1 to see help"), TEXT(""), LogDebugLevel::Informational);
}

void ASimModeBase::setStencilIDs()
Expand Down Expand Up @@ -66,6 +71,7 @@ void ASimModeBase::readSettings()
enable_collision_passthrough = false;
clock_type = "";
engine_sound = true;
clock_speed = 1.0f;


typedef msr::airlib::Settings Settings;
Expand Down Expand Up @@ -154,6 +160,8 @@ void ASimModeBase::readSettings()
clock_type = "ScalableClock";
}

clock_speed = settings.getFloat("ClockSpeed", 1.0f);

Settings record_settings;
if (settings.getChild("Recording", record_settings)) {
recording_settings.record_on_move = record_settings.getBool("RecordOnMove", recording_settings.record_on_move);
Expand Down
2 changes: 1 addition & 1 deletion Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class AIRSIM_API ASimModeBase : public AActor
float settings_version_actual;
float settings_version_minimum = 1;
bool engine_sound;

float clock_speed;

private:
void readSettings();
Expand Down
7 changes: 3 additions & 4 deletions docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Below are complete list of settings available along with their default values. I
"DefaultVehicleConfig": "",
"SimMode": "",
"ClockType": "",
"ClockSpeed": "1",
"LocalHostIp": "127.0.0.1",
"RecordUIVisible": true,
"LogMessagesVisible": true,
Expand Down Expand Up @@ -168,7 +169,5 @@ The recording feature allows you to record data such as position, orientation, v
* RecordInterval: specifies minimal interval in seconds between capturing two images.
* RecordOnMove: specifies that do not record frame if there was vehicle's position or orientation hasn't changed





#### ClockSpeed
Determines the speed of simulation clock with respect to wall clock. For example, value of 5.0 would mean simulation clock has 5 seconds elapsed when wall clock has 1 second elapsed (i.e. simulation is running faster). The value of 0.1 means that simulation clock is 10X slower than wall clock. The value of 1 means simulation is running in real time. It is important to realize that quality of simuation may decrease as the simulation clock runs faster. You might see artifacts like object moving past obstacles because collison is not detected. However slowing down simulation clock (i.e. values < 1.0) generally improves the quality of simulation.

0 comments on commit d156c5d

Please sign in to comment.