-
Notifications
You must be signed in to change notification settings - Fork 6
Cruise control #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cruise control #12
Conversation
Initial release of Cruise Control
| { | ||
| //Simulator.Confirmer.Information(Locomotive.Train.AccelerationMpSpS.SmoothedValue.ToString()); | ||
| // | ||
| if (SpeedRegMode == SpeedRegulatorMode.AVV) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer if this block was moved to a TCS script, keeping in this class a more generic Automatic Train Operation (ATO) system.
I suggest the TCS-ATO interface to be like this:
void SetATOTargetParameters(float targetSpeedMpS, float targetDistanceM)I think the targetDistanceM is necessary to accurately stop a train in a platform when required, but I might be wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be there, it was only a testing part. Will remove it. We can work on ATO later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
| controllerTime = inf.ReadSingle(); | ||
| CurrentSelectedSpeedMpS = inf.ReadSingle(); | ||
| currentThrottlePercent = inf.ReadSingle(); | ||
| float deltaCoefficient = inf.ReadSingle(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose for saving this parameters but then discard them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually the only things that should be saved are those that change during the simulation (i.e. selected cruise speed, cruise speed operation mode, etc.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in new PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to create more PRs. When you push the changes to your upstream repository, this PR is automatically updated.
…and MultiPositionControl initial commit; by Jindrich
| WaterScoopWidthM = locoCopy.WaterScoopWidthM; | ||
| MoveParamsToAxle(); | ||
| if (locoCopy.CruiseControl != null) | ||
| CruiseControl = locoCopy.CruiseControl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you have to perform a deep clone of the CruiseControl class, not just copying the reference. The Copy() method is called when there are several instances of the same engine in the consist, to avoid parsing the STF file more than once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do Copy() method for the CruisControll class. What variables should the copy method include?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Copy() method is a substitution for Parse(STFReader stf), so you should set the same variables as in the CruiseControl.Parse() method. For example, UseThrottleAsSpeedSelector, MaxAccelerationMpSS, etc.
| public TrainType SelectedTrainType = TrainType.Pax; | ||
| public void ChangeTrainTypePaxCargo() | ||
| { | ||
| SelectedTrainType = SelectedTrainType == TrainType.Pax ? SelectedTrainType = TrainType.Cargo : TrainType.Pax; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you provide more information about this selector? Is it only used for cruise control (in real trains), or should it change also braking related parameters? I was planning to add something similar for brake operation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may write large story about brakes. Because the brakes are still simulated same as back when we only have MSTS. Not a very large, challenging or breathtaking information. But this needs complete review (I mean the brakes) or small steps for us, until we are on the Moon, (or Mars nowadays).
The TrainType cargo : pax is now used for cruisecontrol only to select different time in reduced force, before the whole train is in tension on all couplers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, let's keep the button for cruise control only then.
| break; | ||
| } | ||
| bool metric = cvc.Units == CABViewControlUnits.KM_PER_HOUR; | ||
| float temp = CruiseControl.RestrictedSpeedActive ? MpS.FromMpS(CruiseControl.CurrentSelectedSpeedMpS, metric) : temp = MpS.FromMpS(CruiseControl.SelectedSpeedMpS, metric); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| float temp = CruiseControl.RestrictedSpeedActive ? MpS.FromMpS(CruiseControl.CurrentSelectedSpeedMpS, metric) : temp = MpS.FromMpS(CruiseControl.SelectedSpeedMpS, metric); | |
| float temp = CruiseControl.RestrictedSpeedActive ? MpS.FromMpS(CruiseControl.CurrentSelectedSpeedMpS, metric) : MpS.FromMpS(CruiseControl.SelectedSpeedMpS, metric); | |
Just a little style change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was very tired to write this :D
| if (mstsSignalType.Semaphore) | ||
| glowDay = 0.0f; | ||
| /* Jindrich | ||
| * Why is this here? I want all my lights glowing, when I have glowing on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I see, you have created a different PR for this. To avoid merge issues, you should remove this line from this PR.
Probably this block should be kept for backwards compatibility anyway. I think you can manually force SHUNTING and INFO signals to glow using the sigcfg.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR was cancelled.
|
Just to let you know how I am proceeding, I get Jindrich's updates from this PR or from PR #13 (I see that Jindrich updates both PRs in parallel) and apply them to my cruise-control branch (which is the base of PR #13), which I push to my remote repository request. I have too removed the signal glow changes. |
|
I believe the merge conflicts are caused because of the two PRs. Both are referencing the same remote branch (jima72:CruiseControl) but they compare against different branches in your repo. You can see that commits in both PRs have the same hash. As you are using 'git apply' instead of 'git merge' to apply Jindrich's changes, the commit information is lost and git is unable to know that your diff and Jindrich changes are the same. If you wish to modify the PR locally, without loosing commit information, you can follow this instructions: https://docs.github.com/en/github-ae@latest/github/collaborating-with-issues-and-pull-requests/checking-out-pull-requests-locally#modifying-an-active-pull-request-locally |
|
Thanks César, I resolved the conflicts with your hint. I hope I did things OK. |
| if (!IsPlayerTrain || CruiseControl.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Manual || CruiseControl.UseThrottle) | ||
| UpdateMotiveForce(elapsedClockSeconds, t, AbsSpeedMpS, AbsWheelSpeedMpS); | ||
| else if (IsPlayerTrain || CruiseControl.SpeedRegulatorOptions.Contains("engageforceonnonzerospeed")) | ||
| CruiseControl.Update(elapsedClockSeconds, AbsWheelSpeedMpS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please have a look at this lines:
If train is not a player train, the first clause will be executed, which I believe it's OK
However, if train is player train, the 'else if' condition is unnecessary, so it could be replaced with an 'else'. Did you mean something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
|
|
||
| public void StartThrottleIncrease() | ||
| { | ||
| if (CruiseControl != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better if you moved this to the end of StartThrottleIncrease() method, so the combined controls can be used normally, and the cruise control code only swallows the command when the combined control is in throttle positions.
The same applies for all Start/Stop Throttle Increase/Decrease methods
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, some locos uses the throttle handle as CruiseControl mode selector (i. e. neutral (no force), drive (force until speed reached), confirmation for drive (need to be held until given speed) when in automatic mode. Then the lever in fact is not controlling the throttle anymore, and the logic for brakes and force is completely driven by cruise control. So in that case is necessary only the cruise control to be executed and the rest is skipped completely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does the throttle handle behave when the cruise control is disconnected? If it is just a single throttle lever (without combining brakes), then the changes that I suggest aren't affected. Could you please provide more accurate description of the throttle lever on these locos?
I have in mind some locomotives with a combined control lever, where the throttle acts as a speed selector, but when the lever is moved to a braking position, the brakes are applied and the cruise control is disconnected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imagine you have a switch, with positions M and A. It the switch is in M position, the lever (plus/neutral/minus) works as a throttle - cruise control disconnected. If it's set to A, then the cruise control is active, but the train will not move, until you momentarily set the throttle lever to plus. The cc will then set the throttle virtually to 100%, and the force is maintained internally by overriding the UpdateMotiveForce. So the throttle is set to 100%, but the force to the loco is internally computed by cc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe wait, until I upload the new MultiPositionController class, with wich you can stack up any controller with predefined steps. These are also bound to cruise control if that iv available. The variety of controls aroud the globe is large, so I decided to do it this way, because the normal throttle lever or combined lever were not sufficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a sample of such a controller:
ORTSMultiPositionController (
Positions (
Position ( ThrottleIncrease SpringLoadedBackwardsImmediatelly "Souhlas" )
Position ( Drive CruiseControl.NeedIncreaseAfterAnyBrake "Jízda" )
Position ( Neutral Default "Výběh" )
Position ( DynamicBrakeIncrease SpringLoadedForwards "EDB" )
Position ( TrainBrakeIncrease SpringLoadedForwards "Brzda" )
Position ( EmergencyBrake Null "Rychlobrzda" )
)
)
Initial commit, will definitelly need fixes.