Skip to content

AcresSimControl.h#

Game/Source/Acres/AcresSimControl.h Generated

Simulator control: the session-wide channel the ROS 2 side (Vehicle/ROS/acres_sim) and learners use to pause, play and step the world in lockstep, reset it, move and spawn entities, change the conditions and the vehicles' hardware shifts, record the episode log and replay one. Protocol: Docs/Reference/channels.md (newline-delimited JSON on 127.0.0.1, -SimControl=<port>); episode log: Docs/Reference/files.md, "Episode Log".

-SimControl=<port>          the control channel
-Lockstep                   start held: the world advances only on step requests
-EpisodeLog=<file.mcap>     record the episode log from the first physics step
-EpisodeReplay=<file.mcap>  replay an episode log (the agents follow their logged poses; -EpisodeReplayExit
                            quits when it ends)

The operation "replay" of the channel gives a running session the next episode log with a time scale and the texts of the replay panel of the HUD (FAcresReplayInfo): the game then shows drive after drive in one process.

Agent 0 (the game mode's pawn) creates the one instance at the end of its BeginPlay when any of these flags is given, after it spawned the other agents, and deletes it in EndPlay.

Lockstep: a step request switches the engine to a fixed frame time of exactly one physics step (FApp fixed time step at the async physics step, 1/120 s: the Chaos solver then runs exactly one step per frame), releases the world (AWorldSettings pauser cleared) for N frames and holds it again (pauser set) before the next frame's world tick. While held, the world does not tick (no physics, game time, NPC or timer), but frames keep rendering and the vehicle pawns keep ticking (bTickEvenWhenPaused): their sensors finish the scans and images that fell due and their bridges flush reports. The reply is sent when the physics has done N steps and every agent's sensors are idle, after a barrier went into each connected sensor stream and RL bridge.

Threads: everything runs on the game thread (FWorldDelegates::OnWorldTickStart for the socket and the step scheduling, FCoreDelegates::OnEndFrame for completion, recording and replay bookkeeping) except RecordStep and ReplayState, which the pawns call from their physics steps.

Name Type Unit Default Description
ReplayFrameSteps static constexpr int 12 The logged steps of one frame of the replay: one control step of a learner, 0.1 s.
bReplayHelp, bReplayHudHidden bool The keys of the replay: the list of the keys shows; the HUD is hidden for a clean picture.

FAcresSimControl#

Opens the channel and the log or replay the command line asks for.

Argument Description
InAgent0 The session's agent 0 (the game mode's pawn); must outlive this object.
explicit FAcresSimControl(AAcresVehiclePawn* InAgent0);

~FAcresSimControl#

Closes the socket and the episode log, restores the engine's frame timing.

~FAcresSimControl();

Get#

The session's instance, or null. Game thread (and the pawns' physics steps, which only use the thread-safe members).

static FAcresSimControl* Get() ;

IsRequested#

True when the command line asks for simulator control (any of the flags above).

static bool IsRequested();

IsLockstep#

True while the world is in lockstep (held or stepping): the RL bridge then does not brake a client that is slow in wall-clock time.

static bool IsLockstep() ;

RecordStep#

Physics thread, end of every agent's step: queues the agent's state for the episode log. Cheap when not recording.

Argument Description
Agent The pawn.
State Its episode-log state after the step (base_footprint pose in the world frame, ...).
WorldTimeS World time of the step, s.
void RecordStep(const AAcresVehiclePawn& Agent, AcresLog::FAgentState&& State, double WorldTimeS);

IsRecording#

True while an episode log is being recorded. Any thread.

bool IsRecording() const ;

IsReplaying#

True while an episode log is being replayed (the pawns then follow it instead of simulating). Any thread.

bool IsReplaying() const ;

ReplayEpoch#

The number of the replay: it changes when the operation "replay" gives a new log. A pawn then starts at the first logged step again. Any thread.

uint32 ReplayEpoch() const ;

ReplayRate#

Logged steps for each physics step: the time scale of the replay (0 while it is paused). Any thread.

double ReplayRate() const ;

ReplaySteps#

The number of logged steps of the replay. Any thread.

uint64 ReplaySteps() const ;

ReplayStartIndex#

The logged step at which a pawn starts the replay (the key "start_s" of the operation "replay"; else 0).

uint64 ReplayStartIndex() const ;

ReplayInfo#

The replay panel of the HUD, or null: only a replay of the operation "replay" has one. Game thread.

const FAcresReplayInfo* ReplayInfo() const ;

ReplayView#

The view of the replay: 0 chase, 1 field from above, 2 whole drive from above, 3 sensor camera, 4 rear sensor camera (camera_rear). Game thread.

int ReplayView() const ;

ScaleReplayRate#

Changes the time scale by a factor (the keys of the replay view) and pauses or continues. Game thread.

void ScaleReplayRate(double Factor);

SeekReplay#

Moves the replay to a logged step. The farm then has the contacts of the log to this step. Game thread.

void SeekReplay(uint64 Index);

StepReplayFrames#

Pauses the replay and moves it by whole frames (the keys "one step back" and "one step forward").

void StepReplayFrames(int Frames);

JumpReplaySeconds#

Moves the replay by logged seconds.

void JumpReplaySeconds(double Seconds);

MarkReplay#

Writes a mark: one line into the marks file (the key "marks" of the operation "replay"; else Saved/Viewer/marks.jsonl of the game) and a screenshot beside it. Returns the number of the mark, 0 on failure.

int MarkReplay(TSharedPtr<FJsonObject>* OutRecord = nullptr);

ReplayToast#

A short message for the replay panel ("Mark 3 saved") and the real time at which it came.

const FString& ReplayToast() const ;

ReplayContacts#

The overlaps of agent 0 with level objects in the replay so far, and the real time of the last test that found one (FPlatformTime::Seconds; 0: none). Game thread.

const TArray<FAcresReplayContact>& ReplayContacts() const ;

IsReplayDone#

True after the last logged step was shown.

bool IsReplayDone() const ;

ReplayShownStep#

The logged step that agent 0 shows, from 0.

uint64 ReplayShownStep() const;

ReplayState#

Physics thread: the logged state of an agent at a replay step.

Argument Description
AgentName The agent's name.
ReplayStep Physics steps since the replay started (0 = the first logged step).
Out The logged state (the last one once the log has ended).
OutWorldTimeS The logged world time of that step, s.
OutEpoch The number of the replay that gave the state (ReplayEpoch). A caller that counts its steps compares it with the number that its count belongs to.

Returns: False when the log has no such agent.

bool ReplayState(const FString& AgentName, uint64 ReplayStep, AcresLog::FAgentState& Out, double& OutWorldTimeS, uint32* OutEpoch = nullptr) const;

ReplayPose#

Physics thread: the logged pose of an agent at a replay step (the target of a step with a time scale). False also when the replay is not that of Epoch.

bool ReplayPose(const FString& AgentName, uint64 ReplayStep, uint32 Epoch, AcresLog::FPose& Out) const;

FAcresReplayInfo#

struct FAcresReplayInfo

What the HUD shows for a replay that the operation "replay" started: the file of the key "info" (schema acres-replay-info-1, Docs/Reference/channels.md) and the track of the log. Made on a worker thread with the log, then read only (game thread).

Name Type Unit Default Description
Badge FString The chip below the heading ("Residual policy, strength 1"); with the accent colour for a learned policy.
FieldName FString The name of the ground of the view "field" ("Field RF042").
LabelFields TArray&lt;FString> The fields that the inset always names: the fields that the route passes or borders ("F39", "RF042").
FieldBounds, DriveBounds FBox2D The ground that the top views show, world metres (X east, Y south): the field and the whole drive.
Track TArray&lt;FVector> The driven track of agent 0: one point for each TrackEverySteps logged steps.
DistanceM TArray&lt;float> m The distance that agent 0 drove to each logged step, m.

FRow#

struct FRow

A row of the panel: a fixed text, or a series with one value for each SeriesDtS of episode time.

Name Type Unit Default Description
Names TArray&lt;FString> A series of indexes into Names (a phase), not of numbers.
bBar bool bar false The series is a share from 0 to 1 and gets a bar.
Of int 0 The series counts to this number ("41 / 62"); 0: no limit.

FLeg#

struct FLeg

A leg of the mission on the time bar: its name and the logged time at which it ends.

FLine#

struct FLine

A polyline on the ground, world metres (X east, Y south, Z up).

FAcresReplayContact#

struct FAcresReplayContact

One overlap of the plan box of agent 0 with a level object during a replay of the operation "replay" (AAcresVehiclePawn::PlanBoxOverlaps): from the first logged step with the overlap to the last one.

Name Type Unit Default Description
PositionM FVector m FVector::ZeroVector base_footprint at the first step: world ENU m, and the heading counter-clockwise from east, deg.