Skip to content

AcresSimModel.h#

Acres/Source/Acres/AcresSimModel.h Generated

Small engine-independent vehicle helpers: engine torque curve, wheel slip ratio and Ackermann steering.

Pure C++ with no Unreal types, so it compiles and can be tested without the engine. Everything is SI (metres, newtons, seconds, radians); convert to Unreal units (centimetres, degrees) only where values meet the engine. AcresVehicleModel.cpp calls Torque, Slip and Ackermann every physics step (120 Hz, physics thread).

Name Type Unit Default Description
StandardGravityMps2 inline constexpr double m/s² 9.80665 Standard gravity, m/s2.

Torque#

Full-load engine torque at a given speed, by linear interpolation of a torque curve.

The curve is rescaled so its highest point equals PeakTorqueNm. Speeds below the first point return the first point's torque, speeds above the last point return the last point's torque, and speeds at or above MaxRpm return 0 (fuel cut-off).

Argument Description
TorqueCurve Array of CurveCount points sorted by rising rpm. May be null.
CurveCount Number of points in TorqueCurve.
PeakTorqueNm Peak torque the curve is scaled to, N m.
MaxRpm Engine speed at and above which torque is zero (fuel cut-off), rev/min.
Rpm Current engine speed, rev/min.

Returns: Full-load torque, N m. 0 for a null or empty curve.

double Torque(const FTorquePoint* TorqueCurve, std::size_t CurveCount, double PeakTorqueNm, double MaxRpm, double Rpm);

Example

const double TNm = Torque(P.TorqueCurve.data(), P.TorqueCurve.size(), 700.0, 2300.0, 1500.0);

Slip#

Longitudinal slip ratio of a wheel.

s = (omegar - v) / max(0.2, |omegar|, |v|). Positive when the wheel spins faster than it travels (driving), negative when it drags (braking). The 0.2 m/s floor keeps it finite near standstill.

Argument Description
WheelOmegaRadPerSec Wheel spin rate, rad/s.
RadiusM Rolling radius, m.
SpeedMps Ground speed of the contact point along the wheel heading, m/s.

Returns: Slip ratio, dimensionless, in [-1, 1] except in the low-speed floor region.

double Slip(double WheelOmegaRadPerSec, double RadiusM, double SpeedMps);

Ackermann#

Left and right front wheel angles for a bicycle-model steering angle.

Turn radius at the rear axle centre R = L / tan|delta|; inner wheel atan(L / (R - T/2)) (with R - T/2 floored at 0.1 m), outer wheel atan(L / (R + T/2)). Below 1e-5 rad both angles are zero.

Argument Description
SteeringRadians Bicycle-model steering angle, rad. Positive steers left.
WheelbaseM Wheelbase L, m.
TrackM Front track width T, m.

Returns: Left and right wheel angles, rad.

FAckermannAngles Ackermann(double SteeringRadians, double WheelbaseM, double TrackM);

Example

const FAckermannAngles A = Ackermann(0.3, 2.64, 1.9); // A.LeftRadians > A.RightRadians > 0

FVector3d#

struct FVector3d

Plain double-precision 3-vector (SI unless the function says otherwise).

Used instead of Unreal's FVector so this file compiles without the engine.

Name Type Unit Default Description
X double 0.0 X component.
Y double 0.0 Y component.
Z double 0.0 Z component.

FTorquePoint#

struct FTorquePoint

One point of an engine full-load torque curve.

Name Type Unit Default Description
Rpm double 0.0 Engine speed, rev/min.
TorqueNm double N·m 0.0 Full-load torque at that speed, N m.

FAckermannAngles#

struct FAckermannAngles

Front wheel steering angles from the Ackermann geometry.

On a left turn the left wheel is the inner one and steers more; on a right turn it's the other way round.

Name Type Unit Default Description
LeftRadians double 0.0 Left front wheel angle, rad (positive = steer left). Largest magnitude when turning left.
RightRadians double 0.0 Right front wheel angle, rad (positive = steer left). Largest magnitude when turning right.