Unsolved Add retarder to power train

Discussion in 'Mod Support' started by moravas, Nov 6, 2018.

  1. moravas

    moravas
    Expand Collapse

    Joined:
    Oct 27, 2018
    Messages:
    14
    Hi,

    We, at the Simhouse would like to to add / implement a retarder and add it to one of already existing power train (e.g.: one of the T75 truck's power train configuration).
    Can anybody help me, how can I do it? Is there any example, step-by-step guide, whatever?
     
  2. RobertGracie

    RobertGracie
    Expand Collapse

    Joined:
    Oct 15, 2013
    Messages:
    3,779
    Are you talking about a Jake brake or more like an exhaust brake here?

    I mean thats the only two sorts of brakes I know about that are related to engines
     
  3. MASKED REPTILIAN

    MASKED REPTILIAN
    Expand Collapse

    Joined:
    May 10, 2018
    Messages:
    203
    add more hub friction to emulate it maybe
     
  4. aljowen

    aljowen
    Expand Collapse

    Joined:
    Oct 21, 2012
    Messages:
    1,677
    My (limited) understanding is that retarders can be turned on and off, so adding more static friction wouldn't be ideal. Not to mention it would screw up the engine torque/power specs.

    My best initial idea for how to implement one would be:
    • Add a weak electric motor to the vehicle that works counter to the direction of movement, then create a key binding (using lua) that turns that motor on/off (as well as disabling the motor when stationary). This would behave like a retarder by adding friction to the system when engaged, it would also work independently of the brakes, avoiding fade. Since its completely programmable at that point, you could get pretty close to the real deal.
     
  5. MasterFluffy

    MasterFluffy
    Expand Collapse

    Joined:
    Jan 27, 2017
    Messages:
    91
    funny, so I have been wanting to do this but unsuccessful with lua. My goal was to have a key binding that would activate friction value in the transmission to retard vehicle speed... easy to activate it on or off. I got the key binding part to work... but couldn't figure it out how to apply fiction to transmission... likely just improper syntax.
     
  6. aljowen

    aljowen
    Expand Collapse

    Joined:
    Oct 21, 2012
    Messages:
    1,677
    I'm actually not sure if it is possible to adjust those values with Lua?

    If it is, obviously that is a much easier and elegant route to take.
     
  7. Capkirk

    Capkirk
    Expand Collapse

    Joined:
    Nov 19, 2017
    Messages:
    673
    It should be possible to just use the existing torque converter simulation to make a retarder work. The problem is, obviously, getting it to activate and deactivate on demand.
     
    • Informative Informative x 1
  8. metalmuncher

    metalmuncher
    Expand Collapse

    Joined:
    Aug 6, 2012
    Messages:
    257
    It's fairly easy to mess with the engine friction values in realtime in the vehicle lua: powertrain.getDevice("mainEngine").dynamicFriction and powertrain.getDevice("mainEngine").friction. This does actually affect the torque curve app if you reload it as well.
     
    • Informative Informative x 1
  9. aljowen

    aljowen
    Expand Collapse

    Joined:
    Oct 21, 2012
    Messages:
    1,677
    Ah, I guess that's my bad for taking the wiki at face value. I thought the Streams list was exhaustive.

    I guess I should start doing some digging around to see what I have been missing... :rolleyes:
     
  10. moravas

    moravas
    Expand Collapse

    Joined:
    Oct 27, 2018
    Messages:
    14
    Hi,

    A short video about retarder (don't forget, there are many types of retarders)


    Moreover, I don't have to many experience in BeamNG, but reloading the engine (its lua implementation) during the game doesn't seem a good choice.
    I checked the lua related wiki pages, and as I see it, there is a power train "node" in the vehicle's lua config (https://wiki.beamng.com/Powertrain). My guess is to implement a standalone lua module, like (from programming point of view) gearbox and add it to the list mentioned in the wiki.
    What do you think about these? Maybe any guide or example?
     
  11. fufsgfen

    fufsgfen
    Expand Collapse

    Joined:
    Jan 10, 2017
    Messages:
    6,782
    Maybe with shaft that can disconnect, there would be two routes from engine to wheels and disconnecting and connecting shaft your would switch from one to another, not sure if that would work in practice though as powertrain code might get confused.
     
  12. moravas

    moravas
    Expand Collapse

    Joined:
    Oct 27, 2018
    Messages:
    14
    Hi,

    any suggestion how to solve this issue? Is it even possible to develop new item and include into powertrain?
     
  13. fufsgfen

    fufsgfen
    Expand Collapse

    Joined:
    Jan 10, 2017
    Messages:
    6,782
    There is not much in form of tutorial in regards of LUA, but if you look into steamapps\common\BeamNG.Drive\LUA you can see all of powertrain code which is open source, so anyone proficient in LUA can add new items there. Sadly I can't really speak LUA, it takes quite bit of time from me to learn, but it is possible to extend powertrain a lot if you have the skills.

    In practice you would need to study how it is made and kinda reverse engineer it, check what there is in Wiki and work from there.
     
  14. aljowen

    aljowen
    Expand Collapse

    Joined:
    Oct 21, 2012
    Messages:
    1,677
    • Like Like x 1
  15. RobertGracie

    RobertGracie
    Expand Collapse

    Joined:
    Oct 15, 2013
    Messages:
    3,779
    @Diamondback I am wondering are you one of the people who does the simulated engines within the game itself, could you provide any input here?, if not can you get the right person in on this from the devs?

    What I mean by "simulated engines" is the vehicle engines within the game sorry for this update but sometimes I do not make it clear what I am saying first time out haha
     
    #15 RobertGracie, Nov 8, 2018
    Last edited: Nov 8, 2018
    • Agree Agree x 1
  16. metalmuncher

    metalmuncher
    Expand Collapse

    Joined:
    Aug 6, 2012
    Messages:
    257
    I've hacked together a basic mod to get someone started. I don't guarantee this is 'the' way of achieving this, or even a 'good' way, but it is 'a' way. :p

    This includes:
    • Retarder powertrain device, acts like a driveshaft with variable friction. Will probably not work as a wheel axle as I got rid of a load of wheel related code, havent tested disconnecting it or breaking.
    • Input actions for incrementing and decrementing the effect of the retarder
    • Inputmap for incrementing/decrementing on y and h by default, delete keyboard.diff if you want to rebind
    • A bit of lua to glue the powertrain device and input together via electrics
    • A replacement driveshaft that adds the retarder powertrain device between the transmission and driveshaft
    • A partsconfig with the replacement driveshaft loaded
    The retarder has both friction and dynamicFriction like an engine. friction is constant, dynamicFriction increases with speed. The friction values are set in jbeam for fully off and fully on, the electrics coefficient interpolates between the on and off values, 1 for fully 'on'. ATM this is a constant incremented and decremented by keys, more interesting control is left as an exercise for someone else. :)
     

    Attached Files:

    • Like Like x 5
  17. MasterFluffy

    MasterFluffy
    Expand Collapse

    Joined:
    Jan 27, 2017
    Messages:
    91
    Great work! works very well!
     
  18. moravas

    moravas
    Expand Collapse

    Joined:
    Oct 27, 2018
    Messages:
    14
    Thank you, it seems to work fine
    --- Post updated ---
    Hi All,

    maybe an additional question:
    I observed, that pressing the keys, increase the retarder coefficient value "randomli". In the input_action_retarder.lua, the value is increased by "0.5 * Value", but I don't see any declaration of value. I would like to increase coefficient by fix steps, like 25%, or 5, or whatever, and do it by discrete key press event
    How can I do it?

    Regards
     
    • Agree Agree x 1
  19. Tom Foolery

    Tom Foolery
    Expand Collapse

    Joined:
    Aug 2, 2017
    Messages:
    79
    Okay, I'm sorry to bump this thread, but I had an idea. Shifting into reverse with the Wentward slows it down on a grade using the converter, so what if we did this: Attach a converter (powered by nothing) through a rangebox (with low range set to reverse and high to 0) to the wheels. In theory, when the rangebox is switched to Low, the converter should absorb torque from the wheels and slow the vehicle down without any custom Lua. The stall torque should be the limiting factor... I think.
     
  20. airman426

    airman426
    Expand Collapse

    Joined:
    Sep 7, 2015
    Messages:
    288
    Wouldn't this same system be able to be applied to make a jake brake for the T-series?
     
    • Agree Agree x 1
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice