Skip to content

Commit

Permalink
[Unity] Set Wind API implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
rajat2004 committed Aug 16, 2020
1 parent 68d461f commit c4e5331
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ void SimModeBase::setTimeOfDay(bool is_enabled, const std::string& start_datetim
//throw std::domain_error("setTimeOfDay is not implemented by SimMode");
}

void SimModeBase::setWind(const msr::airlib::Vector3r& wind) const
{
// should be overridden by derived class
unused(wind);
throw std::domain_error("setWind is not implemented by SimMode");
}

std::unique_ptr<msr::airlib::ApiServerBase> SimModeBase::createApiServer() const
{
//this will be the case when compilation with RPCLIB is disabled or simmode doesn't support APIs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class SimModeBase
virtual bool isPaused() const;
virtual void pause(bool is_paused);
virtual void continueForTime(double seconds);
virtual void setWind(const msr::airlib::Vector3r& wind) const;
void startApiServer();
void stopApiServer();
bool isApiServerStarted();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ void SimModeWorldBase::continueForTime(double seconds)
physics_world_->continueForTime(seconds);
}

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

void SimModeWorldBase::updateDebugReport(msr::airlib::StateReporterWrapper& debug_reporter)
{
unused(debug_reporter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class SimModeWorldBase : public SimModeBase
virtual void pause(bool is_paused) override;
virtual void continueForTime(double seconds) override;

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

private:
std::unique_ptr<msr::airlib::PhysicsWorld> physics_world_;
PhysicsEngineBase* physics_engine_;
Expand Down
5 changes: 5 additions & 0 deletions Unity/AirLibWrapper/AirsimWrapper/Source/WorldSimApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,9 @@ bool WorldSimApi::isRecording() const
return false;
}

void WorldSimApi::setWind(const Vector3r& wind) const
{
simmode_->setWind(wind);
};

#pragma endregion
2 changes: 2 additions & 0 deletions Unity/AirLibWrapper/AirsimWrapper/Source/WorldSimApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class WorldSimApi : public msr::airlib::WorldSimApiBase
virtual void stopRecording() override;
virtual bool isRecording() const override;

virtual void setWind(const Vector3r& wind) const override;

private:
SimModeBase * simmode_;
std::string vehicle_name_;
Expand Down

0 comments on commit c4e5331

Please sign in to comment.