Skip to content

AcresSession.h#

Acres/Source/Acres/AcresSession.h Generated

A simulation session as configured in the front-end menu, and how it becomes a running simulation.

Every value the menu can edit is described once, in a parameter table in AcresSession.cpp: which tab shows it, its label and display unit, its physical limits, and the JSON path it overrides in one of the shipped configuration files (environment.json, sensors.json, tractor.json in Content/Simulation) or a launch flag. The menu UI, validation, saving and session start-up all read that one table, so adding a setting is one line.

Starting a session (Prepare) writes per-session copies of the configuration files into Saved/Sessions/<stamp>-<mode>/ and returns extra command-line arguments. The menu then reloads the map with those arguments; the simulation itself only ever reads files and flags, it never talks to the menu.

Parameter ids look like "trac:vehicle.mass_kg": a prefix for the file ("env", "sen", "trac"), or "flag", "npc" and "opt" for values that are not in a file, then the JSON path inside that file.

EAcresSessionMode#

enum class EAcresSessionMode : uint8

Which kind of session the menu is configuring.

Value Description
Simulation Full simulation: sensors and session logging on.
Pilot Free drive: no sensors, no logging.
Replay Drive a recorded session or command file (see AcresReplay.h).
Optimizer Run Optimizer: planning only, no simulation is started directly.

EAcresParamKind#

enum class EAcresParamKind : uint8

How a parameter is edited in the menu.

Value Description
Number Spin box with decimals.
Integer Spin box, whole numbers.
Toggle Check box; stored as 0 or 1.
Choice Drop-down list; stored as a string.

FAcresParam#

struct FAcresParam

One editable setting: one row of the menu's parameter table.

The table is a static array of these in AcresSession.cpp. All strings are static literals (TCHAR is Unreal's character type, wide on Windows).

Name Type Unit Default Description
Tab const TCHAR* Tab: menu tab name ("Weather"). Group: heading within the tab. Id: parameter id ("env:wind.speed_mps"). Label: text shown to the user. Unit: display unit ("km/h").
Kind EAcresParamKind Editor widget type.
Min double See above.
Max double Allowed range in display units.
Step double Spin-box increment in display units.
Scale double Display value = file value x Scale (for example 3.6 turns m/s in the file into km/h in the menu).
Choices const TCHAR* For Choice: "value=Label|value=Label|..." (the label part is optional).
EnabledBy const TCHAR* Condition for the row to apply: a toggle id ("sen:lidar.enabled"), "id=value" or "id!=value" for choices, or nullptr for always.
Help const TCHAR* Tooltip / hint text, or nullptr.

FAcresSessionIssue#

struct FAcresSessionIssue

A validation finding shown under the menu's tabs.

Name Type Unit Default Description
bError bool True for an error (blocks Start), false for a warning.
Message FString Message for the user, starting with the area ("Tractor: ...").

FAcresSession#

class FAcresSession

The menu's configuration: parameter values, per-field setup, replay choice.

Values are kept in display units (what the user sees). They start from the shipped JSON files (ResetToDefaults), change as the user edits, and are written back into file units when a session starts.

Example

FAcresSession Session;
Session.ResetToDefaults();
Session.Set(TEXT("env:temperature.high_c"), 31);          // degrees C
Session.SetChoice(TEXT("env:clouds"), TEXT("overcast"));
FString Cmd, Dir, Error;
if (Session.Prepare(EAcresSessionMode::Simulation, Cmd, Dir, Error))
    AcresMenu::StartSession(World, Cmd);                  // reload the map with the new arguments
Name Type Unit Default Description
Fields FAcresFieldSetup Fields tab: per-field crop, soil and wetness overrides and terrain edits.
ReplayFile FString A session folder, tractor.csv or command CSV to replay.
ReplayMode FString TEXT("commands") "commands" or "path".

FAcresSession::Params#

The full parameter table, in menu order.

static const TArray<FAcresParam>& Params();

FAcresSession::Find#

Looks up a parameter by id.

Returns: The table row, or nullptr if the id is unknown.

static const FAcresParam* Find(const FString& Id);

FAcresSession::ChoiceValues#

The stored values of a Choice parameter ("clear", "fair", ...), in table order.

static TArray<FString> ChoiceValues(const FAcresParam& P);

FAcresSession::ChoiceLabels#

The display labels of a Choice parameter, same order as ChoiceValues.

static TArray<FString> ChoiceLabels(const FAcresParam& P);

FAcresSession::ResetToDefaults#

Loads every value from the shipped JSON files and makes them the defaults.

Also clears the field setup. Values that are not in a file (flags, NPC and optimizer settings) get fixed defaults from AcresSession.cpp.

void ResetToDefaults();

FAcresSession::Get#

Current value of a Number, Integer or Toggle parameter, in display units (0 if unknown).

double Get(const FString& Id) const;

FAcresSession::GetChoice#

Current value of a Choice parameter (empty if unknown).

FString GetChoice(const FString& Id) const;

FAcresSession::GetToggle#

True when a Toggle parameter is on.

bool GetToggle(const FString& Id) const ;

FAcresSession::Set#

Sets a numeric parameter.

Argument Description
Id Parameter id.
DisplayValue New value in display units. Clamped to the table's range; rounded for Integer and Toggle.
void Set(const FString& Id, double DisplayValue);

FAcresSession::SetChoice#

Sets a Choice parameter to one of its stored values (not validated here).

void SetChoice(const FString& Id, const FString& Value);

FAcresSession::IsDefault#

True when the parameter still has its shipped default (the menu shows changed values in green).

bool IsDefault(const FString& Id) const;

FAcresSession::IsActive#

True when the row's EnabledBy condition holds (and its parent's, recursively).

bool IsActive(const FAcresParam& P) const;

FAcresSession::Validate#

Checks the configuration before a session starts.

Covers range limits and physics consistency: engine power vs torque x speed, static stability, front-axle load with a mounted implement, implement draft vs traction, rain intensity, dates, sensor throughput, custom soil ordering, replay file readability, optimizer slip band and work hours.

Argument Description
Mode Session type; sensor checks are skipped for Pilot and Optimizer.

Returns: Every finding; any entry with bError blocks the Start button.

TArray<FAcresSessionIssue> Validate(EAcresSessionMode Mode) const;

FAcresSession::Save#

Saves all values and the field setup as a named preset in Saved/Configs/<Name>.json (terrain edits in <Name>.terrain.f32).

Returns: False with Error set if the name is empty or the file cannot be written.

bool Save(const FString& Name, FString& Error) const;

FAcresSession::Load#

Loads a preset saved with Save. Unknown ids are ignored, so presets from older versions still load.

bool Load(const FString& Name, FString& Error);

FAcresSession::SavedNames#

Names of the saved presets (without extension), sorted.

static TArray<FString> SavedNames();

FAcresSession::ToJson#

All values and the field setup as JSON (the format Save writes).

TSharedRef<FJsonObject> ToJson() const;

FAcresSession::Prepare#

Validates the configuration and writes a session folder, ready for the simulation to read.

Writes environment.json, sensors.json and tractor.json (shipped files with this session's overrides), session-config.json and the field setup into Saved/Sessions/<stamp>-<mode>/, and builds the command-line arguments that make the simulation use them (-VehicleDemo, -EnvConfig=..., -SensorRecord, ...).

Argument Description
Mode Session type; decides logging and sensor flags.
OutCommandLine Extra arguments to append to the launch command line (no map name).
OutDir Absolute path of the new session folder.
Error Set when validation fails or a file cannot be written.

Returns: True when the folder is complete.

bool Prepare(EAcresSessionMode Mode, FString& OutCommandLine, FString& OutDir, FString& Error) const;

FAcresSession::LoadFromSessionFolder#

Loads the settings a logged session ran with (its session-config.json and field setup), keeping the current replay choice.

Returns: False with Error set if the folder has no session-config.json.

bool LoadFromSessionFolder(const FString& Dir, FString& Error);

FAcresSession::RecentSessions#

Session folders under Saved/Sessions that contain a tractor.csv, newest first.

Argument Description
Max Maximum number of folders to return.
static TArray<FString> RecentSessions(int Max = 30);