Reusing OpenRails physics code for model railways use

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cjakeman
    Senior Member
    • Mar 2010
    • 137

    #31
    Originally posted by Markstaffrld
    Chris I’ve been told that replicating model railway track is not able to be duplicated exactly and because of the discrepancies it could lead to application crashes.

    Does the two descriptions of both the real and virtual have to be precisely the same? If it is can it be achieved?
    Getting curves of the correct radius is not an issue as you can specify the radius and angle in Open Rails. Switches/Pointwork would take longer as these are comparable to modellers set track and new ones would have to be created with a tighter radius.

    However this is side issue in order to give you proper gradients. The main issue is to get acceleration and braking acceptable on a model.

    Originally posted by Markstaffrld
    Going the other way and distilling the physics code out of train.cs have you a view on how big that code would most likely be?
    I’m trying to work out if our protothrottles have enough ram to be able to process the physics basic algorithms on board. Ball park?
    Some of our users are looking at 100 trains simultaneously, but here we have only one. A few kB I would guess.

    *************

    I've enjoyed exploring what's possible here and your ProtoThrottle looks very good to me. However I've got lots of coding commitments already, so unless you have a friendly coder on tap I can't see this going anywhere.
    Chris Jakeman

    sigpic

    Comment

    • Markstaffrld
      Member
      • Jan 2019
      • 22

      #32
      Chris I want to Thankyou so much for your guidance, without your input I wouldn’t understand that the idea I had is (with the right people onboard) was viable.

      That pleases me no end. But no volunteers have come forward and I have been getting a bit of trolling by nesayers on the subject and I feel somewhat worn down.

      I’m going to concentrate on building the ProtoThrottle hardware first and hope that along the way the hardware will inspire a coder to join me and try an option or two then.

      But Chris I do what you to know I really appreciate your helping me and I know that your way busy and have little time. I know the feeling.

      Regards
      Mark

      Comment

      • Markstaffrld
        Member
        • Jan 2019
        • 22

        #33
        Back again men, I have a follow up question on the same subject.

        To reuse Openrails Physics code to enhance model railway train behaviours.

        Two of us have been working our way through Openrails (or should I say Greg has). With less input from me given I’m not a coders backside.

        But we have been looking at
        Openrails-Testing-Source/Source/ORTS.Simulaton/Simulation/physics/train.cs

        This piece of code would appear to have software that is tracking slack at each coupler and covers of making sure slow acceleration is used to not break couplers.

        That is all fine and good but it doesn’t seem to point us to the place where the physics of a steam engine works out how much throttle with x amount of reverser cutoff causes y amount of acceleration.

        I found that

        Source Orts.Simulation/Common/SteamTables.cs

        Appears to have the base tables that matimatical formulars would use under differing circumstances to deliver realistic driver outcomes to throttle/cutoff and outside external inputs settings

        But for the life of me, I’m not nailing down where these things “tie it all together”

        HELLLLLLPPPPPP! Please!

        Mark the model railway dude
        Last edited by Markstaffrld; 03-07-2019, 20:43.

        Comment

        • Markstaffrld
          Member
          • Jan 2019
          • 22

          #34
          Hi again,

          I have discovered the coalstonewcastle web site.

          What a fantastic resource. I think most of what I need can be found on that web address.

          Have a great days guys
          Mark

          Comment

          • cjakeman
            Senior Member
            • Mar 2010
            • 137

            #35
            Originally posted by Markstaffrld
            But we have been looking at
            Openrails-Testing-Source/Source/ORTS.Simulaton/Simulation/physics/train.cs

            This piece of code would appear to have software that is tracking slack at each coupler and covers of making sure slow acceleration is used to not break couplers.

            That is all fine and good but it doesn’t seem to point us to the place where the physics of a steam engine works out how much throttle with x amount of reverser cutoff causes y amount of acceleration.
            The acceleration of the train depends on the MotiveForceN of each loco, the effect of gravity where there's a gradient and drag due to friction, wind resistance etc.

            You've been looking in the right file for acceleration.

            Method physicsUpdate() runs at eachupdate cycle to calculate TotalForceN for each car in the train and ultimately the revised SpeedMpS of the train.

            But to find the MotiveForceN for a steam loco, you should look into MSTSteamLocomotive.cs at method UpdateMotiveForceN()

            It's all rather involved as OR caters for simple and compound steam engines and geared steam engines too.
            Chris Jakeman

            sigpic

            Comment

            • Markstaffrld
              Member
              • Jan 2019
              • 22

              #36
              Thanks Chris,

              I think this job is going to take a while
              Mark

              Comment

              • SimonME30
                New Member
                • Jul 2019
                • 17

                #37
                Hi Mark,
                I’m keen to do this for my layout.
                It’s not just the physics tho, it’s the sound as well. I model in O gauge, and have a fleet of 12”:1’ carriages. I don’t want to hear a light engine getting around, with ghost carriages, I want to hear the entire train go past. Loco sound decoders just don’t do this, nor will they ever have the bass sound of a full size train.

                My approach would be to model the layout in OpenRails, including the timetable (I like operation, and have the WTT for my prototype). Use OpenRails in full, straight out of the box. Use the API to extract the relevant speed and direction data, and control the models via a Wi-Fi, battery powered on board ‘decoder’. I have done the latter using ESP8266. Use the well established DCc++ comms protocol or indeed the wi-throttle protocol would also work.

                Next part I would like is as you suggest, a steam centric handle held, wi-Fi loco controller.

                Comment

                • SimonME30
                  New Member
                  • Jul 2019
                  • 17

                  #38
                  Hi Mark,
                  just thought I'd provide an update.

                  ive got another new thread https://www.trainsim.com/forums/foru...lp#post2342385. Some repeated comment from that thread is below

                  The game changer for me has been AI helping me to do the code. Probably a terrible idea, but it was never going to happen without some kind of intelligence that I don't have, so artificial it is!

                  I've done a first nowRail ESP32 based handcontroller which has no screen, embedded physics, and steam loco style controls (5x BCD Thumbwheel switches for DCC locoAddr, regulator/reverser/brake/switches for maker lights/couplers etc...). That 'sketch' will shortly get upgraded to talk with OpenRails. So openrails will then tell nowRail what each locos speed, direction and reverser setting is (using DCC protocols, so it's not an orphan). Each loco will have a nowRail ESP32 'decoder' which will interpret the dcc commands. I've already done a 30 lever fully interlocked lever frame, which is broadcasting the facing point lock/point/signal commands over nowRail, and a mimic panel with 36 servos which has 2x nowRail ESP32 'accessory decoders' which are driving the servos via 3x PCA9685

                  I've always wanted impressive bass sound which is more than just the loco, and has the effect that after the train has passed, all you can hear is the carriages. So I've just done a project in Visual Studio to have an Array of 12x 3.5" speakers under the 7200mm scenic section of the layout. The project is like having 12x 'external cameras' spaced evey 600mm down the layout, and the relevant sound is played/panned through each speaker.

                  The speakers will be in 3x 100mm high x 400mm deep x 2400mm long 'cabinets', with horizontal baffles v'd out in front of each speaker. The baffles have engine room mass loaded vinyl sound proofing. The theory is that you can only really hear from the 2-3 speakers directly in front of you, so after the loco has gone past you, the volume of its exhaust should hopefully fade, rather than with DCC systems where I'd be able to hear the sound for the entire length of the layout. Hardware has been ordered, so far only the Motu UltraLite5 10 channel (+ headphones) mixer has turned up. Cables, Amplifiers and 3.5" drivers are on their way.

                  If I tell open rails that the storage yard is all at 1:50, it should keep the engine working hard as it continues to climb the 1:50 grade out of the station as it moves from right to left (even tho IRL the loco and carriages will be on the flat). And my under baseboard sound project will continue to play those sounds, but fading as the train exits audience left....

                  I'm planning to use timetable mode to set up as much of the sequence as I can.

                  progress to date is that I've been able to model the layout in TSRE5. I've got some faults to correct, download some rolling stock, make some paths that make sense, and see if I can set up a timetable.

                  Comment

                  Working...