Skip to content

AcresReplay.h#

Acres/Source/Acres/AcresReplay.h Generated

Replay input: a recorded drive the tractor can follow again.

A replay file is a CSV with a header row. It can be an ACRES session log (tractor.csv, or the session folder that holds it) or a minimal command file written by another program, for example an AI driving policy. Accepted column names (the first match wins):

time       time_s | t
speed      speed_mps | v_forward_mps | v                     signed m/s, negative = reverse
curvature  curvature_1pm | curvature_command_1pm |
           curvature_measured_1pm | kappa                    1/m, left turns positive
path       east_m, north_m | ue_x_m, ue_y_m                  optional; enables path following and the start pose
heading    heading_deg                                       optional, degrees clockwise from north
implement  implement | harvest                               optional 0/1, harvest cutter on or off
gear       gear                                              optional forward gear 1..16

The vehicle (AcresVehicle.cpp) samples the track on the physics thread. In "commands" mode it applies speed and Ackermann steering (steer = atan(curvature x wheelbase)); in "path" mode it follows the path with pure pursuit and looks up speed, implement and gear by position along the path.

FAcresReplayTrack#

struct FAcresReplayTrack

A replay loaded into memory, resampled to at most 20 Hz.

All arrays have one entry per kept row. Optional arrays (X, Y, HeadingDeg, Implement, Gear) are filled only when the matching flag is set.

Example

FAcresReplayTrack Track;
FString Error;
if (FAcresReplayTrack::Load(TEXT("/data/run-12"), Track, Error))
{
    double V, K; bool bCut;
    Track.Sample(5.0, V, K, bCut);   // speed, curvature and cutter state 5 s in
}
Name Type Unit Default Description
T TArray<double> Time, s (as in the file, first row may be non-zero).
Speed TArray<double> Signed forward speed, m/s.
Kappa TArray<double> Path curvature, 1/m, left positive. X,
X TArray<double> See above.
Y TArray<double> Position in world metres (X east, Y south).
HeadingDeg TArray<double> ° Heading, degrees clockwise from north.
Implement TArray<uint8> 1 = cutter on.
Gear TArray<uint8> Forward gear 1..16, 0 = let the controller choose.
bPath, bHeading, bImplement, bGear bool Which optional columns were present.
Source FString Absolute path of the CSV that was read.

FAcresReplayTrack::Load#

Reads and validates a replay CSV.

Rows closer than 50 ms to the previous kept row are skipped, so 120 Hz session logs come in at 20 Hz.

Argument Description
Path A CSV file, or a session folder (its tractor.csv is used).
Out Receives the track; replaced on success.
Error Set to a readable reason on failure.

Returns: False when the file is missing, lacks time/speed/curvature columns, time does not increase, or a value is out of range (|speed| > 20 m/s, |curvature| > 1 /m).

static bool Load(const FString& Path, FAcresReplayTrack& Out, FString& Error);

FAcresReplayTrack::Sample#

Linear interpolation of speed and curvature at a time offset.

Argument Description
Time Seconds after the first row (0 = start of the track). Clamped to the track.
OutSpeed Speed, m/s.
OutKappa Curvature, 1/m.
OutImplement Nearest-row cutter state (false when the column is absent).
void Sample(double Time, double& OutSpeed, double& OutKappa, bool& OutImplement) const;

FAcresReplayTrack::GearAt#

Gear in effect at a time offset.

Argument Description
Time Seconds after the first row.

Returns: Forward gear 1..16, or 0 when the file has no gear column or the row says 0 (controller chooses).

int GearAt(double Time) const;

FAcresReplayTrack::Duration#

Length of the track in seconds (last time minus first time).

double Duration() const ;