porisius / FicsitRemoteMonitoring

56 stars 12 forks source link

Trains are `REALLY` fast #163

Open saffronjam opened 20 hours ago

saffronjam commented 20 hours ago

Hi,

It's me again :D

I am noticing my trains are reaching really high speed according to the API, while they are not in game (comparing with the UI when driving/riding a train).

[
  {
    "ID": "BP_Train_C_2143971800",
    "Name": "[Con] 1",
    "ClassName": "BP_Train_C",
    "location": {
      "x": -279329.794589808,
      "y": -68231.1170365018,
      "z": 729.644048154571,
      "rotation": 90.7203158709069
    },
    "TotalMass": 475318,
    "PayloadMass": 115318,
    "MaxPayloadMass": 140000,
    "ForwardSpeed": 2858.01025390625,   <--- Should be km/h according to docs
    "ThrottlePercent": 100,
    "TrainStation": "[EMO Im] Concrete",
    "Derailed": false,
    "PendingDerail": false,
    "Status": "Self-Driving",
...

image

(Screenshot is not exactly at the same time as the API fetch)

Interestingly, it seems to be a linear offset, where if I divide by more or less 27.9, it gives the correct speed.

Th3Fanbus commented 19 hours ago

From what I can tell, the number comes from UFGRailroadVehicleMovementComponent (base class of UFGLocomotiveMovementComponent): https://github.com/porisius/FicsitRemoteMonitoring/blob/main/Source/FicsitRemoteMonitoring/Private/FRM_Trains.cpp#L69

/** Speed of this vehicle along the track. In the direction of the train. [cm/s] */
UFUNCTION( BlueprintPure, Category = "FactoryGame|Railroad|Movement" )
FORCEINLINE float GetForwardSpeed() const { return mVelocity; }

So yes, the units seem to be wrong.

porisius commented 4 hours ago

Probably one of the issues that were fix that re-broke (lack of better term) when the rewrite was done.

If I remember correctly, UE reports back in cm/s or some weird measurement. I can get something up to the build server here in a few.