Cruise control
#181
Posted 19 November 2022 - 12:03 PM
The manual has been updated and can be found (in html version) here http://interazioni-e...wYear_MG_Manual (search for Cruise Control chapter). The new parameter can be used both when throttle commands selected speed and when throttle commands max force, and both when there is a simple throttle or when there is a combined control.
Changes have been inserted also in the official OR versions, but the related Unstable release hasn't yet appeared.
Blueprint approval is still not there.
#182
Posted 23 November 2022 - 12:12 PM
I want to credit again Jindrich, which is the initial author of this feature. Most part of the code and logic is his creation.
#183
Posted 24 November 2022 - 07:26 AM
- Is it possible to control the Force Selector with a Multi Position controller?
- Why is a unique value not received from the Cabview controller for each position type?:
Position Type Cabview animation frame ThrottleIncrease 0 DynamicBrakeDecrease 0 TrainBrakeDecrease 0 DynamicBrakeHold 0 ThrottleIncreaseOrDynamicBrakeDecreaseFast 0 ThrottleIncreaseOrDynamicBrakeDecrease 0 DynamicBrakeIncreaseOrThrottleDecreaseFast 0 DynamicBrakeIncreaseOrThrottleDecrease 0 KeepCurrent 0 Drive 1 ThrottleHold 1 Neutral 2 DynamicBrakeIncrease 3 TrainBrakeIncrease 4 DynamicBrakeIncreaseFast 5 EmergencyBrake 5 ThrottleIncreaseFast 6 ThrottleDecrease 7 ThrottleDecreaseFast 8 SelectedSpeedIncrease 9 SelectedSpeedDecrease 10 SelectSpeedZero 11
Among these, there are completely opposite ones, which are recived the same value. For example: ThrottleIncreaseOrDynamicBrakeDecrease and DynamicBrakeIncreaseOrThrottleDecrease
#184
Posted 24 November 2022 - 08:13 AM
2. In fact it is as you are writing, and I think this should be changed to provide different values for every position type. However this must be done carefully to avoid malfunctions in already published locomotives. I have always used only Position Types SelectedSpeedIncrease, Neutral, SelectedSpeedDecrease and SelectSpeedZero. It would be interesting to know what Position Types other people have used.
A comment by Jindrich about point 2. would also be welcome.
#185
Posted 07 January 2023 - 12:49 PM
I'm having some trouble implementing cruise control on an electric locomotive.
I'm trying to implement a 2 lever system:
1- Throtlle and dynamic brake combined lever. When CC is on this lever acts as force selector
2- CC lever acting as a proportional speed selector.
So far this is what I have in my eng file:
ORTSCruiseControl ( MaxForceSteps ( 10 ) comment (** Usually will be 100 meaning 100%, but some locos have limited force steps **) SpeedSelectorStepTimeSeconds ( 0.5 ) comment (** how fast the selected speed lever adds speed, 0.3 is one step in 0.3 seconds **) DynamicBrakeMaxForceAtSelectorStep ( 50 ) comment (** the brake will reach 100% at this step, the lower step the max brake percent will be also lower **) NominalSpeedStep ( 5 ) comment (** when pressing Shift+A or Shift+D how many speed units should the selected speed change **) StartReducingSpeedDelta ( 0.5 ) (** the lower number, the sooner the regulator will decrease power **) StartReducingSpeedDeltaDownwards ( 1.0 ) (** the lower number, the sooner the regulator will decrease power when dynamically braking**) ForceRegulatorAutoWhenNonZeroForceSelected ( True ) comment (** When a non zero speed is selected, the regulator is set to auto **) ForceRegulatorAutoWhenNonZeroSpeedSelectedAndThrottleAtZero ( True ) comment (** Self explaining **) MaxForceKeepSelectedStepWhenManualModeSet ( True ) comment (** Self explaining **) ForceResetRequiredAfterBraking ( True ) comment (** After manual braking, to apply again force, the force must first be manually reset to zero **) ResetForceAfterAnyBraking ( True ) DynamicBrakeIsSelectedForceDependant ( True ) comment (** If true dynamic brake force applied depends from the position of the force selector, else always the maximum dynamic brake force is applied **) ThrottleFullRangeIncreaseTimeSeconds ( 4 ) comment (** time in seconds needed for the regulator to reach 0-100% of power **) ThrottleFullRangeDecreaseTimeSeconds ( 4 ) comment (** time in seconds needed for the regulator to reach 100-0% of power **) DynamicBrakeFullRangeIncreaseTimeSeconds ( 2 ) comment ( ** same as above, but for dynamic braking ** ) DynamicBrakeFullRangeDecreaseTimeSeconds ( 2 ) comment ( ** same as above, but for dynamic braking ** ) DefaultForceStep ( 0 ) comment (** When OR is started, this will be the selected force step, usually set at 0 **) DisableCruiseControlOnThrottleAndZeroForceAndZeroSpeed ( True ) Comment (** enables manual if moving throttle or combined control when selected force and selected speed are at zero **) DynamicBrakeCommandHasPriorityOverCruiseControl ( True ) comment (** When cruise control is in Auto, manually activating the dynamic brake has priority **) HasIndependentThrottleDynamicBrakeLever ( True ) comment (** added now ** The cabview is equipped with a combined Throttle-Dynamic brake lever independent from the CC controls **) DoComputeNumberOfAxles ( True ) comment (** Number of train axles automatically computed at game start **) UseThrottleAsForceSelector ( True ) comment (** if ControllerCruiseControlLogic is set to None, throttle when in Auto mode will change the maximum CC Force **) ForceResetIncludeDynamicBrake ( True ) Options ( "RegulatorManual, RegulatorAuto, SelectorOn, StartFromZero, EngageForceOnNonZeroSpeed" ) )
This is on my CVF:
Lever ( Type ( ORTS_SELECTED_SPEED_SELECTOR LEVER ) Position ( 520 338 49 88 ) Graphic ( 4700power.ace ) Style ( NOT_SPRUNG ) MouseControl ( 1 ) NumFrames ( 10 5 2 ) NumPositions ( 0 ) NumValues ( 0 ) Orientation ( 1 ) DirIncrease ( 1 ) ScaleRange ( 0 220 ) Units ( KM_PER_HOUR ) ) CombinedControl ( Type ( CP_HANDLE COMBINED_CONTROL ) Position ( 334 376 59 114 ) Graphic ( 5600_combined.ace ) Style ( NONE ) MouseControl ( 1 ) NumFrames ( 18 9 2 ) NumPositions ( 18 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ) NumValues ( 18 0 0.059 0.118 0.176 0.235 0.294 0.353 0.412 0.471 0.529 0.588 0.647 0.706 0.765 0.824 0.882 0.941 1 ) Orientation ( 1 ) DirIncrease ( 1 ) )
It appears to work, but when the locomotive starts moving, in a few seconds the simulation crashes.
I'm attaching the log file. I thank anyone that can give me a few hints on this, and if there is any cab control to create an indicator for CC being active, or even a button to activate an make CC available.
Attached File(s)
-
OpenRailsLog.txt (24.65K)
Number of downloads: 299
#186
Posted 10 May 2023 - 09:59 PM
For context, the Genesis locomotives have a simple cruise control that will hold the current speed when activated using power limited to the throttle setting, with no use of braking at all and no buttons to directly change the speed setting. The only operator controls are MFD buttons to turn cruise on and off. Also, the throttle needs to be above idle to enable the system-which is interesting. Quite a few systems require 0 throttle to enable/disable but this is the inverse.
https://i.imgur.com/77XK3ge.png
- I would really like a way to explicitly disable the use of dynamic braking. I know I can set the "DynamicBrakeFullRangeIncreaseTimeSeconds" to a very large number, which does prevent dynamic brake force from appearing, but it does not actually prevent the dynamic brakes from setting up. This causes interesting problems (eg: If I set the cruise mode from automatic to manual with the throttle open while the cruise system was trying to use dynamic braking, the resulting state is a broken setup where the throttle is open and the dynamic brakes are set to 0% at the same time! This weird state prevents throttle increases; reducing the throttle to idle is required to set the dynamic brakes to off, then normal control is restored. Maybe when cruise control is set to manual mode it should disable dynamic brakes instead of leaving them set to 0%?). There is an option to explicitly enable/disable the use of train brakes, so why not for dynamic brakes?
- I need a way to make use of the train brake set the control mode back to manual. This is a behavior of the real genesis locomotives which I was unable to replicate, as the only triggers for disabling cruise control automatically are DisableCruiseControlOnThrottleAndZeroSpeed and DisableCruiseControlOnThrottleAndZeroForce. Using the train brake does disable CC tractive effort, but it doesn't actually set things back to manual.
- Activating cruise control while in motion with throttle applied was resulting in my tractive force instantly dropping to 0 (I guess the system initializes to 0 force, even when the selected throttle isn't 0), which is jarring. It should start at the current power output and gradually reduce the throttle.
- On the real locomotive, turning on cruise control while it is already on will re-select the current speed as the cruise speed (useful if speed increased or decreased from the setpoint due to a hill), but that cannot be done in OR.
Cruise parameters for reference:
ORTSCruiseControl ( MaxForceSteps ( 8 ) Comment ( Throttle controls cruise control force, and the throttle has 8 notches. ) SpeedIsMPH ( True ) NominalSpeedStep ( 0 ) Comment ( This system does not allow manual speed setting. Speed is set based on current speed at activation time. ) SpeedSelectorStepTimeSeconds ( 1e9 ) Comment ( This will also prevent manual adjustments of speed setting. ) UseThrottleAsForceSelector ( True ) Comment ( The throttle sets the maximum power the cruise control will use. ) UseThrottleInCombinedControl ( True ) Comment ( Required for locomotives which have a combined throttle and dynamic brake. ) ModeSwitchAllowedWithThrottleNotAtZero ( True ) Comment ( This system allows, and requires, throttle to be applied to activate. ) ThrottleNeutralPosition ( True ) Comment ( Setting zero throttle disables this cruise control system entirely. ) StartReducingSpeedDelta ( 0.1 ) Comment ( Set quite low to make acceleration more conservative. Should avoid overshoots. ) Options ( "RegulatorManual, RegulatorAuto, EngageForceOnNonZeroSpeed" ) ThrottleFullRangeIncreaseTimeSeconds ( 10 ) ThrottleFullRangeDecreaseTimeSeconds ( 10 ) DynamicBrakeFullRangeIncreaseTimeSeconds ( 1e9 ) Comment ( Force dynamic brake to take effectively infinite time to ramp up, preventing dynamics from being used. ) DynamicBrakeFullRangeDecreaseTimeSeconds ( 1 ) DisableCruiseControlOnThrottleAndZeroSpeed ( True ) Comment ( Resets cruise when train departs after a stop. ) DisableCruiseControlOnThrottleAndZeroForce ( True ) Comment ( Forces cruise to disable when throttling up from idle, as real system is disabled by idle throttle. ) DoComputeNumberOfAxles ( True ) Comment ( No manual entering of axle information. ) )
#187
Posted 11 May 2023 - 12:37 AM
Quote
Hello.
I did something similar. It accelerates to the set speed and holds it.
He can't brake.
Below is the complete code. The last line is the point.
ORTSCruiseControl ( MaxForceSteps ( 1 ) SpeedSelectorStepTimeSeconds ( 0.5 ) NominalSpeedStep ( 20 ) Options ( "RegulatorManual, RegulatorAuto, SelectorOn, StartFromZero, EngageForceOnNonZeroSpeed" ) StartReducingSpeedDelta ( 0.5 ) ForceRegulatorAutoWhenNonZeroSpeedSelected ( True ) ForceRegulatorAutoWhenNonZeroSpeedSelectedAndThrottleAtZero ( True ) MaxForceKeepSelectedStepWhenManualModeSet ( True ) ThrottleFullRangeIncreaseTimeSeconds ( 4 ) ThrottleFullRangeDecreaseTimeSeconds ( 4 ) MaxPowerThreshold ( 5.5 ) UseThrottleAsSpeedSelector ( False ) UseThrottleAsForceSelector ( True ) UseThrottleInCombinedControl ( True ) ControllerCruiseControlLogic ( None ) HasProportionalSpeedSelector ( True ) SpeedSelectorIsDiscrete ( True ) ModeSwitchAllowedWithThrottleNotAtZero ( True ) TrainBrakeMinPercentValue ( 0 ) Comment ( This is the minimum train brake percentage used by CC. 0 means no braking. ) )
Sincerely, Laci1959.
#188
Posted 11 May 2023 - 12:46 AM
Quote
Hello.
Vehicles used in Hungary do not have this. There is only the lever for setting the speed and an on/off switch. FLIRT, KISS motor trains have only the lever for setting the speed. Fixed in zero position. You have to lift it a little and move it forward. With this, CC is already turned on. CC is switched off in the zero position of the lever.
Out of curiosity, I omitted the Multi Position controller and it works.
Sincerely, Laci1959.
#189
Posted 11 May 2023 - 05:58 PM
If I had to guess, it seems something in the if statement on line 508 of CruiseControl.cs may be mistakenly triggering CCThrottleOrDynBrakePercent = 0 even if TrainBrakePriority is false. Taking a close look, we have a statement that says "If (the brake pipe pressure is more than 1 psi below the max system pressure, or (the EP wire is commanding a brake application and the train brake has priority)) and the cruise control isn't using the train brake, then...". See the mistake? Due to order of operations, the train brake priority is anded with the EP wire, THEN that result is or'd with the brake pipe check. Thus, if the brake is applied, regardless of the train brake priority or EP wire, the cruise control will be set to 0.
else if ((Locomotive.TrainBrakeController.MaxPressurePSI - Locomotive.BrakeSystem.BrakeLine1PressurePSI > 1 || Locomotive.Train.BrakeLine4 > 0 && TrainBrakePriority) && !CCIsUsingTrainBrake) { reducingForce = true; timeFromEngineMoved = 0; if (CCThrottleOrDynBrakePercent > 0) CCThrottleOrDynBrakePercent = 0; }
I believe the fix to this would be a simple case of moving parenthesis to change that if statement to this. In this case, no matter what anything else evaluates to, if train brake priority is false then the statement won't run and the cruise control won't reset, thus fixing the problem. I'd like to try fixing that but I'm not exactly set up to compile OpenRails, and I don't have the time to set that up right now.
else if ((Locomotive.TrainBrakeController.MaxPressurePSI - Locomotive.BrakeSystem.BrakeLine1PressurePSI > 1 || Locomotive.Train.BrakeLine4 > 0 ) && TrainBrakePriority && !CCIsUsingTrainBrake) { reducingForce = true; timeFromEngineMoved = 0; if (CCThrottleOrDynBrakePercent > 0) CCThrottleOrDynBrakePercent = 0; }
Regardless, this does not give me the result I wanted for the Genesis locomotive, where applying the train brakes reverts the cruise control to manual mode. But I feel like there are quite a few systems out there where you should be able to apply the train brakes without cruise control suddenly setting the dynamic brake to 0.
#190
Posted 11 May 2023 - 10:51 PM
#191
Posted 12 May 2023 - 06:31 AM
#192
Posted 13 May 2023 - 04:11 PM
Anyway, I used this to have go at simulating an energy management system for freight trains, like GE's trip optimizer or EMD's LEADER. These aren't strictly cruise control systems, as the speed is decided automatically, but they have the interesting quirk of only using throttle and dynamic brakes, requiring the operator to manually add in train braking at certain points (however, it knows when it will need train brakes and will inform the operator of this-I think in the future even the automatic brake part will become automated). With this fix, it is possible to set a speed, let the system use dynamic brakes, then add a minimum reduction when dynamic brakes aren't enough and the system will then balance speed using the dynamics. It's quite effective and interesting to watch, I'm tempted to record a video to demonstrate considering it flawlessly took a bulky 145 TOB train down a 2% grade with a minimum set. Now I just want to check how it interacts with distributed power. If anyone would like to experiment with this, here's the list of parameters I settled on:
ORTSCruiseControl ( MaxForceSteps ( 8 ) Comment ( Throttle controls cruise control force, and the throttle has 8 notches. ) SpeedIsMPH ( True ) MinimumSpeedForCCEffect ( 10mph ) Comment ( System does not work unless train is already moving. ) NominalSpeedStep ( 1 ) SpeedSelectorStepTimeSeconds ( 0.1 ) UseThrottleAsForceSelector ( True ) Comment ( The throttle sets the maximum power the cruise control will use. ) UseThrottleInCombinedControl ( True ) Comment ( Required for locomotives which have a combined throttle and dynamic brake. ) ModeSwitchAllowedWithThrottleNotAtZero ( True ) Comment ( This system allows throttle to be applied while changing mdoes. ) StartReducingSpeedDelta ( 0.01 ) Comment ( Set very low to make acceleration more conservative. Should avoid overshoots. ) StartReducingSpeedDeltaDownwards ( 0.05 ) Options ( "RegulatorManual, RegulatorAuto, EngageForceOnNonZeroSpeed" ) ThrottleFullRangeIncreaseTimeSeconds ( 30 ) ThrottleFullRangeDecreaseTimeSeconds ( 30 ) DynamicBrakeFullRangeIncreaseTimeSeconds ( 30 ) DynamicBrakeFullRangeDecreaseTimeSeconds ( 30 ) TrainBrakeCommandHasPriorityOverCruiseControl ( False ) Comment ( Applying the train brake manually won't disable cruise control. ) DynamicBrakeCommandHasPriorityOverCruiseControl ( False ) Comment ( Applying dynamic brake manually won't interfere with automatic braking. ) KeepSelectedSpeedWhenManualModeSet ( True ) Comment ( Set speed is 'remembered' even when cruise has been turned off. ) DoComputeNumberOfAxles ( True ) Comment ( No manual entering of axle information. ) )
I noticed one thing it will not do is stretch brake (apply forward traction while the train brakes are applied). I would assume most cruise control systems do not try to stretch brake, but there's probably a system out there that does.
Also, the "SkipThrottleDisplay" is something I didn't see on the Genesis that manifested itself when I moved over to a locomotive with split throttle/dynamic brake. It seems unintentional that the throttle display wasn't skipped when a combined throttle/dynamic brake was used. Also this is yet another thing I'd like to control, as the throttle display should not be skipped on the systems I'm making because the throttle is used as the force selector.
#193
Posted 24 May 2023 - 01:15 AM
your suggested fix for TrainBrakeCommandHasPriorityOverCruiseControl is present also in ORNYMG 142.1. I have now created a quick patch for the same release, that allows to disable the use of the dynamic brake for the CC, as you asked for the Genesis.
Attached you have the patch, to be uncompressed in ORNYMG 142.1.
To disable the use of the dyn brake, you have to add following line to the CruiseControl() block in the .eng file
UseDynBrake ( False )
Default for such new parameter is True.
A feedback from your side about the effectiveness of the patch is welcome.

Number of downloads: 273
#194
Posted 24 May 2023 - 04:15 AM
#195
Posted 24 May 2023 - 06:15 AM
I'll have a look at the dynamic brake patch when I'm back home, if there's a way to break it I'll probably find it, but I can't imagine it's that risky.