openrails icon indicating copy to clipboard operation
openrails copied to clipboard

Automatic speed control

Open cesarBLG opened this issue 10 months ago • 3 comments

Several improvements to the cruise control subsystem, including:

  • Interface with the TCS to implement Automatic Train Operation. Exposed parameters are SetSpeedMpS and SetSpeedAccelerationMpSS which determine the permitted speed and deceleration of the braking curve.
  • Use a linear conversion from 'delta' speed (difference between set speed and current train speed) to deceleration. The legacy algorithm (which is kept as default to maintain compatibility) is non-linear and causes oscillations for small deltas (small changes in speed result in big changes in throttle demand).
  • Simplified the code

https://blueprints.launchpad.net/or/+spec/cruise-control-extensions

https://www.elvastower.com/forums/index.php?/topic/33841-cruise-control/page__view__findpost__p__318664

cesarBLG avatar May 21 '25 19:05 cesarBLG

Hi César, about this https://www.elvastower.com/forums/index.php?/topic/39072-u20250824-0738-restore-crash-using-a-locomotive-with-tcs-and-cc/#entry321033 I made some investigation and saw that the crash started to occur when I merged the present PR into ORNYMG. I checked the code and believe I detected a bug in the Save/Restore code of the MaxForceSelectorController within CruiseControl.cs.

The MaxForceSelectorController Save/Restore code calls two methods within MSTSNotchController.cs. However those two methods aren't symmetrical. The Save code within MSTSNotchController.cs has a line outf.Write((int)ControllerTypes.MSTSNotchController); which has no corresponding line in the Restore code. And in fact, if you check another place where the Restore code is called, that is MSTSWagon.cs where WeightLoadController data are restored, the restore code is as follows: var controllerType = inf.ReadInt32(); WeightLoadController.Restore(inf);

Moreover I don't know if a null check for the MaxForceSelectorController has to be done before saving and restoring it.

Csantucci avatar Aug 25 '25 14:08 Csantucci

Thanks for reporting Carlo. I'm travelling and I don't have access to my PC, I'll fix it as soon as I come back.

I think it's not wise to have non-symmetrical save/restore for the NotchController, which differs from the rest of the save/restore methods, so I'll take a look.

cesarBLG avatar Aug 27 '25 01:08 cesarBLG

I uploaded a fix. However, It looks like all the controller save/restore process is unnecessarily complicated. I don't know why it was done in such a way, but I'll try to simplify it.

cesarBLG avatar Aug 30 '25 14:08 cesarBLG