Skip to content
Open
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
1 change: 1 addition & 0 deletions AirLib/include/api/RpcLibClientBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ namespace airlib
int getMinRequiredClientVersion() const;

bool simIsPaused() const;
float simGetClockRate() const;
void simPause(bool is_paused);
void simContinueForTime(double seconds);
void simContinueForFrames(uint32_t frames);
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 @@ -453,6 +453,11 @@ __pragma(warning(disable : 4239))
return pimpl_->client.call("simIsPaused").as<bool>();
}

float RpcLibClientBase::simGetClockRate() const
{
return pimpl_->client.call("simGetClockRate").as<float>();
}

void RpcLibClientBase::simPause(bool is_paused)
{
pimpl_->client.call("simPause", is_paused);
Expand Down
6 changes: 6 additions & 0 deletions AirLib/src/api/RpcLibServerBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//if using Unreal Build system then include precompiled header file first

#include "api/RpcLibServerBase.hpp"
#include "common/ClockFactory.hpp"

#include "common/Common.hpp"
STRICT_MODE_OFF
Expand Down Expand Up @@ -108,6 +109,11 @@ namespace airlib
return getWorldSimApi()->isPaused();
});

// True scale of sim clock vs wall clock (credit: davidtr99 #4612 naming aligned to sim* APIs)
pimpl_->server.bind("simGetClockRate", [&]() -> float {
return ClockFactory::get()->getTrueScaleWrtWallClock();
});

pimpl_->server.bind("simContinueForTime", [&](double seconds) -> void {
getWorldSimApi()->continueForTime(seconds);
});
Expand Down
10 changes: 10 additions & 0 deletions PythonClient/airsim/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ def simIsPause(self):
"""
return self.client.call("simIsPaused")

def simGetClockRate(self):
"""
Returns the true scale of the simulation clock relative to wall clock
(settings ClockSpeed). For example, ClockSpeed 0.5 yields about 0.5.

Returns:
float: sim clock rate vs wall clock
"""
return self.client.call("simGetClockRate")

def simContinueForTime(self, seconds):
"""
Continue the simulation for the specified number of seconds
Expand Down