Unsolved Add retarder to power train

ExpandCollapse

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?

ExpandCollapse

ExpandCollapse

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.

ExpandCollapse

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.

ExpandCollapse

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.

Click to expand...

I'm actually not sure if it is possible to adjust those values with Lua?

ExpandCollapse

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.

Click to expand...

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.

ExpandCollapse

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.

ExpandCollapse

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.

Click to expand...

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...

ExpandCollapse

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?

ExpandCollapse

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.

Click to expand...

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.

ExpandCollapse

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

Click to expand...

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.

ExpandCollapse

@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

ExpandCollapse

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.

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.

ExpandCollapse

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?