timer.h 427 B

12345678910111213141516171819202122232425
  1. #pragma once
  2. #include <cstdint>
  3. #include <chrono>
  4. class Timer {
  5. private:
  6. std::chrono::time_point<std::chrono::high_resolution_clock> target_time_;
  7. int64_t proportional_{};
  8. int64_t integral_{};
  9. int64_t derivative_{};
  10. constexpr static double P_{0.0};
  11. constexpr static double I_{-1.0};
  12. constexpr static double D_{0.0};
  13. public:
  14. Timer();
  15. void wait(int64_t period);
  16. void update();
  17. private:
  18. int64_t adjust() const;
  19. };