Skip to content

CoreSimDbw.h#

ROS/acres_core_sim/include/acres_core_sim/CoreSimDbw.h Generated

The Polaris' drive-by-wire command path between the RL / DBW bridge's JSON messages and the vehicle model, as the game runs it (AcresRlBridge.cpp HandleDbw, AcresPolaris.cpp StepPolarisControls and PublishPolaris, AcresRlBridge.cpp SendDbwReports), without the keyboard driver and the session's own drivers (replay, drive script), which the Core does not have:

  • a message updates the inbox (the latest command of each subsystem with a sequence number, the system enable with its own) and a snapshot is queued with the solver time it applies at (AcresCommandTiming.h: its arrival mapped onto the physics steps; in lockstep the next step);
  • each physics step takes the snapshots due, turns a new sequence number into a fresh message (the ...Fresh flags that restart the model's 0.1 s command timeout) and hands a subsystem to the bridge for 0.25 s after its last message while the system is enabled; the gear command applies while enabled, else the driver's lever (P);
  • after the step, the report fields (FAcresDbwTelemetry of the game) and, on the 50 Hz grid of physics time, a "dbw_report" JSON line in the game's format, which acres_sim turns into the ds_dbw_msgs reports.

One agent's simulation thread; Post may be called from that thread only (the server parses on it).

FDbwInbox#

struct FDbwInbox

The game's FAcresDbwInbox: the latest command of each subsystem and its sequence number.

FDbwTelemetry#

struct FDbwTelemetry

Report fields after a step (the game's FAcresDbwTelemetry, the fields the JSON report carries).

FDbwPath#

class FDbwPath

One Polaris' command path. See the file comment.

Name Type Unit Default Description
ExternalHoldS static constexpr double s .25 A subsystem the bridge commanded within this long is the bridge's, s (AcresPolaris.cpp ExternalHoldS).
ReportPeriodS static constexpr double s .02 DBW report period, s (Dataspeed reports at 50 Hz).
DriveMode int AcresSim::UtvDriveAllWheel AWD switch position (EUtvDriveMode), set by "drive_mode".
Lever int AcresSim::UtvGearPark The driver's gear lever (EUtvGear; P at session start).

FDbwPath::Post#

Applies one JSON line's drive-by-wire keys (dbw, steering_cmd, throttle_cmd, brake_cmd, gear_cmd, ulc_cmd, drive_mode) as the game's HandleDbw does; command types the model does not have are rejected (counted).

Argument Description
Message The parsed line.
ApplyAtS Solver time the snapshot applies at (AcresSim::ApplyAtNextStep: the next step).

Returns: True when the line had a drive-by-wire key.

bool Post(const nlohmann::json& Message, double ApplyAtS);

FDbwPath::Step#

The command of one physics step (StepPolarisControls without a keyboard or session driver).

Argument Description
StepStartS Solver time at the step's start, s (the queue's clock).
NowS The vehicle's physics time, s (the hold clock).
SteeringCenterDeg The steering wheel angle of the driver's centred wheel, deg.

Returns: The command for AcresSim::StepDbw (fresh flags, driver fields, gear, drive mode).

AcresSim::FDbwCommand Step(double StepStartS, double NowS, double SteeringCenterDeg);

FDbwPath::Publish#

Report fields after the step (PublishPolaris), and whether a 50 Hz report falls due at this physics time.

bool Publish(double Dt, double PhysicsTimeS, const AcresSim::FUtvParameters& P, const AcresSim::FUtvState& S, FDbwTelemetry& Out);

FDbwPath::ReportJson#

The "dbw_report" line of the game's RL bridge (AcresRlBridge.cpp SendDbwReports), with its newline.

static std::string ReportJson(const std::string& Agent, double TimeS, const FDbwTelemetry& R, double CommandTimeoutS);

FDbwPath::Teleported#

A vehicle teleport: the measured acceleration restarts (the enable, the inbox and the queued commands stay, as in the game's ResetPolaris).

void Teleported(double StartSpeedMps);

FDbwPath::Enabled#

The system enable (/vehicle/enable) as the last step saw it.

bool Enabled() const ;

FDbwPath::Rejected#

Messages rejected (unknown command types) so far.

int Rejected() const ;