[Solved] Train-dependent level crossing

View previous topic View next topic Go down

[Solved] Train-dependent level crossing

Post by Dexter on Sun Oct 09, 2011 2:36 pm

Hi folks,

I have played with the formulas from Graham and after a few modifications, I can finally say it is working as i wanted. Watch the below video and comment, please. Cool Note: the animations are running smoothly in real life, the recording software is quite demanding and therefore it appears choppy in some part of the vid.

This video shows conditional use of animations on the level crossing - based upon train approach. Timing of the animations is subject to adjustments, this is only a demonstrative video.:-)





Last edited by Derryck on Sun Oct 09, 2011 8:18 pm; edited 1 time in total
avatar
Dexter

Posts : 1842
Join date : 2011-07-08
Age : 31
Location : Brno, Czech republic

http://www.brnobve.eu

Back to top Go down

Re: [Solved] Train-dependent level crossing

Post by joeyfjj on Sun Oct 09, 2011 2:53 pm

Looks ok to me

joeyfjj

Posts : 265
Join date : 2011-07-30
Location : Singapore

http://joeyfoo.com

Back to top Go down

Re: [Solved] Train-dependent level crossing

Post by velaro on Sun Oct 09, 2011 3:21 pm

I get an error message: this video contains music from UMG ... Laughing
avatar
velaro

Posts : 23
Join date : 2011-08-02
Age : 41
Location : Reutlingen, Germany

Back to top Go down

Re: [Solved] Train-dependent level crossing

Post by graymac on Sun Oct 09, 2011 3:38 pm

Looks good! So now there is the flexibility of being able to set two distance values, one to drop the barriers well before the train arrives , and a shorter one after the train has passed, which lifts the barriers again for the road traffic. Well done Derryck.
avatar
graymac

Posts : 1744
Join date : 2011-08-28
Location : Co Mayo, Eire

http://www.celtictrainsim.com

Back to top Go down

Re: [Solved] Train-dependent level crossing

Post by Dexter on Sun Oct 09, 2011 4:27 pm

velaro wrote:I get an error message: this video contains music from UMG ... Laughing

Ah yes, German resident, right? I just got a lovely email from youtube that my video won't be available in Germany due to music copyright. I will upload the vid here, no worries. Smile
avatar
Dexter

Posts : 1842
Join date : 2011-07-08
Age : 31
Location : Brno, Czech republic

http://www.brnobve.eu

Back to top Go down

Re: [Solved] Train-dependent level crossing

Post by lonelyinardwick on Sun Oct 09, 2011 4:34 pm

What's up with German residents that YouTube won't allow? :S

lonelyinardwick

Posts : 375
Join date : 2011-07-24

https://about.me/lonelyinardwick

Back to top Go down

Re: [Solved] Train-dependent level crossing

Post by Dexter on Sun Oct 09, 2011 5:03 pm

It's not an YouTube issue, it has to do with Universal Music Group. Iam uploading the video on my website - I shall put a link here shortly.
avatar
Dexter

Posts : 1842
Join date : 2011-07-08
Age : 31
Location : Brno, Czech republic

http://www.brnobve.eu

Back to top Go down

Re: [Solved] Train-dependent level crossing

Post by graymac on Sun Oct 09, 2011 5:04 pm

Government legislation Jeffrey! Crying or Very sad
avatar
graymac

Posts : 1744
Join date : 2011-08-28
Location : Co Mayo, Eire

http://www.celtictrainsim.com

Back to top Go down

Re: [Solved] Train-dependent level crossing

Post by Dexter on Sun Oct 09, 2011 5:35 pm

Alternative link to the video is provided HERE
avatar
Dexter

Posts : 1842
Join date : 2011-07-08
Age : 31
Location : Brno, Czech republic

http://www.brnobve.eu

Back to top Go down

Re: [Solved] Train-dependent level crossing

Post by joeyfjj on Sun Oct 09, 2011 5:45 pm

Actually, truth be told I rather have a silent video than one with music I don't appreciate. Smile

joeyfjj

Posts : 265
Join date : 2011-07-30
Location : Singapore

http://joeyfoo.com

Back to top Go down

Re: [Solved] Train-dependent level crossing

Post by Dexter on Sun Oct 09, 2011 5:50 pm

Joey, is there something you don't like about that music? Laughing By the way, it is a matter of a second to click the speaker button. Back to the topic please, any suggestions? Smile
avatar
Dexter

Posts : 1842
Join date : 2011-07-08
Age : 31
Location : Brno, Czech republic

http://www.brnobve.eu

Back to top Go down

Re: [Solved] Train-dependent level crossing

Post by Dexter on Mon Oct 17, 2011 7:51 pm

OK, I promised to make the formula public, so here it is + I will also try to explain. Very Happy

First goes the gate:

states = [whatever_your_object_name_is]
RotateXFunction = if[trackDistance <=400 & trackdistance[-1]>(-25), 0, (abs[trackdistance] > 50) * (-1.5)]
RotateXDamping = 1, 1.1

Explanation:
  • IF -> a conditional, expresses that something will happen in case the set criteria (conditions) are met, the formula inside has to be surrounded by brackets [] and consists of condition, what to do if condition is met and what to do if not


  • trackDistance <= 400 -> sets the first condition, in this case the nominal distance of the train from the object is less or equal to 400 metres

  • & -> logical operator, which stands for "AND". In this case it means more criteria need to be fulfilled within the same time period before the action will be taken

  • trackdistance[-1]>(-25) -> the second condition, which needs to be fulfilled together with the first one in order for the action to take place. In our case the distance (in meters) of the geometrical centre of coupler indexed with "-1" (which is a default value of the very last wagon regardless on their total amount) has to be higher than -25, which means the condition is broken after the last wagon passes the crossing (because -25 is in fact 25 meters BEHIND the crossing) and the gate goes up.

  • 0 -> Means when the conditions ARE fulfilled, the rotation will be ZERO radians (this in fact requires the gate to be defined in the "states.csv" file as closed, otherwise the displayed result will be incorrect)

  • (abs[trackdistance] > 50) * (-1.5) -> defines that the rotation will be performed when at least one of the criteria is NOT fulfilled. The formula will open the gate to an approximate angle of 87 angular degrees.

  • RotateXDamping = 1, 1.1 -> Tells us the rotation will be performed gradually, not as a jump from an unrotated state to the other one


And the blinking lights, this is something I particularly like:

states = CrossingLightL.csv, CrossingLightR.csv, Null.csv
StateFunction = if[trackDistance<=600 & trackdistance[-1]>(-25), mod[value + 1, 2], 2]
RefreshRate = 0.5

Explanation:
  • states = CrossingLightL.csv, CrossingLightR.csv, Null.csv -> Defines the list of states of the light. In the first one, the left is turned on, in the second, the right one is turned on and the third object is just an invisible fake.

  • IF -> a conditional, expresses that something will happen in case the set criteria (conditions) are met, the formula inside has to be surrounded by brackets [] and consists of condition, what to do if condition is met and what to do if not

  • trackDistance <= 600 -> sets the first condition, in this case the nominal distance of the train from the object is less or equal to 600 metres

  • & -> logical operator, which stands for "AND". In this case it means more criteria need to be fulfilled within the same time period before the action will be taken

  • trackdistance[-1]>(-25) -> the second condition, which needs to be fulfilled together with the first one in order for the action to take place. In our case the distance (in meters) of the geometrical centre of coupler indexed with "-1" (which is a default value of the very last wagon regardless on their total amount) has to be higher than -25, which means the condition is broken after the last wagon passes the crossing (because -25 is in fact 25 meters BEHIND the crossing) and the lights should stop blinking.

  • mod[value + 1, 2] -> determines the state to be used by dividing VALUE+1 (the starting content of this variable is 0) by TWO. With each cycle (will be explained when I get to REFRESH) 1 is added to the VALUE and therefore, the remainder (basically this is what MOD function is all about) of VALUE being divided by two is either 0, or 1. Here comes the state change, either state 0, or 1 is used and flashes over the static crossing object

  • 2 -> when the conditions are NOT fulfilled, the state 2 is used. Therefore, we only see the switched off lights defined within the static crossing object. Smile

  • RefreshRate = 0.5 -> Represents the time interval for the state change in seconds. In other words this means that the cycle repeats every second. Smile


ANY QUESTION, GRAY? Very Happy



Last edited by Derryck on Mon Oct 17, 2011 10:14 pm; edited 3 times in total
avatar
Dexter

Posts : 1842
Join date : 2011-07-08
Age : 31
Location : Brno, Czech republic

http://www.brnobve.eu

Back to top Go down

Re: [Solved] Train-dependent level crossing

Post by graymac on Mon Oct 17, 2011 8:34 pm

Thanks for that Derryck. I shall enjoy experimenting with the distances. It looks as if it could also be adapted to operate a .freeobj semaphore distant signal to work with a crossing. Should be very useful.
avatar
graymac

Posts : 1744
Join date : 2011-08-28
Location : Co Mayo, Eire

http://www.celtictrainsim.com

Back to top Go down

Re: [Solved] Train-dependent level crossing

Post by Dexter on Mon Oct 17, 2011 8:41 pm

graymac wrote:Thanks for that Derryck. I shall enjoy experimenting with the distances. It looks as if it could also be adapted to operate a .freeobj semaphore distant signal to work with a crossing. Should be very useful.

Yes, it is constructed to be universal. For the semaphore, I would rather use the second part. I like the way I am avoiding the state indexed as "2" when I need the lights to be switched off. Very Happy
avatar
Dexter

Posts : 1842
Join date : 2011-07-08
Age : 31
Location : Brno, Czech republic

http://www.brnobve.eu

Back to top Go down

Re: [Solved] Train-dependent level crossing

Post by graymac on Mon Oct 17, 2011 10:50 pm

In the expression:
RotateXFunction = if[trackDistance <=400 & trackdistance[-1]>(-25), 0, (abs[trackdistance] > 50) * (-1.5)]
you chose a value of 50. Am I right in thinking that this is an "else" condition? And is the number important? I haven't tried changing it to see what happens.
So far I have tried the expression with a 600metre distance and it looks very good. The -25 should be suitable for nearly every situation, I would think.
avatar
graymac

Posts : 1744
Join date : 2011-08-28
Location : Co Mayo, Eire

http://www.celtictrainsim.com

Back to top Go down

Re: [Solved] Train-dependent level crossing

Post by Dexter on Mon Oct 17, 2011 11:04 pm

Yes, the regular ELSE condition, you are right. Surprised
Basically, the more important of the numbers is the one in brackets (-1.5 in this case) Currently, I am performing test whether and under what conditions the calculation can be replaced by a simple value of (-) 1.53, which is approximately equal to 87 angular degrees. It should also work by simply setting this amount of radians. You might want to try it out and let me know afterwards. Very Happy
avatar
Dexter

Posts : 1842
Join date : 2011-07-08
Age : 31
Location : Brno, Czech republic

http://www.brnobve.eu

Back to top Go down

Re: [Solved] Train-dependent level crossing

Post by graymac on Tue Oct 18, 2011 1:19 pm

Yes, you can change the 1.5 radians value which you have in your example to any other value to suit the situation.
It does not make any difference to the first part of the expression as the first part is a conditional formula which simply returns a value of 'true' or 'false'. As this is a 'Rotate' funtion then the amount of rotation is the figure, given in radians rather than degrees. For more information about the relationship between radians and degrees, and to understand how to make the calculations necessary, see here:

http://en.wikipedia.org/wiki/Radians
avatar
graymac

Posts : 1744
Join date : 2011-08-28
Location : Co Mayo, Eire

http://www.celtictrainsim.com

Back to top Go down

Re: [Solved] Train-dependent level crossing

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum