Skip to content

AcresCoreBatch.h#

Core/Source/AcresCoreBatch.h Generated

Batched environments of ACRES Core: N independent Polaris environments on one shared world, stepped together on all CPU cores. This is what the Python module (Core/Python) and the learners use; ROS/acres_core_sim will wrap the same class.

A Step advances every environment by SubSteps physics steps (12 x 1/120 s = 0.1 s, the task's control step) under its drive-by-wire command, in parallel (a persistent thread pool; one environment is only ever stepped by one thread). Commands have ds_dbw semantics (AcresSim::FDbwCommand): a command row given to Step counts as a message arriving at the first physics step and is re-sent every CommandResendSteps physics steps while it is held (a 20 Hz publisher by default, as the lab's path follower); a NaN mode means "no message this step", so that subsystem times out after 0.1 s as on the vehicle. State, wheel and energy arrays are filled after every Step and Reset in structure-of-arrays layout, ready to be wrapped as numpy arrays.

Threads: Step and Reset are called from one thread at a time (they fan out internally).

Name Type Unit Default Description
EnergyColumnCount inline constexpr int 24 Energy ledger columns: the AcresSim::FEnergyFlows fields in declaration order, then GroundLoss = Slip + Lateral + Soil (E_ground of the scouting task).

CommandColumnName#

Column names (for the Python dictionaries and the docs).

const char* CommandColumnName(int Column);

ECommandColumn#

enum ECommandColumn : int

Columns of the command array (one row per environment, double).

Value Description
CmdEnable System enable (/vehicle/enable), 0 / 1.
CmdSteerMode SteeringCmd cmd_type: 0 none, 2 angle (deg), 3 curvature (1/m), 4 yaw rate (rad/s), 14 %.
CmdSteerValue SteeringCmd cmd.
CmdSteerRate SteeringCmd cmd_rate, deg/s (0 default).
CmdSteerAccel SteeringCmd cmd_accel, deg/s2 (0 default).
CmdThrottleMode ThrottleCmd cmd_type: 0 none, 13 raw %, 14 %.
CmdThrottleValue ThrottleCmd cmd.
CmdBrakeMode BrakeCmd cmd_type: 0 none, 1 pressure (bar), 14 %.
CmdBrakeValue BrakeCmd cmd.
CmdGear GearCmd: 0 none, 1 P, 2 R, 3 N, 4 H, 5 L.
CmdUlcMode UlcCmd cmd_type: 0 none, 1 velocity (m/s), 2 acceleration (m/s2).
CmdUlcValue UlcCmd cmd.
CmdUlcLimitAccel UlcCmd limit_accel, m/s2 (0 default).
CmdUlcLimitDecel UlcCmd limit_decel, m/s2 (0 default).
CmdUlcJerkThrottle UlcCmd limit_jerk_throttle, m/s3 (0 default).
CmdUlcJerkBrake UlcCmd limit_jerk_brake, m/s3 (0 default).
CmdUlcCoast UlcCmd coast_decel, 0 / 1.
CmdDriveMode AWD switch: 0 Turf, 1 2WD, 2 AWD.
CommandColumnCount

EStateColumn#

enum EStateColumn : int

Columns of the state array (one row per environment, double). Positions are base_footprint in ENU m.

Value Description
StTime
StX
StY
StZ
StQw
StQx
StQy
StQz
StYaw
StPitch
StRoll
StVx
StVy
StVz
StWx
StWy
StWz
StAx
StAy
StAz
StSpeed
StSteeringWheelDeg
StSteerRefDeg
StRoadWheelRad
StThrottlePct
StBrakeBar
StGear
StUlcVelRef
StUlcAccelRef
StSpeedMeasured
StRpm
StCvtRatio
StFuelRateLph
StFuelUsedL
StDbwEnabled
StSteerEnabled
StThrottleEnabled
StBrakeEnabled
StUlcEnabled
StGrounded
StRearSlip
StCropCrushedM2
StCropCrushedStepM2
StCrushedWheelsStepM2
StCrushedBodyStepM2
StOffMap
StCollision
StFieldUnder
StSurfaceUnder
StateColumnCount

EWheelColumn#

enum EWheelColumn : int

Columns of the wheel array ([environment][wheel 0..3][column], double; wheels FL, FR, RL, RR).

Value Description
WhOmega
WhSlip
WhNormalN
WhFxN
WhFyN
WhSinkageM
WhContact
WhSurfaceClass
WhField
WhSteerRad
WhDriveTorqueNm
WhSuspensionM
WhPressurePa
WheelColumnCount

FAcresBatchOptions#

struct FAcresBatchOptions

Options of FAcresBatch::Init.

Name Type Unit Default Description
World FAcresWorldOptions The world (its ContentDir must be set).
PolarisConfig std::string polaris.json (empty: <ContentDir>/polaris.json), parameter overrides (dotted keys) and occupants (-1: file).
NumEnvs, Threads int Environments; worker threads (0: all hardware threads).
PhysicsDt double 1. / 120 Physics step, s; physics steps per Step; re-send period of held commands, physics steps (0: never re-send).
bFarm bool true Keep crop and rut marks (the farm); off saves the stamp work in RL that does not score crop.
OffMapMarginM double m 10 Distance from the tile edge at which an environment counts as off the map, m.

FAcresEnv#

struct FAcresEnv

One environment.

Name Type Unit Default Description
Command AcresSim::FDbwCommand The command held (and its re-send clock), the raw last command row.
EnergyAtStep AcresSim::FEnergyFlows Energy at the start of the last Step (for the deltas) and crop at its start.
Log std::unique_ptr&lt;FAcresEpisodeLog> Episode log (null when not recording), its agent id and name; physics steps since the environment was created (the log's step and clock), resets so far and the step of the last reset.

FAcresBatch#

class FAcresBatch

The batch. See the file comment.

Name Type Unit Default Description
State std::vector&lt;double> Output arrays, refreshed by Step and Reset.
World FAcresWorld The world and the environments (read-only use from outside between calls).

FAcresBatch::Init#

Loads the world and the Polaris parameters, creates the environments (each at the origin until reset) and the thread pool. False with Error on a load failure.

bool Init(const FAcresBatchOptions& Options, std::string* Error = nullptr);

FAcresBatch::Size#

Number of environments.

int Size() const ;

FAcresBatch::Reset#

Places environments and clears their farm marks, commands and logs' clocks.

Argument Description
Poses Count x 4: base_footprint x, y (ENU m), yaw (rad counter-clockwise from east), forward speed (m/s).
bSettled On the terrain at the static ride height (true), or dropped level from 0.2 m as the game does. Gear, DriveMode: Start gear (EUtvGear) and AWD switch position.
void Reset(const int* Indices, int Count, const double* Poses, bool bSettled = true, int Gear = AcresSim::UtvGearLow, int DriveMode = AcresSim::UtvDriveAllWheel);

FAcresBatch::Step#

Advances every environment by SubSteps physics steps.

Argument Description
Commands Size() x CommandColumnCount rows (ECommandColumn), or null to keep holding the last commands (and re-sending them). A NaN mode (or a NaN enable) in a row: no new message for that subsystem.
void Step(const double* Commands);

FAcresBatch::StepPhysics#

Advances every environment by ONE physics step under a fully formed drive-by-wire command each: the caller has already applied ds_dbw semantics (the ...Fresh flags mark a message arriving this step, the driver fields are set). This is the game's own command path (AcresPolaris.cpp StepPolarisControls), which ROS/acres_core_sim runs per physics step; Step's command rows and re-send clock are not used.

Argument Description
Commands Size() commands, one per environment.
void StepPhysics(const AcresSim::FDbwCommand* Commands);

FAcresBatch::SetConditions#

Sets the soil-water scenario of environments (FAcresConditions): a global antecedent fraction (NaN: farm.json), per-field fractions (Count x 60, NaN entries keep the global one; null: none) and the rain film.

void SetConditions(const int* Indices, int Count, double GlobalFraction, const double* FieldFractions, double SurfaceFilm);

FAcresBatch::SetParameters#

Replaces the Polaris parameters of environments: the batch's base parameters with these dotted-key overrides (hardware shifts, domain randomisation). Takes effect immediately (the vehicle is re-initialised; reset it).

bool SetParameters(const int* Indices, int Count, const std::map<std::string, double>& Overrides, std::string* Error = nullptr);

FAcresBatch::StartLog#

Starts recording an environment into an MCAP episode log (Documentation/Modelling/core.md, "Episode Log").

bool StartLog(int Index, const std::string& Path, const std::map<std::string, std::string>& Metadata, const std::string& AgentName = "polaris", std::string* Error = nullptr);

FAcresBatch::StopLog#

Stops and closes an environment's log.

void StopLog(int Index);

FAcresBatch::AgentInfo#

An environment as the episode log describes it: its agent entry (/sim/agents), its soil-water conditions (/sim/conditions), and its state after the last physics step (/sim/agent_states) with that step's farm contacts (/sim/farm_stamps). For a caller that writes several environments into one log as the agents of one world (ROS/acres_core_sim); StartLog's per-environment logs use the same.

AcresLog::FAgentInfo AgentInfo(const FAcresEnv& E) const;

FAcresBatch::Scan#

Scans environments' LiDAR against the terrain and the obstacle scene, in parallel.

Argument Description
Pattern ELidarPattern.
OutRanges Count x beams ranges from the lens, m, NaN without a return (Helios: organized as the game's PCD, column x 32 + ring; planar: beam k at k deg counter-clockwise from forward). bNoise, Seed: Range noise (deterministic from the seed, the environment and the physics step).
OutMaterial Optional Count x beams hit codes (AcresCoreLidar.h EAcresLidarMaterial or a scene material).
void Scan(const int* Indices, int Count, int Pattern, float* OutRanges, bool bNoise = false, uint64_t Seed = 0, uint8_t* OutMaterial = nullptr);

FAcresBatch::ParallelFor#

Runs Fn(i) for i in [0, Count) on the pool (blocking). Public for the LiDAR and tools.

void ParallelFor(int Count, const std::function<void(int)>& Fn);

ELidarPattern#

enum ELidarPattern : int

LiDAR patterns: LidarHelios (sensors_polaris.json, 1800 x 32) and LidarPlanar (the scouting task's 360 beams, 1 deg apart, level, 30 m) at the Helios mount.

Value Description
LidarHelios
LidarPlanar