Skip to content

Commit

Permalink
Add API for getting the settings text being used
Browse files Browse the repository at this point in the history
  • Loading branch information
rajat2004 committed Mar 28, 2021
1 parent 5a49411 commit aaef18e
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions AirLib/include/api/RpcLibClientBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ class RpcLibClientBase {

void simSetWind(const Vector3r& wind) const;

std::string getSettingsString() const;

protected:
void* getClient();
const void* getClient() const;
Expand Down
2 changes: 2 additions & 0 deletions AirLib/include/api/WorldSimApiBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ class WorldSimApiBase {
virtual bool isRecording() const = 0;

virtual void setWind(const Vector3r& wind) const = 0;

virtual std::string getSettingsString() const = 0;
};


Expand Down
5 changes: 5 additions & 0 deletions AirLib/src/api/RpcLibClientBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,11 @@ void RpcLibClientBase::simSetWind(const Vector3r& wind) const
pimpl_->client.call("simSetWind", conv_wind);
}

std::string RpcLibClientBase::getSettingsString() const
{
return pimpl_->client.call("getSettingsString").as<std::string>();
}

void* RpcLibClientBase::getClient()
{
return &pimpl_->client;
Expand Down
4 changes: 4 additions & 0 deletions AirLib/src/api/RpcLibServerBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,10 @@ RpcLibServerBase::RpcLibServerBase(ApiProvider* api_provider, const std::string&
getWorldSimApi()->setWind(wind.to());
});

pimpl_->server.bind("getSettingsString", [&]() -> std::string {
return getWorldSimApi()->getSettingsString();
});

//if we don't suppress then server will bomb out for exceptions raised by any method
pimpl_->server.suppress_exceptions(true);
}
Expand Down
9 changes: 9 additions & 0 deletions PythonClient/airsim/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,15 @@ def simAddVehicle(self, vehicle_name, vehicle_type, pose, pawn_path = ""):
"""
return self.client.call('simAddVehicle', vehicle_name, vehicle_type, pose, pawn_path)

def getSettingsString(self):
"""
Fetch the settings text being used by AirSim
Returns:
str: Settings text in JSON format
"""
return self.client.call('getSettingsString')

# ----------------------------------- Multirotor APIs ---------------------------------------------
class MultirotorClient(VehicleClient, object):
def __init__(self, ip = "", port = 41451, timeout_value = 3600):
Expand Down
5 changes: 5 additions & 0 deletions Unreal/Plugins/AirSim/Source/WorldSimApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,3 +573,8 @@ void WorldSimApi::setWind(const Vector3r& wind) const
{
simmode_->setWind(wind);
}

std::string WorldSimApi::getSettingsString() const
{
return msr::airlib::AirSimSettings::singleton().settings_text_;
}
2 changes: 2 additions & 0 deletions Unreal/Plugins/AirSim/Source/WorldSimApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class WorldSimApi : public msr::airlib::WorldSimApiBase {
virtual void setWind(const Vector3r& wind) const override;
virtual bool createVoxelGrid(const Vector3r& position, const int& x_size, const int& y_size, const int& z_size, const float& res, const std::string& output_file) override;

virtual std::string getSettingsString() const override;

private:
AActor* createNewActor(const FActorSpawnParameters& spawn_params, const FTransform& actor_transform, const Vector3r& scale, UStaticMesh* static_mesh);
void spawnPlayer();
Expand Down

0 comments on commit aaef18e

Please sign in to comment.