Skip to content

Farm Traffic and Workers#

The farm traffic adds tractors, pickups, highway cars and walking workers to a session. The scenario actors add objects to the path of a mission. The vehicles of the traffic are kinematic: the model moves them along paths and computes no tire forces.

What the Model Does#

Inputs Outputs
The road graph of site.json, the highway centreline Poses of the farm vehicles, highway cars and workers
The pose of the agent vehicle Right-of-way stops, contacts and the incident log
A scenario of path objects (seed, patterns, route) Poses of the scenario actors in ACRES Core and in the game
A farm vehicle of the traffic stops for a worker in its corridor and drives on when the corridor is clear. Right of way: the corridor test The blue corridor in front of the tractor is 4 + 2.5 v long. A worker in it stops the tractor. The tractor drives on when the corridor is clear. worker, 0.8 m/s tractor: cruise 5 m/s, braking 3.5 m/s², acceleration 1.2 m/s² corridor: length ℓ = 4 + 2.5 v, half width w = 1.6 m, clearance c = 0.5 m for a worker blocked: 0 < r·f < ℓ + c and |r·f⊥| < w + c/2
The corridor test of a farm vehicle, from a simulation with the rules and the constants of this page. The worker enters the corridor, the tractor brakes to a stop 3.7 m before the worker, waits 3.2 s and drives on. Open the diagram

The model gives the sensors and the agent other road users to see and to avoid. It is not a traffic simulation.

  • One actor, AAcresNpcDirector, owns all vehicles and workers of the traffic. The vehicle of agent 0 creates it at the start of a session on the level ACRE.
  • A traffic vehicle moves one time for each rendered frame. The time step \(\Delta t\) is the frame time, not the physics step.
  • A traffic vehicle has no mass and no tire model. A collision box stops the vehicle of the agent.
  • The farm vehicles drive on the road graph of site.json. They do not read the ground layer.
  • The model knows one vehicle of the agent: the pawn of the first player controller. This page names it the agent vehicle.
  • All positions in this page are world meters with X east and Y south. A yaw is an Unreal yaw: 0 is east and 90° is south.
  • The random seeds are constants. The sequence of the events thus depends only on the frame times.

Symbols#

Symbol Quantity Unit
\(\mathbf{p}\) Position of a vehicle or a worker m
\(\psi\) Yaw of a vehicle or a worker rad
\(\mathbf{f}\) Unit heading \((\cos\psi, \sin\psi)\) -
\(v\) Speed along the heading m/s
\(v_c\) Cruise speed m/s
\(v_i\) Speed limit at the path point \(i\) m/s
\(\theta_i\) Turn angle of the path at the point \(i\) deg
\(d\) Distance to the next path point m
\(a_+\), \(a_-\) Acceleration limit and braking limit m/s²
\(R_{min}\) Minimum turn radius m
\(\Delta t\) Frame time s
\(L_h, W_h\) Half length and half width of a footprint m
\(S\) Distance of a highway car along US 52 m
\(v_0\) Desired speed of a highway car m/s
\(g\) Gap to the leader of a highway car m
\(s_0, T, a_{max}, b\) Minimum gap, time headway, maximum acceleration and comfortable deceleration of the Intelligent Driver Model m, s, m/s², m/s²
\(o_k\) Offset of the lane \(k\) from the centreline of US 52 m
\(L\) Wheelbase m
\(\delta\) Steering angle of the front wheels deg

How It Works#

Members of the Traffic#

Member Count Class Behavior
Tractor 3 AAcresNpcVehicle Drives to an empty field, makes five passes, drives back and parks.
Pickup 4 AAcresNpcVehicle Drives to a service point, waits, drives back and parks.
Parked pickup 3 AAcresNpcVehicle Stays in its stall for the full session.
Highway car 16 AAcresNpcCar Drives on US 52 in one lane. -NpcTraffic= changes the count.
Road walker 5 AAcresNpcWorker Walks along the side of a farm road.
Crop scout 3 AAcresNpcWorker Walks along the south edge of F27, F28 and F30 and examines the crop.
Staff 2 AAcresNpcWorker Walks between the parking lot and Beck's Ag Center.

-NpcVehicles adds the tractors, the pickups and the highway cars. -NpcWorkers adds the ten workers. A tractor is a copy of the Maxxum meshes of the level with a different paint. The highway cars use the four models of npc_cars.json: the SUV, the pickup and the two farm trucks. Each car has a model drawn with the traffic shares of the models (traffic_share: SUV 0.60, pickup 0.25, single axle truck 0.08, tandem axle truck 0.07, an assumption, not counted). An SUV has one of its eight paints, drawn with the shares of the paints from the seed of the traffic.

Two groups of objects are not members of the traffic:

  • Parked cars. 42 SUVs, each in one of the eight paints, stand in the stalls of the three parking lots in each mode of the game. They come from the layer Map/Layers/parked_cars.json (Scene, "Parked cars"). They are static level actors with a hidden collision box, obstacles of the scouting map and of ACRES Core.
  • Objects on the path. A scenario of ACRES Core places a truck and a person on the path of a mission (Objects on the Path). The truck is a farm truck of npc_cars.json at its own size. (A truck of 9 m or longer is the tandem axle truck, 11.7 m, else the single axle truck, 6.6 m. The collision box has the size of the object.) The person is a cylinder of 0.6 m by 1.8 m. The control channel places them (objects), or the option -PathObjects= loads a scenario file. They move with their velocity, and the vehicle hits their collision box. The LiDAR sees them as the classes vehicle and person, and the episode log has them on /sim/objects.

Road Graph#

FAcresRoadGraph::Build makes a graph from the roads of site.json. It ignores a road with a width of 20 m or more. Only US 52 is that wide.

  1. It changes each point of a road from survey grid cells to world meters.
  2. It divides each segment of length \(\ell\) into \(n = \max(1, \lceil \ell / 8 \rceil)\) equal parts.
  3. It makes a node for each division point. A point nearer than 4.5 m to a node becomes that node.
  4. It links each node to the node before it on the same road.

Roads that cross or touch thus have a common node. A node keeps the largest width of its roads. The node count depends on the road data. ACRES_NPC_READY reports the count for a run.

The farm lines in site.json now come from the current surface polygons. The NPC controller still applies the fixed lateral offset described below. It does not check the full footprint against the road boundary. Thus the map update alone does not certify an NPC path on a narrow road.

FAcresRoadGraph::Route finds the shortest path between two nodes with the algorithm of Dijkstra. The cost of a link is its length. AAcresNpcDirector::RouteBetween routes between the nodes that are nearest to two points.

Farm Vehicles#

Path and Speed Limits#

AAcresNpcVehicle::Plan receives the points of a path and the cruise speed. It moves each interior point to the right of the direction of travel, so that two vehicles in opposite directions do not meet. The move is 1.6 m where the road has the room. On a narrow road the move is smaller: the body stays 0.1 m inside the edge of the road (the ground layer, surface_polygons.json). With \(\mathbf{t}_i\) the unit vector from \(\mathbf{c}_{i-1}\) to \(\mathbf{c}_{i+1}\) of the center path:

\[ \mathbf{p}_i = \mathbf{c}_i + 1.6\,(-t_{i,y},\, t_{i,x}) \]

The first point, the last point and the ten points of the field passes stay on the center path.

The turn angle at a point sets its speed limit. The function \(\operatorname{smooth}\) is the cubic smoothstep.

\[ \theta_i = \arccos\!\left(\frac{(\mathbf{p}_i - \mathbf{p}_{i-1})\cdot(\mathbf{p}_{i+1} - \mathbf{p}_i)}{\lVert\mathbf{p}_i - \mathbf{p}_{i-1}\rVert\,\lVert\mathbf{p}_{i+1} - \mathbf{p}_i\rVert}\right) \]
\[ v_i = v_c + (v_{turn} - v_c)\,\operatorname{smooth}(10^\circ, 70^\circ, \theta_i) \]
\[ \operatorname{smooth}(e_0, e_1, x) = q^2(3 - 2q), \qquad q = \operatorname{clamp}\!\left(\frac{x - e_0}{e_1 - e_0}, 0, 1\right) \]

The first point has the limit \(v_c\). The last point has the limit 0.

Motion along the Path#

AAcresNpcVehicle::Tick moves the vehicle to the next path point \(\mathbf{p}_n\). Let \(d = \lVert\mathbf{p}_n - \mathbf{p}\rVert\).

The target speed is the highest speed from which the vehicle can decrease to \(v_n\) in the distance \(d\) less 1 m.

\[ v_{want} = \min\!\left(v_{lim},\, \sqrt{v_n^2 + 2\,a_+\,\max(0,\, d - 1)}\right) \]

\(v_{lim}\) is the cruise speed. During the field passes it is 2.2 m/s. The target speed is 0 when the corridor in front of the vehicle is not clear (see Right of Way).

\[ v \leftarrow \begin{cases} \min(v_{want},\, v + a_+\,\Delta t) & v_{want} > v \\ \max(v_{want},\, v - a_-\,\Delta t) & v_{want} \le v \end{cases} \]

The yaw turns to the path point. The turn rate is that of a vehicle on its minimum turn radius.

\[ e = \operatorname{wrap}\big(\mathrm{atan2}(p_{n,y} - p_y,\, p_{n,x} - p_x) - \psi\big), \qquad \psi \leftarrow \psi + \operatorname{clamp}\!\left(e,\, \pm\frac{\max(v, 0.3)}{R_{min}}\,\Delta t\right) \]
\[ \mathbf{p} \leftarrow \mathbf{p} + v\,\Delta t\,(\cos\psi, \sin\psi) \]

The vehicle goes to the subsequent path point when \(d < 2.2\) m. It also does so when \(d < 6\) m and \(|e| > 100^\circ\).

Constant Tractor Pickup
Cruise speed \(v_c\) 5 m/s 8.3 m/s
Corner speed \(v_{turn}\) 1.6 m/s 2.5 m/s
Field pass speed 2.2 m/s
Acceleration limit \(a_+\) 1.2 m/s² 1.2 m/s²
Braking limit \(a_-\) 3.5 m/s² 3.5 m/s²
Minimum turn radius \(R_{min}\) 4.8 m 6 m
Footprint \(L_h \times W_h\) 2.75 m x 1.3 m 2.75 m x 1.1 m
Collision box, half sizes 2.30 m x 1.25 m x 1.20 m 2.65 m x 0.95 m x 0.95 m

Pose on the Ground#

The body follows the terrain. GroundPose reads the ground height below the four wheel positions. AAcresNpcDirector::GroundZ gives the height. It includes the terrain edits of the session. With the mean heights \(z_f\) and \(z_r\) of the two axles at \(x_f\) and \(x_r\), and the half track \(w\):

\[ z = z_r + (z_f - z_r)\,\frac{-x_r}{x_f - x_r} \]
\[ \text{pitch} = \mathrm{atan2}(z_f - z_r,\, x_f - x_r), \qquad \text{roll} = -\mathrm{atan2}\!\left(\bar z_{right} - \bar z_{left},\, 2w\right) \]

The tractor has \(x_f = 1.548\) m, \(x_r = -1.032\) m and \(w = 0.95\) m. The pickup has \(x_f = 1.999\) m, \(x_r = -1.691\) m and \(w = 0.865\) m. The origin of a farm vehicle is 1.1 m above the ground.

FAcresNpcWheelRig::Update turns the wheels. The spin angle is the distance divided by the wheel radius. The front wheels show the steering angle of a bicycle model with the yaw rate \(\dot\psi\).

\[ \delta_{target} = \operatorname{clamp}\!\left(\arctan\frac{L\,\dot\psi}{\max(|v|, 1)},\, \pm 35^\circ\right), \qquad \delta \leftarrow \delta + (\delta_{target} - \delta)\,\min(1,\, 10\,\Delta t) \]

Work in a Field#

A tractor selects one of the fields with the land cover empty at random. These are F29, F32, F39 and F48. The work path uses the bounding box of the field, made smaller by 5 m on each side.

  1. The passes go along the longer side of the box.
  2. The road route ends at the node that is nearest to the point 6 m south of the box.
  3. The tractor makes five passes. Pass \(k\) is at the offset \(3 + 6k\) m from the edge of the box, for \(k = 0\) to 4.
  4. Each second pass goes in the opposite direction.

The passes start at the south edge when they go east and west. They start at the west edge when they go north and south. The tractor then waits 3 s to 8 s and drives back to the parking lot.

The work of a traffic tractor does not change the soil, the crops or the ruts. It has no implement model.

Errands of the Pickups#

A pickup selects a service point at random, drives there, waits 20 s to 50 s and drives back. The first service point is the mean position of the first six bins of site.json. The other service points are the centers of three buildings, selected by their footprint_id in site.json: B054, B034 and B012.

Parking#

The vehicles park in parking lot A, east of Beck's Ag Center. The lot has two rows of 17 stalls at the two sides of one aisle. The stalls are 2.75 m wide. The vehicles use each third stall, so that two free stalls are between two vehicles.

A parking maneuver follows a cubic Bézier curve at 1.3 m/s. AAcresNpcVehicle::StartManeuver sets the four control points.

\[ \mathbf{B}(t) = (1-t)^3\mathbf{P}_0 + 3(1-t)^2 t\,\mathbf{P}_1 + 3(1-t)t^2\,\mathbf{P}_2 + t^3\mathbf{P}_3, \qquad t \leftarrow \min\!\left(1,\, t + \frac{1.3\,\Delta t}{\ell_B}\right) \]
\[ \mathbf{B}'(t) = 3(1-t)^2(\mathbf{P}_1 - \mathbf{P}_0) + 6(1-t)t\,(\mathbf{P}_2 - \mathbf{P}_1) + 3t^2(\mathbf{P}_3 - \mathbf{P}_2) \]

\(\ell_B\) is the length of the curve, measured with 16 chords. The yaw follows \(\mathbf{B}'\). In reverse, the yaw follows \(-\mathbf{B}'\).

Maneuver \(\mathbf{P}_0\) \(\mathbf{P}_1\) \(\mathbf{P}_2\) \(\mathbf{P}_3\)
Leave a stall in reverse The stall 3 m from the stall to the aisle 3 m south of \(\mathbf{P}_3\) On the aisle, 4 m north of the stall
Enter a stall The position on the aisle 2.5 m ahead 3 m from the stall to the aisle The stall

One vehicle at a time uses the aisle. AAcresNpcDirector::RequestLot keeps a queue, and the first vehicle in the queue has the lot.

  • A parked vehicle waits in its stall until it has the lot.
  • A vehicle that drives back stops 18 m before the lot entrance until it has the lot.
  • A vehicle that leaves releases the lot when it is 8 m after the entrance.
  • A vehicle that cannot move for 8 s in reverse drives back into its stall and releases the lot.
Wait Tractor Pickup
Before the first trip 15 s to 45 s 5 s to 90 s
In the stall after a trip 90 s to 200 s 60 s to 180 s
At the destination 3 s to 8 s 20 s to 50 s

Each wait is a uniform random value.

Right of Way and Collisions#

Two tests prevent contact between the members of the traffic and the agent vehicle.

Corridor test. AAcresNpcDirector::Blocked examines a corridor in front of a vehicle or a worker. For a farm vehicle, the corridor has the length \(4 + 2.5\,v\) and the half width 1.6 m (tractor) or 1.3 m (pickup). An object at the relative position \(\mathbf{r}\) blocks the corridor when

\[ 0 < \mathbf{r}\cdot\mathbf{f} < \ell + c \quad \text{and} \quad |\mathbf{r}\cdot\mathbf{f}_\perp| < w + \frac{c}{2} \]

Here \(\ell\) is the corridor length, \(w\) is the half width and \(c\) is a clearance. The clearance is 2.5 m for the agent vehicle, 2 m for a traffic vehicle and 0.5 m for a worker. A blocked vehicle sets its target speed to 0. A vehicle that a driver passes with room (Meeting, below) does not block the corridor of that driver.

Footprint test. AAcresNpcDirector::Overlaps tests two rectangles with the separating axis theorem. The rectangles have the centers \(\mathbf{c}_1, \mathbf{c}_2\), the headings \(\mathbf{f}_1, \mathbf{f}_2\) and the normals \(\mathbf{n}_1, \mathbf{n}_2\). They do not touch if one axis \(\mathbf{a}\) of the four vectors \(\mathbf{f}_1, \mathbf{n}_1, \mathbf{f}_2, \mathbf{n}_2\) obeys

\[ |(\mathbf{c}_2 - \mathbf{c}_1)\cdot\mathbf{a}| > \sum_{m=1}^{2}\Big(L_{h,m}\,|\mathbf{f}_m\cdot\mathbf{a}| + W_{h,m}\,|\mathbf{n}_m\cdot\mathbf{a}|\Big) \]

After each move, a farm vehicle tests its footprint, extended to the front by its stop distance.

\[ \ell_{stop} = 0.8 + \frac{v^2}{2\,a_-} \]

The test rectangle has the center \(\mathbf{p} + \mathbf{f}\,\ell_{stop}/2\), the half length \(L_h + \ell_{stop}/2\) and the half width \(W_h + 0.2\). If it touches a different footprint, the vehicle goes back to its position before the move and its speed becomes 0.

Object Footprint \(L_h \times W_h\)
Agent vehicle Tractor: 3.2 m x 1.35 m. Polaris: 1.95 m x 0.85 m
Farm vehicle Tractor: 2.75 m x 1.3 m. Pickup: 2.95 m x 1.1 m
Highway car Half of the length and the width of its model
Worker 0.35 m x 0.35 m

Meeting. AAcresNpcVehicle::Meeting gives a farm vehicle the rules of the traffic model of the fast simulator (Fast/acres_batch/scenarios_traffic.py, kernels/physics.py). The rules are for a vehicle that comes the other way or stands in its way. AAcresNpcDirector::Oncoming finds that vehicle: the agent vehicle or a farm vehicle that is not parked, ahead within the notice distance of the driver.

Each driver has its own values. The seed of the vehicle gives them.

Value Range
Move to the right for the other vehicle 0 m (60 % of the drivers), 0.2 m to 0.5 m (30 %), onto the verge as far as the ground lets it (10 %)
Speed when it moves onto the verge 2.0 m/s to 4.5 m/s
Patience 4 s to 15 s
Notice distance 80 m to 200 m (80 % of the drivers), 25 m to 50 m (20 %)

The driver measures the gap \(g\) between the two bodies as they are side by side.

Gap What the driver does
\(g \ge 1.1\) m It passes at its speed.
\(0.5 \le g < 1.1\) m It passes at 2.5 m/s or less from 30 m.
\(g < 0.5\) m It stops 6 m before the other vehicle and counts the time that it stands.
\(g < 0.5\) m after its patience It moves as far right as the ground lets it. If the gap is then 0.2 m or more, it goes on at 1.0 m/s. If the ground has the room but the vehicle stands, it goes on at 0.8 m/s while it moves to the right.

The room to the right is the drivable ground of the ground layer: the road, and for the move onto the verge the grass also. The rules do not apply in the parking lot and for 30 m about its entrance: there the vehicles take turns.

In a session of 8 minutes with the seven working vehicles, the count of footprints that overlap for a second was 181 (472 before these rules). A tractor of 2.6 m stops behind a Polaris that stands in the middle of a gravel road of 4 m. The road and its verge are 0.15 m short of the room. It passes when the Polaris stands at the side of the road.

Physics collision. Each traffic vehicle has a box that blocks all collision channels but the wheel trace channel. The body of the agent vehicle thus collides with a traffic vehicle, and the wheel traces and the LiDAR ground traces ignore it. The boxes have the tags ACREObstacle, ACREVehicle and NpcVehicle.

Highway Traffic#

Centreline#

FAcresHighway::Build makes a smooth curve through the points of the road US52 of site.json. Between two points \(\mathbf{P}_1\) and \(\mathbf{P}_2\) with the neighbors \(\mathbf{P}_0\) and \(\mathbf{P}_3\), the curve is a Catmull-Rom spline.

\[ \mathbf{C}(t) = \tfrac{1}{2}\Big[2\mathbf{P}_1 + (\mathbf{P}_2 - \mathbf{P}_0)\,t + (2\mathbf{P}_0 - 5\mathbf{P}_1 + 4\mathbf{P}_2 - \mathbf{P}_3)\,t^2 + (-\mathbf{P}_0 + 3\mathbf{P}_1 - 3\mathbf{P}_2 + \mathbf{P}_3)\,t^3\Big] \]

The function samples the curve each 0.5 m or less and then makes points with a spacing of 2 m along the arc. The position of a car is thus one number: its distance \(S\) from the west end. The tangent at a point is the central difference of its neighbors.

Lanes and Start State#

Each direction has two lanes. The traffic drives on the right: the cars to the east use the south carriageway. site.json gives the offsets of the lane centers from the centreline: \(o_0 = 9.21\) m (inner lane) and \(o_1 = 12.86\) m (outer lane).

AAcresNpcDirector::SetupTraffic puts car \(i\) into the group \(i \bmod 4\): east inner, east outer, west inner, west outer.

Quantity Value
Desired speed \(v_0\), inner lane Uniform, 25.5 m/s to 29 m/s
Desired speed \(v_0\), outer lane Uniform, 22 m/s to 25.5 m/s
Model longer than 6 m Outer lane, \(v_0 \le 23\) m/s
Start speed \(0.9\,v_0\)
Seed of the random stream 5252

The cars of a group start at equal distances along the road, each with a random shift of 0 to 0.45 of that distance.

Car Following#

AAcresNpcDirector::TickTraffic uses the Intelligent Driver Model (Treiber, Hennecke and Helbing, 2000). The leader of a car is the nearest car in front of it in the same lane and direction. The road is a loop for this search.

\[ g = \Delta S - \frac{L_{leader} + L_{car}}{2} \]
\[ s^* = s_0 + \max\!\left(0,\, v\,T + \frac{v\,(v - v_{leader})}{2\sqrt{a_{max}\,b}}\right) \]
\[ \dot v = \operatorname{clamp}\!\left(a_{max}\left[1 - \left(\frac{v}{v_0}\right)^4 - \left(\frac{s^*}{\max(g, 0.1)}\right)^2\right],\, -9,\, a_{max}\right) \]

A car without a leader has no interaction term. The model computes all accelerations before it moves a car.

\[ v \leftarrow \max(0,\, v + \dot v\,h), \qquad S \leftarrow S + D\,v\,h, \qquad h = \min(\Delta t,\, 0.1) \]

\(D\) is +1 for the cars to the east and -1 for the cars to the west. A car that goes past one end of the road continues at the other end.

The position and the yaw of a car come from the center point \(\mathbf{C}(S)\) and the unit tangent \(\mathbf{t}\).

\[ \mathbf{p} = \mathbf{C}(S) + D\,o_k\,(-t_y,\, t_x), \qquad \psi = \mathrm{atan2}(D\,t_y,\, D\,t_x) \]

Each car has its own driver. The ranges are those of the fast simulator's traffic. A vehicle of 6.5 m or more has the ranges of a truck.

Constant Car Truck
\(a_{max}\) 1.5 m/s² to 2.5 m/s² 0.6 m/s² to 1.2 m/s²
\(b\) 2.0 m/s² to 3.0 m/s² 1.5 m/s² to 2.5 m/s²
\(s_0\) 2 m to 4 m 3 m to 6 m
\(T\) 1.0 s to 2.0 s 1.5 s to 2.5 s

The Agent Vehicle on the Highway#

FAcresHighway::Project gives the distance \(S_p\) and the lateral offset \(y_p\) of the agent vehicle. The agent vehicle is the leader of a car when it is in front of the car and when

\[ |y_p - D\,o_k| < 3.3 \text{ m} \]

The gap is then \(D\,(S_p - S) - (L_{car}/2 + 3)\). The leader speed is the speed of the agent vehicle along the road, with a minimum of 0. The cars do not change lanes. A stopped agent vehicle thus stops the cars of its lane.

A car moves without a teleport. The physics engine gives its box the velocity of the move, so the box pushes a vehicle that it touches.

Workers#

A worker walks between the points of its beat and waits at each point. AAcresNpcWorker::Tick moves it.

  • It walks at 1.25 m/s. It turns at 240°/s maximum.
  • It is at a point when the distance is less than 0.4 m. A walker then waits 1 s to 5 s. A crop scout waits 8 s to 20 s.
  • It stops when the corridor test finds an object in front of it. Its corridor has a length of 2.5 m and a half width of 0.6 m.
  • If its direct step is not free, it tries the headings at ±30°, ±60° and ±90°. A step is 0.8 m long.
  • If no heading is free, it waits.
Worker Beat
Road walker 18 nodes of the road graph (approximately 140 m), moved 4.2 m to one side of the road.
Crop scout Four points along the south edge of the field box, 1.8 m outside the field.
Staff Four points between the west edge of parking lot A and the entrance of the building.

A worker has three animations: walk, idle and inspect. It has no collision while it lives.

Impact and Incident Log#

Each frame, a worker computes the position of its chest (0.9 m above the ground) in the frame of the agent vehicle. The agent vehicle strikes the worker when all these conditions are true.

\[ |x| < 2.7 \text{ m}, \qquad |y| < 1.45 \text{ m}, \qquad |z| < 2.5 \text{ m}, \qquad \lVert\mathbf{v}\rVert > 0.7 \text{ m/s} \]

AAcresNpcWorker::Die then changes the worker into a ragdoll. The bodies of the ragdoll get a change of velocity.

\[ \Delta\mathbf{v} = 1.3\,\lVert\mathbf{v}\rVert\,\hat{\mathbf{v}} + (0,\, 0,\, 0.45\,\lVert\mathbf{v}\rVert) \]

A decal below the body grows from a half size of 0.35 m to 1.4 m in 6 s.

AAcresNpcDirector::Incident records the event in three places.

Output Contents
npc-events.csv in the session folder One row: time_s, event, x_m, y_m, speed_mps. The event name is worker_struck.
HUD The message "Worker struck at N km/h" for 6 s.
Log file A line with ACRES_NPC_INCIDENT, the event, the speed and the position.

The position is the Unreal world position in meters. The speed is the speed of the agent vehicle.

The option -NpcTestVictim makes this event in a test. This session drives the Maxxum 30 m to the north from the default spawn.

Packaged/Linux/Acres.sh -VehicleDemo -NpcVehicles -NpcWorkers -NpcTraffic=24 \
  -NpcTestVictim -DriveScript=/data/drive.json -VehicleOutput=/data/npc-session
{"frame": "spawn", "path": [[0, 0], [30, 0]],
 "keys": [{"t": 0, "gear": 8, "speed_kmh": 0}, {"t": 2, "speed_kmh": 8}, {"t": 45, "exit": true}]}

The log file and npc-events.csv then contain these lines.

ACRES_NPC_TRAFFIC cars=24 models=9 road_m=1536
ACRES_NPC_READY road_nodes=2306 spots=34 empty_fields=4 service=4 npcs=45
ACRES_NPC_INCIDENT worker_struck speed=2.09 at X=-3870.968 Y=12651.308 Z=28.428
time_s,event,x_m,y_m,speed_mps
7.981,worker_struck,-38.71,126.51,2.09

The vehicle bridge and the simulator control channel can put more workers into the session. Vehicle Bridge and Simulator Control Channel describe these commands.

Objects on the Path#

A scenario of the run-time library puts persons, trucks, tractors and cars on the path of a mission. ACRES Core and the game run the same actor scripts (Vehicle/Runtime/Source/object_scripts.cpp). The actor interface is in Vehicle/Runtime/Include/acres_runtime/scenario.h, and the generator is Vehicle/Runtime/Source/scenario_gen.cpp.

The motion patterns are static, temporary, crossing, along, walk, stand, emerge, headland, back_out, lead and pull_out. The configuration is Config/path_objects.json. The seed contains the episode seed, the run number and the mission identifier. Thus the same inputs give the same actors for each number of worker processes.

How the actors treat the vehicle. A reactive actor gives way when it sees the vehicle (reaction in the configuration). An actor with no reaction runs its script and does not look at the vehicle. Thus it can walk or drive onto the lane in front of a moving vehicle.

Human-like reactive actors (the default). Each reactive actor has its own draws, so two actors of a scenario do not act the same way:

Property Person Driver
Reaction delay, from the perception to the action (to give way and to go on again) 0.5 s to 1.5 s 0.7 s to 1.5 s
Inattentive share, and the distance at which an inattentive actor notices the vehicle 20 %, 3 m 20 %, 8 m
Distance at which an attentive actor gives way (its own draw, react_m of the script is for the scripted model) 6 m to 15 m 15 m to 30 m
Critical gap: it gives way when the vehicle comes to it in less than this time (react_s of the script is for the scripted model) 6.7 s 6.5 s
Patience (its own draw, patience_s of the script is for the scripted model) 4 s to 15 s 4 s to 15 s
Time to go on again the same critical gap the same critical gap
Time from its walk to a stop, and back 0.3 s to 0.8 s (slows with brake_mps2)
Wander of its speed (an Ornstein-Uhlenbeck process, standard deviation 5 %, time constant 3 s) no bound no bound
Share that does not give way 0 15 %

The time test uses the distance of the two centres and the closing speed of the two. The closing speed is the speed of the vehicle to the actor plus the speed of the actor to the vehicle. The batched simulator has the same law (world.things_step, the physics kernel) since 19 November 2026.

The critical gap of a driver is that of a passenger car at a stop-controlled junction (Fitzpatrick 1991, TRB Human Factors Guidelines for Road Systems 2025). The naturalistic SHRP 2 drives at 60 rural T-junctions gave 5.3 s for a right turn and 6.2 s for a left turn (Li et al. 2022).

The critical gap of a person is the crossing time of a farm road of 4 m at 1.07 m/s plus 3 s (Highway Capacity Manual 2000, equation 18-17). The width of 4 m is an assumed value. Gap acceptance has one critical gap for each actor, thus the same time lets the actor go on again. Before that date the library needed a gap 1.0 to 1.5 times longer, with no source.

The test Tests/Runtime/test_scenario.py (section 5) drives the vehicle at 3 m/s onto the actors of four patterns, 40 seeds each. It compares the human-like actor with the scripted actor of release 1.0.0. The values below come from the runtime build of 19 November 2026, with the actor values and critical gaps of this page:

Pattern Scripted Actor (Release 1.0.0) Human-Like Actor
Crossing person Stops in one step at 5.9 m Stops at 8.3 m (standard deviation 1.7 m), 34 of 40. 31 slow to the stop in 0.3 s to 0.8 s
Person who emerges behind a parked truck Reacts in the step in which it sees the vehicle 29 of 40 react. 2 react before the scripted actor (the critical gap). The other 27 react 0.8 s later (median)
Person who walks against the vehicle Gives way from 8.5 m 6 of 38 notice the vehicle at 3.6 m or nearer. The earliest gives way at 28.9 m
Driver at a headland Gives way 13 of 40 do not give way before the rule of no step. 27 give way from 6.8 m to 23.0 m

The rule of no step (the vehicle is directly ahead with less than 1 m of space) and the rule of the body below are immediate and the same as before.

The draws are a SplitMix64 hash of the index of the actor and of its start pose. Thus a scenario gives the same run each time. An actor with no reaction does not draw and moves as in release 1.0.0. The block human of Config/path_objects.json holds the ranges. It is the one source of these values.

The batched simulator reads the block (Fast/acres_batch/world.py). The run-time library and the game compile Vehicle/Runtime/Source/human_actor_values.h, which Vehicle/Runtime/Tools/human_actor_values.py makes from the block. Tests/Fast/agreement/test_actors.py compares the file with the block and the draws of the two models with each other. The values are those of the batched simulator (11 November 2026). Before that date the library had other values.

An inattentive person noticed the vehicle at 2.5 m to 3.5 m and a driver at 5 m to 7 m. An attentive actor gave way at react_m times 0.75 to 1.25 (4.5 m to 7.5 m for a person, 7.5 m to 12.5 m for a driver). The patience was patience_s times 0.6 to 1.4, and the wander had a bound of 10 %.

The distances and the times are assumed values. They are not measured on the farm. A packaged game has the values of its build: build the game again to get a change of the block. The environment variable ACRES_ACTOR_MODEL=scripted gives the reaction of release 1.0.0: a person stops in one control step and there is no draw.

A person who notices the vehicle late

A person who is inattentive, or who reacts after its delay, can walk onto the lane within the stopping distance of the vehicle. The shield then cannot stop the vehicle in time, and the contact has the class vehicle. The demo sweeps of 21 October 2026 had such contacts with a crossing person. Its trigger_m was 22 m to 26 m, or 34 m with seed 3. The shield and the generator do not change for this. Give a crossing person a larger trigger_m when a scenario must have no contact.

No actor moves into the vehicle. An actor stands when its next motion brings its body within 1 m of the vehicle plan box (Body, WouldEnter). It goes on when its way is free.

A person who walks along the lane steps 2.5 m aside and walks around a vehicle in its way. A truck, a tractor or a car waits. The vehicle must wait or go around it. Thus a contact never comes from the motion of the actor alone.

Headland entrances. A headland actor uses a mapped field entry near the route. The entry must be within 2 m of the route and hold the full start and return footprints inside the field. When no entry is suitable, the generator omits the actor. It does not use a different roadside point.

Make a scenario. Run this from the repository root, with Sim on the Python path and the run-time library built. The route needs the cost tables of the current map.

from acres_fleet import plans, scenarios

route = plans.route("F56")
scenario = scenarios.generate(route, patterns="crossing", seed=7, mission="F56")
scenarios.save(scenario, "f56-actors.json")

Skills.set_scenario puts a scenario into a skill world (The acres_fleet Package). The control channel operation objects loads it into the game (Simulator Control Channel). The episode log records the state of each actor and, as an option, the contact events.

Worked Example#

Stop distance of a tractor. A tractor at its cruise speed of 5 m/s with the braking limit \(a_- = 3.5\) m/s²:

\[ \ell_{stop} = 0.8 + \frac{5^2}{2 \times 3.5} = 4.37\ \text{m}, \qquad \ell = 4 + 2.5 \times 5 = 16.5\ \text{m} \]

The corridor is thus 3.8 times the stop distance. A worker that enters the corridor 16.5 m ahead leaves 12.1 m of margin.

Car following. A highway car at \(v = 25\) m/s behind a leader at 20 m/s, with \(s_0 = 2.5\) m, \(T = 1.3\) s, \(a_{max} = 1.6\) m/s² and \(b = 2.5\) m/s²:

\[ s^* = 2.5 + 25 \times 1.3 + \frac{25 \times 5}{2\sqrt{1.6 \times 2.5}} = 66.25\ \text{m} \]

At a gap of 60 m and a desired speed \(v_0 = 29\) m/s, the acceleration is \(1.6\,[1 - (25/29)^4 - (66.25/60)^2] = -1.23\) m/s².

Code#

Item File Function
Road graph Game/Source/Acres/AcresNpc.cpp FAcresRoadGraph::Build, Nearest, Route
Set-up of the traffic Game/Source/Acres/AcresNpc.cpp AAcresNpcDirector::Setup, SetupTraffic, LoadCarModels
Corridor and footprint tests Game/Source/Acres/AcresNpc.cpp AAcresNpcDirector::Blocked, AAcresNpcDirector::Overlaps
Parking lot queue Game/Source/Acres/AcresNpc.cpp AAcresNpcDirector::RequestLot, ReleaseLot
Farm vehicle Game/Source/Acres/AcresNpc.cpp AAcresNpcVehicle::Plan, Tick, StartManeuver, PickStall
Highway curve Game/Source/Acres/AcresNpc.cpp FAcresHighway::Build, Sample, Project
Car following Game/Source/Acres/AcresNpc.cpp AAcresNpcDirector::TickTraffic, AAcresNpcCar::Place
Worker Game/Source/Acres/AcresNpc.cpp AAcresNpcWorker::Init, Tick, Die
Incident log Game/Source/Acres/AcresNpc.cpp AAcresNpcDirector::Incident, EndPlay
Wheel animation and ground pose Game/Source/Acres/AcresNpc.cpp FAcresNpcWheelRig::Update, GroundPose
Start of the director Game/Source/Acres/AcresVehicle.cpp AAcresVehiclePawn::BeginPlay
Menu settings Game/Source/Acres/AcresSession.cpp npc:vehicles, npc:workers
Car model import Tools/Assets/Unreal/import_npc_cars.py

The log file shows the state of the traffic with these markers: ACRES_NPC_READY, ACRES_NPC_TRAFFIC, ACRES_NPC_LEAVING, ACRES_NPC_PARKED, ACRES_NPC_STUCK and ACRES_NPC_OVERLAP.

Parameters#

Options and Menu Settings#

Name Type Unit Default Description
-NpcVehicles switch off Adds the tractors, the pickups and 16 highway cars. The menu setting is npc:vehicles.
-NpcWorkers switch off Adds the ten workers. The menu setting is npc:workers.
-NpcTraffic= integer 16 or 0 The number of highway cars, from 0 to 200. Alone, it starts only the highway cars.
-NpcTestVictim switch off Puts one more worker 14 m in front of the agent vehicle. It is a test option.

npc_cars.json#

The file Game/Content/Simulation/npc_cars.json lists the car models of the highway traffic. Tools/Assets/Unreal/import_npc_cars.py writes it. If the file is not available, there are no highway cars.

Name Type Unit Default Description
cars[].name text The name of the model, for example suv.
cars[].body text The asset path of the body mesh.
cars[].wheel text The asset path of the wheel mesh. It is a left wheel.
cars[].glass text The asset path of the glass mesh (see-through, no shadow, not seen by the LiDAR). Optional.
cars[].length_m number m 4.65 to 7.9 The length of the model.
cars[].width_m number m 1.83 to 2.727 The width of the model (the SUV and the pickup: without the mirrors).
cars[].height_m number m 1.73 to 2.534 The height of the model.
cars[].wheel_radius_m number m 0.352 to 0.407 The radius of the wheels.
cars[].wheel_width_m number m The width of the wheels. The game does not read it.
cars[].wheel_positions_m array m 4 or 6 points The wheel centers: x forward, y right, z up from the ground point below the body center.
cars[].paint_material_indices array The material slots that get the paint color of the car.
cars[].paints[] array The paints of the model: name, base_color (linear RGB), share (the part of the cars with this paint) and material (the material instance that the parked cars use). Optional: a model without paints gets a color of the traffic's palette.

The four models are suv (Tools/Assets/Vehicles/build_suv.py), pickup (Tools/Assets/Vehicles/build_pickup.py), truck_medium and truck_tandem (Tools/Assets/Vehicles/build_truck.py). The first is a single axle truck with a 12 ft grain box, 6.56 x 2.44 m, roof 2.75 m. The second is a tandem axle truck with a 27.5 ft box, 11.66 x 2.59 m, roof 3.10 m. (These are class values of conventional grain trucks.) The SUV's paints and their shares (an approximation of the colors of new cars in the USA, not a measurement): white 0.24, black 0.21, grey 0.18, silver 0.11, blue 0.09, red 0.09, green 0.04, bronze 0.04.

Limitations#

  • The traffic moves with the frame time. Two sessions with different frame rates do not give the same traffic.
  • The road graph uses the centrelines of site.json. Only the line of US 52 is on the measured road. A lookup of the ground layer along the other lines shows that 26 % of their length is on the class field.
  • A vehicle that has no room to pass waits. It does not go backward and does not select a different route.
  • The keep-right move uses the ground layer, not the road graph's widths. The road graph still uses the centrelines of site.json.
  • The highway cars do not change lanes and do not leave the highway.
  • A traffic tractor does not change the soil, the crops or the ruts.
  • A worker stops for a vehicle in its corridor, but it does not move away from a vehicle that comes nearer.
  • The impact test and the footprint of the agent vehicle have the size of the Maxxum. The model uses the same sizes for the Polaris.
  • The traffic knows only the vehicle of agent 0. It does not see the other agents of a session.
  • The comments in AcresNpc.h give smaller counts than the code: two tractors, two pickups, four workers and 28 stalls.

References#

  • Treiber, M., Hennecke, A., and Helbing, D. (2000). Congested traffic states in empirical observations and microscopic simulations. Physical Review E, 62(2), 1805-1824.
  • Catmull, E., and Rom, R. (1974). A class of local interpolating splines. In R. E. Barnhill and R. F. Riesenfeld (Eds.), Computer Aided Geometric Design (pp. 317-326). Academic Press.
  • Dijkstra, E. W. (1959). A note on two problems in connexion with graphs. Numerische Mathematik, 1, 269-271.
  • Gottschalk, S., Lin, M. C., and Manocha, D. (1996). OBBTree: A hierarchical structure for rapid interference detection. Proceedings of SIGGRAPH 96, 171-180.