RaidZeroLib
Coroutine robot framework for VEX V5
Loading...
Searching...
No Matches
SimulationPlatform.hpp
1#pragma once
2#include "RaidZeroLib/api/Runtime/Platform.hpp"
3
4namespace rz {
5
7class SimulationPlatform final : public Platform {
8 public:
9 [[nodiscard]] Time now() const override { return time; }
10
11 void sleepUntil(Time target) override {
12 if (target > time) {
13 time = target;
14 }
15 }
16
17 [[nodiscard]] CompetitionMode competitionMode() const override { return mode; }
18
19 void setCompetitionMode(CompetitionMode newMode) { mode = newMode; }
20
22 void advance(Duration duration) { time += duration; }
23
24 private:
25 Time time{};
27};
28
29} // namespace rz
What the runtime needs from the outside world: a clock, a way to wait, and the competition mode.
Definition Platform.hpp:15
Fake clock for host tests: sleeping jumps time forward, so runs are instant and deterministic.
Definition SimulationPlatform.hpp:7
void sleepUntil(Time target) override
Blocks until now() >= time. Returns immediately if that time has passed.
Definition SimulationPlatform.hpp:11
void setCompetitionMode(CompetitionMode newMode)
Definition SimulationPlatform.hpp:19
Time now() const override
Monotonic time.
Definition SimulationPlatform.hpp:9
void advance(Duration duration)
Advances the clock without sleeping, e.g. to simulate a slow tick.
Definition SimulationPlatform.hpp:22
CompetitionMode competitionMode() const override
The mode field control is in right now.
Definition SimulationPlatform.hpp:17
CompetitionMode
What field control (or a competition switch) currently allows the robot to do.
Definition Platform.hpp:7
@ Disabled
Definition Platform.hpp:7
au::QuantityD< au::Seconds > Duration
Definition Units.hpp:16
au::QuantityPointD< au::Seconds > Time
Definition Units.hpp:17
Definition DriverControl.hpp:11