/
vasandi
/
AirSim
Обзор
Документация
Войти
/
vasandi
/
AirSim
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
AirLib/include/common/SteppableClock.hpp
70 строк
2 KB
Андрей Васильченко
сборка под ubuntu 26.04
08 июл 2026, 10:15
08 июл 2026, 10:15
d53c5a2
Код
Авторство
О чём код?
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #ifndef airsim_core_SteppableClock_hpp #define airsim_core_SteppableClock_hpp #include "ClockBase.hpp" #include "Common.hpp" #include <atomic> namespace msr { namespace airlib { class SteppableClock : public ClockBase { public: static constexpr real_T DefaultStepSize = 20E-3f; //Debug clock allows to advance the clock manually in arbitrary way //TTimePoint is nano seconds passed since some fixed point in time //step is how much we would advance the clock by default when calling step() //by default we advance by 20ms SteppableClock(TTimeDelta step = DefaultStepSize, TTimePoint start = 0) : current_(start), step_(step) { start_ = current_ = start ? start : Utils::getTimeSinceEpochNanos(); } virtual ~SteppableClock() {} virtual TTimePoint stepBy(TTimeDelta amount) override { current_ = addTo(current_, amount); return current_; } virtual TTimePoint step() override { ClockBase::step(); current_ = addTo(current_, step_); return current_; } TTimeDelta getStepSize() const { return step_; } virtual TTimePoint nowNanos() const override { return current_; } virtual TTimePoint getStart() const override { return start_; } private: std::atomic<TTimePoint> current_; std::atomic<TTimePoint> start_; TTimeDelta step_; }; } } //namespace #endif