Skip to content

Commit

Permalink
Add Settings field for Wind
Browse files Browse the repository at this point in the history
  • Loading branch information
rajat2004 committed Jul 20, 2020
1 parent 05ff544 commit 82cf932
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions AirLib/include/common/AirSimSettings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ struct AirSimSettings {
float speed_unit_factor = 1.0f;
std::string speed_unit_label = "m\\s";
std::map<std::string, std::unique_ptr<SensorSetting>> sensor_defaults;
Vector3r wind = Vector3r::Zero();

public: //methods
static AirSimSettings& singleton()
Expand Down Expand Up @@ -1051,6 +1052,14 @@ struct AirSimSettings {
tod_setting.move_sun = tod_settings_json.getBool("MoveSun", tod_setting.move_sun);
}
}

{
// Wind Settings
Settings child_json;
if (settings_json.getChild("Wind", child_json)) {
wind = createVectorSetting(child_json, wind);
}
}
}

static void loadDefaultCameraSetting(const Settings& settings_json, CameraSetting& camera_defaults)
Expand Down
7 changes: 7 additions & 0 deletions Unreal/Plugins/AirSim/Source/SimMode/SimModeWorldBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ std::unique_ptr<ASimModeWorldBase::PhysicsEngineBase> ASimModeWorldBase::createP
else {
physics_engine.reset(new msr::airlib::FastPhysicsEngine());
}

physics_engine->setWind(getSettings().wind);
}
else {
physics_engine.reset();
Expand Down Expand Up @@ -98,6 +100,11 @@ void ASimModeWorldBase::continueForTime(double seconds)
UGameplayStatics::SetGamePaused(this->GetWorld(), true);
}

void ASimModeWorldBase::setWind(const msr::airlib::Vector3r& wind)
{
physics_engine_->setWind(wind);
}

void ASimModeWorldBase::updateDebugReport(msr::airlib::StateReporterWrapper& debug_reporter)
{
unused(debug_reporter);
Expand Down
2 changes: 2 additions & 0 deletions Unreal/Plugins/AirSim/Source/SimMode/SimModeWorldBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class AIRSIM_API ASimModeWorldBase : public ASimModeBase
virtual void pause(bool is_paused) override;
virtual void continueForTime(double seconds) override;

void setWind(const msr::airlib::Vector3r& wind);

protected:
void startAsyncUpdator();
void stopAsyncUpdator();
Expand Down

0 comments on commit 82cf932

Please sign in to comment.