News:

Congratulations!
 You've won the News Item Lottery! Your prize? Reading this news item! :)

bidirectional and can_lead_from_rear

Started by Vladki, September 22, 2016, 08:45:04 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Vladki

Hello,

I'm trying to put at least some experimental features to pak128.CS. I have a few questions about reversing trains.

1. Why the default is bidirectional=0. I think that most rail vehicles are bidirectional, except for non-tank steam engines (with tank and coal on a trailer), and front and back units of some EMU/DMU/pendolinos, etc.

2. how exactly works can_lead_from_rear ? I have an example - https://en.wikipedia.org/wiki/%C4%8CD_Class_810 
This is a sort of "railbus" which is by itself bidirectional. (reversing time in simuitrans-ex cca 1 minute). It can haul a few trailers, which look almost the same, just they are unpowered and have no drivers cab. So there is a need for shunting at terminus. (reversing 2 minutes). However if a longer train was formed (>3 vehicles), a second powered unit would be put at the end, and no shunting would be needed. So reversing should be 1 minute, but it is 2 minutes, just as if there would be only one engine. If I give it can_lead_from_rear, then all combinations rverse in 1 minute, and the convoy with only one engine and some trailers goes in reverse - engine pushes the trailers, but they have no drivers cab.


Ves

It is currently not possible to do that. You need to create a duplicate of the engine with a different name and with the string "can_lead_from_rear=1" in that one, as I have done with my Rc-locos: [urk]https://github.com/VictorErik/Pak128.Sweden-Ex/blob/half-height/Vehicles/Rail%20Vehicles/Locomotives/Rc.dat[/url]
There is a duplicate of each engine at the bottom of the dat with the "_SMS" in the name (nickname in SJ for this type of consist building, the locos texting SMS to each other).

I made a thread about some time ago with a suggestion to a fix to get around the resulting issue of duplicate locos in the depot here:
http://forum.simutrans.com/index.php?topic=11978.msg118208#msg118208

Junna

Quote from: Ves on September 22, 2016, 09:49:45 PM
(nickname in SJ for this type of consist building, the locos texting SMS to each other).

I'm pretty sure SMS is for serial multiple unit control? (Seriell multipelstyrning). Using this requires wiring through the intermediate carriages, which is what differs it from conventional multiple control (conventional double- and triple heading, etc).

Ves

Yeah that's probably more correct that that is what the SMS stands for. I just heard the other story and found it amusing!

jamespetts

My apologies for not having spotted this sooner: I do not get e-mails when people post in this forum.

The reason that bidirectional = 0 is the default is because this is the closest to how things work in Standard: the idea was to maintain backwards compatibility with older paksets.

can_lead_from_rear works as follows: if the rearmost vehicle of a train has this flag set, the train will not turn around, but will just run backwards, and will use the faster turnaround time.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Ves

Quotecan_lead_from_rear works as follows: if the rearmost vehicle of a train has this flag set, the train will not turn around, but will just run backwards, and will use the faster turnaround time.

I think that the thing that is desired from both Vladki and also myself, is the ability to have a bidirectional loco at each end of a train.

I have made an example track at the swedish server to illustrate what is happening.
The track is located between the towns of Dingtuna and Träslövsläge (approximate coordinates: 222,229) and there are four different trains running. They have a naming convention as follows:

NORMAL = is a normal locomotive, without "can_lead_from_rear=1" defined
CLFR=1 = is a locomotive with "can_lead_from_rear=1" defined
cars = are normal cars


So a train with two normal locos at each end will be named NORMAL - cars - NORMAL

The four trains running on the track are these:

"NORMAL - cars - NORMAL"
"CLFR=1 - cars - CLFR=1"
"CLFR=1 - cars"
"NORMAL - cars - CLFR=1"


The first train, "NORMAL - cars - NORMAL", will rearrange the locos at the terminus, so the order becomes: "LOCO - car - LOCO - rest of the cars".

The solution to that is to define "can_lead_from_rear=1" in the loco, and that actually works, as demonstrated by the second train, "CLFR=1 - cars - CLFR=1".

However, that will then not work when you want to use the loco alone. After a few runs, the loco will stay at its position in the train, PUSHING the cars in front of it, as demonstrated by te third train, "CLFR=1 - cars".

The ultimate bulletproof solution to the issue is then to create a duplicate of the loco and put "can_lead_from_rear=1" at the second loco. As proven by the fourth train, "NORMAL - cars - CLFR=1", that will work in every occasion, however, it has that major drawback of needing a duplicate of every loco you want to be able to do this with. Also it will clutter down the depot window.


So the ultimate whish would be that there where some intelligence in some way, either that a loco with "can_lead_from_rear=1" that runs alone would not try to push the cars upon reversing, alternative that a loco would be assigned a "virtual" can lead from rear flag when bidirectional and set at the end of a consist.
If none of those are not possible, the "secondmost" ultimate whish I guess would be whats proposed in this thread: http://forum.simutrans.com/index.php?topic=11978.msg118208#msg118208

Am I making any sence? :)

jamespetts

This has made things rather clearer; I was not aware that this was an issue before. I have pushed a fix to the code; would you be able to test this?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Ves

Thank you very much James! That fixed the issue of beeing able to use a locomotive with can_lead_from_rear=1 as a single locomotive, as well as having a loco at each end.

However, it appears that this has broken the case when you use a train with "NORMAL - cars - CLFR=1". It will now rearrange the convoy to "LOCO - car - LOCO - rest of the cars".

jamespetts

Briefly looking at this on the relevant saved game, it appears as though the vehicle with "can_lead_from_rear=1" is actually at the front and the one without is actually at the rear: the "can_lead_from_rear=1" only works when the vehicle that has this is in rear when the convoy is in a non-reversed formation (i.e., as it is straight out of the depot).
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Ves

Yes I know that it should be setup like that. However, I have altered the setup on the server for you to test:

* Save a savegame of the server at its current state and open up the save in the newest build.
* Open the depot, and there you should find a convoy called "NORMAL - cars - CLFR=1(car)". As the name suggest, the last vehicle in the convoy is a cab-car.
* Press start and follow the convoy for some rounds.
* Eventually, the cab-car will become the leading car in both directions.

Vladki

After upgrading the pak sweden, some trains on the server game lost their engines... Perhaps due to removing the SMS versions without adding them to compat.tab :(

Ves

Stupid me! I was thinking when I did the changes "I will remember to update the compat.tab this time", did make the changes in the file, but forgot to add it to github  :o
Updated now, thank you!

Vladki


Ves


Vladki

Do you happen to have some older savegame with those lost engines? The server already corrupted the save and replacing compat.tab did not help.


Vladki

Server restarted with this save, all trains seem to have engines, just some of them are weirdly arranged (e.g. engine in the middle)

Ves

This appears to be the bug I mentioned before. James, take a look at the swedish server, especially the emu's. They have coded in their datfile the primary car without and the rear car with can_lead_from_rear=1. This results in that when the trains are in the nonreversal direction, the leading car shifts position, rearranging the cars of the emu.

Also, this thread appears to become more like a bugreport than pakset specific, maybe move it to the development board?

jamespetts

I think that I have fixed this now; would you be able to re-test?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Ves

It appears to have reverted to the original behavior: A locomotive with can_lead_from_rear=1 will start pushing the cars again. However, the case with a loco (without CLFR=1) and the last car/loco with CLFR=1 works again.

jamespetts

I found some errors in the original fix, and have fixed the fix. Can you test whether the fixed fix has fixed the issue?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Ves

It immediatedly appears to work as intended now! Great work! :)
Only, trains from older savegames with the bug appears to remain in their wrong orders and do strange stuff, however a trip to the depot to straighten them out makes the wonder.

jamespetts

Yes, I am afraid that that is inevitable, as they will not be saved with the correct data from older versions. Thank you very much for re-testing, however.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Vladki

#23
I have tried to add bidirectional and CLFR to some railbuses and their trailers in pak128.CS and found one problem. Illustrated in http://server.exp.simutrans.com/debug-saves/trnava.sve and pakset: http://server.exp.simutrans.com/pak128.CS-exp.zip

I have 4 trains in that game. All vehicles are bidirectional. Railbus is powered some CLFR=1 some =0 see train names, trailer is unpowered and always CLFR=0

CSD_M152 - is in config railbus_red/trailer_red/trailer_blue/railbus_blue. Both railbuses have CLFR=1, and it works as expected - reversing in short time, keeping the order of vehicles

Viamont 810 - railbus_yellow, and 3 trailers of different colors, railbus is CLFR=1, also works OK, reversal is longer, railbus goes to the other end, trailers keep their original position.

ZSSK 811 - railbus_red and 2 trailers (one with mail, one without). CLFR=0, reversal OK, order of vehicles is kept.

And here comes the problem: ZSR_811: railbus_orange, trailer_orange, trailer_red, railbus_red, CLFR=0. When reversing it moves the orange trailer to the other end, plus it takes the orange trailer with it as well. So the reversed order is railbus_orange, trailer_orange, railbus_red, trailer_red.
I would expect only the railbus should go to the other end, thus making this formation: railbus_orange, railbus_red, trailer_red, trailer_orange.

Is there any reason, while train with CLFR=0 behaves different when there is a powered vehicle at the end or not? Similar behavior can be seen on swedish servergame at traslovslage station - train named "normal - cars - normal"


BTW, the save game has probably some problem. If you quit simutrans and start again, it hangs at loading the temp-load.sve. Seems to be in some infinite loop with sleep (not using CPU), but hes to be killed forcefully. (kill -9). After that it starts with the mini default game, and lets you load my save without hassle. I tried with pak.sweden and it does the same thing, so it is not pakset or savegame specific. I shall report this as separate thread.

Rollmaterial

Does trailer_orange have bidirectional=1?

Vladki

Quote from: Rollmaterial on November 13, 2016, 09:02:49 PM
Does trailer_orange have bidirectional=1?
Yes, it is not specific to this trailer. I have tried with others (well they are mostly just different liveries, but as the pakset is not yet for experimental, they are coded as separate vehicles, not using the liveries feature of experimental)

jamespetts

I have not had a chance to test this, but I suspect that this behaviour is caused by the special code for detecting a steam locomotive with a tender. I have modified the code so that this now only works if both the locomotive and tender are explicitly encoded as having the steam engine type; otherwise, it should now behave as expected.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Vladki

Quote from: jamespetts on November 13, 2016, 09:41:53 PM
I have not had a chance to test this, but I suspect that this behaviour is caused by the special code for detecting a steam locomotive with a tender. I have modified the code so that this now only works if both the locomotive and tender are explicitly encoded as having the steam engine type; otherwise, it should now behave as expected.
I suppose that engines with tender, should be identified by constraints (next/prev) rather than by steam. There are tank steam engines, that are tender-less, and on the other hand there are articulated diesel or electric engines that behave similar to steam+tender in this regard.

Moreover - steam+tender are usually not bidirectional, while articulated diesel/electric are bidirectional.


The railbuses and trailers in my examples have no constraints.

jamespetts

They are identified by constraints as well - can you check whether the behaviour that you describe has changed? If not, I will need to look into this in more detail.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.


Ves

QuoteI have not had a chance to test this, but I suspect that this behaviour is caused by the special code for detecting a steam locomotive with a tender. I have modified the code so that this now only works if both the locomotive and tender are explicitly encoded as having the steam engine type; otherwise, it should now behave as expected.
Bear in mind that there are some locomotives which are not steam but are also permanently coupled together. In Pak.sweden there is the Dm3, which is three engines coupled together, with a cab at each end. Currently, the cabs points "inwards" when the train is reversing. It is like the constraintNEXT becomes constraintPREV and vice versa when the train is reversing. There is a Dm3 on the swedish server (im about to clean it up, however, the server just crashed...) showing the behavior. Mind, that alot of trains are in strange order, but this is because I havent had time to clean it up yet (and the server just crashed, so it will be like that for a second)..

edit Just like Vladki was saying :)

Edit2 Incidentally, nice selection of signals you made Vladki! Looking really good :thumbsup:

Vladki

Perhaps making bidirectional powered vehicles to be automatically CLFR=1, would make sense.
And also if they are constrained like DM3 or similar, to keep them together and put the whole unit on the other end of the train.
In the czech pak you can find some railbuses and trailers that have a "mail hold". Those also behave funny when reversing.

Ves

Quote from: Vladki on November 13, 2016, 10:34:10 PM
Perhaps making bidirectional powered vehicles to be automatically CLFR=1, would make sense.
And also if they are constrained like DM3 or similar, to keep them together and put the whole unit on the other end of the train.
In the czech pak you can find some railbuses and trailers that have a "mail hold". Those also behave funny when reversing.
I dont think it would necessary make sence to have any bidirectional powered vehicle to automitacally have CLFR=1 as a powered bidirectional vehicle not principally do have a cab at each end, look at american trains like this one: http://www.katousa.com/N/SS-F7/.
Upon reversal of a train, I think that the train should find the rearmost vehicle with CLFR=1 in the train and split it from there, threating the whole section between the front vehicle and the latest CLFR=1 as if it was a single loco doing a roundabout. Hopefully in such a case there is no need for any vehicle to turn around, as nondirectional vehicles usually tends to be steam engines and engines like the american linked above. However, for the failproofing, IF there are such a vehicle in the train, some logic must be applied:

If the player uses a steam engine (or other nonbidirectional vehicle) as the leading vehicle and wrongly uses a vehicle with CLFR=1 in the consist, the CLFR=1 from any vehicle should be ignored. The engine should do the roundabaout and turn around as normal, taking any constrained cars with it in the action.

If there is a vehicle in the middle of a train, I can see several scenarios:
If the nonbi vehicle is constrained together with the leading vehicle (which is bidirectional), the section which is constrained together should do the roundabout, turn around, and remain their position in respect to constraint next/prev as described above.

If the nonbi vehicle is not constrained with the leading vehicle, it should just turn around, forcing any constrained vehicles to turn too.

But even with these rules, I don't think the constraints can be too complicated from a pakset creation pow.

Vladki

Perhaps a little change in the logic of bidirectional and CLFR would be useful:

bidirectional = 0 would be only those vehicles, that cannot run in reverse at full speed: i.e. steam engines with tender
bidirectional = 1 would be all that can run in both directions at full speed even if they have only one cab, i.e almost everything.
CLFR=0 would be set on vehicles that do NOT have a cab in rear: F7, front part of Dm3, front unit of pendolino/TGV and similar units.
CLFR=1 would be set on vehicles that have a cab in rear: i.e. driving trailers, rear unit of pendolino/TGV, rear part of Dm3, reversed F7 (I suppose that they can be run back to back), and all modern diesel and electric engines that have cab on each end, or have a cab in the middle (shunters like this https://cs.wikipedia.org/wiki/Lokomotiva_210). Steam tank engines fall in this category too.

Reversing will be done like Ves suggested:
If all cars are bidirectional, and there is a CLFR=1 at the end - just reverse
If all cars are bidirectional, and there is a CLFR=1 not at the end (perhaps even the first vehicle) - take the part from front to CLFR=1 and move it to the end of train.
unidirectional vehicles should disable any CLFR=1 in train, and should turn around and take the same relative position in the train. (Example: 2 steam engines with tender in front, and one more in rear.


I would also propose that similarly to using ConstrantNext[0]=any on many wagons to force a brake (guard) van at the end of train, one could also use ConstranitPrev[0]=any to force an engine (or car) with cab on the head of the train.

Ves: the signals in pak128.CS were originally painted by Lubak91. I did the dat files, positioning, light combinations, etc.


Vladki

I have prepared a savegame using pak128.CS (and a few addons). Notable trains are:
- Train (18) lead by class 556 Stokr: this is usual steam engine with tender. Bidirectional=0 (both engine and tender), constraint[next/prev] between engine and tender. Turnaround time 6 minutes, reversal is OK. One of the cars (csd_aba) has two parts overlapping. It behaves a bit funny when reversed (see when it takes corners), but that is a minor problem
- Train (19) lead by class TL 659 Turbinka: this is an experimental turbine loco, which due to high fuel consumption needed an extra tank waggon attached. So it is constrained in same way as steam tender engine 556, but is bidirectional (both engine and tender), turnaround 2 minutes, reversal OK. Although this engine does not need turning on turntable, it needs more complicated shunting, so a longer turnaround time might be reasonable. But this was just a prototype, and is not expected to be used too much so there's no need to make special exemption just for this one. (and may be fixed by setting it non bidirectional). However when I used this engine with British mk2 coaches, where rear and front brake cars are defined, it did some funny rearrangements of the train, like class 698 below.
- Train (20) lead by class T 698 Kokakola: This engine consists of two parts. If set as non-bidirectional, the engine reverses nicely (although it takes long time), but also it takes the first waggon (csd_wlab blue) to the front of the train. If set as bidirectional, it reverses quickly, but the unit is spit and recombined with cabs facing each other. And the problem with front wagon remains.
- Train (8) railbus class CD_811. The engine and trailers have normal hook & screw coupling, but are constrained with similar vehicles due to remote control of doors and rear engine. The front 811-1 and rear 811-2 engine are in real world identical, but I had to code the rear one as can_lead_from_rear=1, to get the desired behavior. (no rearranging, 1 minute turnaround). Again the middle cars are pax+mail combo which looks funny when reversed)
- Train (11) railbus class ZD_810. front engine coded as can lead from rear. Turnaround OK (2 minutes, as it has to shunt). Train arrangement OK. I think there used to be problem with such combination, but now it is OK. Thus the train 8 could be recoded to have CLFR on both ends - as does e.g train 13 and 14.
- Train (10) regionova trio 814, this is a fixed DMU of three cars, but is capable of pulling normal trailers. It is bidirectional, with the last unit CLFR=1. If running alone, it works fine, but with a trailer it gets rearranged with cabs inside. This should behave the same way as swedish Dm3 (three-part electric loco for heavy freight).

pakset: http://list.extended.simutrans.org/pak128.CS-Ex.zip
addons: http://list.extended.simutrans.org/csd_y_extended.pak
save: http://list.extended.simutrans.org/debug-saves/twin-engine.sve

So, only trains 20 (kokakola) and 10 (regionova) need a fix
Do not rotate the map - it will segfault. :-(