Architecture#
This page shows the parts of ACRES, the connections between them and the threads that run them. Read Unreal for C++ Developers first when the Unreal terms are new to you.
The Parts#
ACRES has five parts.
| Part | Location | Function |
|---|---|---|
| The game | Acres/ |
The full simulator in Unreal Engine 5.8: the farm, both vehicles, the implements, the weather and all sensors. |
| ACRES Core | Core/ |
The simulator without Unreal: the Polaris on the same terrain, soil and crops, with a ray-cast LiDAR. |
| The ROS 2 workspace | ROS/ |
The messages, the ROS 2 bridge, the Core server and the Polaris description. |
| The learning stack | Learning/ |
The tasks, the environments, the training and the deployment program. |
| The calibration studies | Calibration/ |
The comparisons of the simulator with real data. |
The system overview shows the data flows between these parts.
The Layers of the Game#
The game is one Unreal module with three layers.
- Clients. A person at the keyboard, a program on a socket, or the ROS 2 bridge.
- The Unreal layer. It owns the actors, the threads, the rendering and the UI.
- The engine-free models. They contain the mathematics. They use standard C++ and SI units.
The Unreal layer reads the configuration and the map products at the start of a session. At each physics step it fills the input structs of the models and applies their outputs. Chaos, the physics engine of Unreal, integrates only the chassis body from the total force and torque.
File Groups#
All game code is in Acres/Source/Acres. A file name without an extension stands for the .h file and the .cpp file.
| Group | Files | Function |
|---|---|---|
| Vehicle pawn | AcresVehicle, AcresVehicleControl.cpp, AcresPolaris.cpp |
The pawn of a vehicle, its physics step, its controls and the Polaris branch. |
| Vehicle models | AcresVehicleModel, AcresUtvModel, AcresSimModel, AcresPowerModel |
The Maxxum model, the Polaris model with the drive-by-wire, the power and fuel model. |
| Soil | AcresSoilModel, AcresSurfaceMap |
The soil library, the tyre and soil forces, the surface class at a point. |
| Implements | AcresImplementModel, AcresImplementCoupling, AcresFieldWorkModel |
The implement forces, their path to the chassis, the marks of field work. |
| Equipment rigs | AcresRig |
The skeletal meshes of the vehicles and implements that follow the physics state. |
| Agents | AcresAgents, AcresPlaces, AcresGeoUtm.h |
The vehicles of a session, the named places, the UTM projection. |
| Farm | AcresFarmRuntime, AcresFarmModel, AcresFieldSetup, AcresSoilVisuals, AcresCrops.h |
Crops, soil water, ruts, field settings and the look of the ground. |
| Weather | AcresEnvironment, AcresEnvironmentModel |
Sun, clouds, temperature, wind, rain and the clock. |
| Sensors | AcresSensors, AcresCameraModel, AcresLidarModel, AcresLidarPhysics.h, AcresLidarGpu, AcresGnssModel |
The sensor recorder and the model of each sensor. |
| Rendering | AcresRenderTier, AcresVideoCapture |
The render tiers, the sensor profile and the video capture. |
| Bridges | AcresRlBridge, AcresCommandTiming.h, AcresSensorStream, AcresSimControl |
The vehicle bridge with the timestamped command queue, the sensor stream, the simulator control channel. |
| Logs | AcresSessionLog, AcresEpisodeLog, AcresEpisodeSchemas.h, AcresReplay |
The session log, the episode log and the replay input. |
| Application | AcresShell, AcresMenu, AcresSession, AcresHud.cpp, AcresOptimizer, AcresNpc |
The game mode, the menu, the session configuration, the HUD, the optimizer and the farm traffic. |
C++ Headers lists the public declarations of each file.
How a Session Starts#
The menu does not build the simulation in the running map.
It writes a session folder with copies of the configuration files. Then it loads the map again with options that point to the folder.
A command line can start the same session without the menu. It gives the folder with the option -VehicleOutput=.
The simulation reads only files and options. Each session is thus reproducible from its folder. Run the Packaged Game and Configuration Files give the details.
What the Vehicle Pawn Owns#
AAcresVehiclePawn is the hub of a session. One instance exists for each agent.
The Maxxum and the Polaris use the same class with different models and parameters.
BeginPlay of agent 0 does these steps in this sequence.
- It reads the agent list of the session and its own configuration.
- It goes to the spawn pose.
- It makes the weather runtime and the farm runtime. The farm runtime starts the water thread.
- It makes the body, the wheels, the equipment rig and the implement.
- It opens the session log and starts the sensor recorder and the sensor stream.
- It opens the vehicle bridge.
- It spawns the other agents. They share the farm and the weather.
- It makes the simulator control when the command line requests it.
Each agent has its own controls, sensors, bridge ports and logs. Run Several Vehicles shows a session with two agents.
One Physics Step#
Each 1/120 s the physics thread calls AsyncPhysicsTickActor of each vehicle pawn.
The pawn computes each force itself and gives Chaos only the totals. The physics is thus the same as in the model tests and does not change with the frame rate. Time Stepping and Determinism gives the sequence and the timing rules.
One Frame#
On the game thread, Tick does the visible work of a frame.
- It moves the equipment rig to the last physics state.
- It reads the keyboard and the sockets and puts commands into the timestamped command queue.
- It schedules the camera captures and the LiDAR scans and collects their results.
- It updates the sky, the sun, the fog, the rain and the weather materials.
- It applies the changes of the crops, the ruts and the water to the ground.
The HUD draws the speed, the time, the weather, the minimap and the panels after the 3D scene.
Threads#
| Thread | Rate | Work |
|---|---|---|
| Game | Each frame | Actors, UI, visuals, sockets, the sensor schedule, lockstep control. |
| Physics | Fixed, 120 Hz | The vehicle step: models, forces, farm marks, log rows, sensor samples. |
| Render | Each frame | Drawing, the camera readback, the GPU LiDAR pass. |
AcresWater |
Its own clock | The soil-water model. In lockstep, the physics thread steps it at fixed simulation times. |
AcresSensorWriter |
When rows arrive | Writes the sensor files in the sequence of delivery. |
AcresSensorStream |
When frames arrive | Sends the sensor frames to the ROS 2 bridge. |
AcresRlReceiver |
When messages arrive | Reads the vehicle bridge and stamps each message with its arrival time. |
AcresVideoWriter |
Each captured frame | Sends the frames of the window to ffmpeg. |
| Thread pool | Each camera image | The camera sensor model and the PNG encoding. |
Data moves between threads in three ways.
| Method | Use |
|---|---|
| A small struct that the code copies under a lock | Telemetry, controls, the weather state. |
| A snapshot with three buffers | The soil-water state. A reader never waits. |
| A bounded queue | Sensor rows, scan requests, stream frames, timed commands. A full queue drops data and counts the drops. |
The Bridges#
A session can open three sockets for each agent on 127.0.0.1.
| Socket | Option | Direction | Content |
|---|---|---|---|
| Vehicle bridge | -RlPort= |
Both | Commands to the vehicle, reports from the vehicle. The Maxxum also has a J1939 CAN bus. |
| Simulator control channel | -SimControl= |
Both | Pause, steps, resets, entities, conditions, recording. One channel for the session. |
| Sensor stream | -SensorStream= |
Out | The clock, the INS data, the LiDAR clouds and the camera images. |
The ROS 2 bridge acres_sim connects to the three sockets and publishes the topics of the real vehicle.
The Core server acres_core_sim opens the same sockets for ACRES Core, so one ROS 2 bridge operates with the two simulators.
Interfaces and Ports lists the ports and the protocols.
ACRES Core#
ACRES Core compiles the engine-free model files of the game and adds its own world layer.
| Item | The Game | ACRES Core |
|---|---|---|
| Vehicles | Maxxum with implements, Polaris | Polaris |
| Chassis integration | Chaos | Its own rigid body |
| Terrain | The collision mesh of the map | The terrain triangles of the same survey |
| Sensors | Camera, GPU LiDAR, INS, GNSS, IMU, CAN | Ray-cast LiDAR, INS, wheel signals |
| Environments in one process | One world, more than one agent | A batch of independent environments |
| Episode log | Yes | Yes, the same format |
Python API and Headless Core Runs show how to use it.
Data on Disk#
| Location | Content | Reader |
|---|---|---|
Acres/Content/Simulation/*.json |
The parameters of the vehicles, soils, sensors, weather and farm. | The simulation at the start, the menu for the defaults, ACRES Core. |
Acres/Content/Simulation/ACRE/ |
The map products. | The farm, the weather, the traffic, the optimizer, the HUD, ACRES Core. |
Saved/Sessions/<stamp>-<mode>/ |
One session that the menu started: configuration copies, the session log, the sensor episodes. | The user. |
Saved/Vehicle/ or the folder of -VehicleOutput= |
One session that a command line started. | The user. |
Saved/Configs/ |
The presets that the menu saved. | The menu. |
Saved/Optimizer/ |
The results of the optimizer. | The user. |
Session Log, Episode Log and Map Products give the formats.