From 8b2089126caa8db659910b39a7b454081f8a5b41 Mon Sep 17 00:00:00 2001 From: David Tejero Ruiz Date: Wed, 8 Jun 2022 14:41:50 +0200 Subject: [PATCH] Added new C++ API request to get actual simulation clock rate --- AirLib/include/api/RpcLibClientBase.hpp | 1 + AirLib/src/api/RpcLibClientBase.cpp | 5 +++++ AirLib/src/api/RpcLibServerBase.cpp | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/AirLib/include/api/RpcLibClientBase.hpp b/AirLib/include/api/RpcLibClientBase.hpp index fd90824524..79433751a5 100644 --- a/AirLib/include/api/RpcLibClientBase.hpp +++ b/AirLib/include/api/RpcLibClientBase.hpp @@ -49,6 +49,7 @@ namespace airlib int getMinRequiredClientVersion() const; bool simIsPaused() const; + float getSimClockRate() const; void simPause(bool is_paused); void simContinueForTime(double seconds); void simContinueForFrames(uint32_t frames); diff --git a/AirLib/src/api/RpcLibClientBase.cpp b/AirLib/src/api/RpcLibClientBase.cpp index 891c5155d6..23933d45ae 100644 --- a/AirLib/src/api/RpcLibClientBase.cpp +++ b/AirLib/src/api/RpcLibClientBase.cpp @@ -453,6 +453,11 @@ __pragma(warning(disable : 4239)) return pimpl_->client.call("simIsPaused").as(); } + float RpcLibClientBase::getSimClockRate() const + { + return pimpl_->client.call("getSimClockRate").as(); + } + void RpcLibClientBase::simPause(bool is_paused) { pimpl_->client.call("simPause", is_paused); diff --git a/AirLib/src/api/RpcLibServerBase.cpp b/AirLib/src/api/RpcLibServerBase.cpp index 0710bd8d5a..afc5098d2e 100644 --- a/AirLib/src/api/RpcLibServerBase.cpp +++ b/AirLib/src/api/RpcLibServerBase.cpp @@ -108,6 +108,10 @@ namespace airlib return getWorldSimApi()->isPaused(); }); + pimpl_->server.bind("getSimClockRate", [&]() -> float { + return ClockFactory::get()->getTrueScaleWrtWallClock(); + }); + pimpl_->server.bind("simContinueForTime", [&](double seconds) -> void { getWorldSimApi()->continueForTime(seconds); });