Solved Low-pass Filter on Angular Velocity of Differential

Discussion in 'Mod Support' started by default0.0player, Jun 17, 2021.

  1. default0.0player

    default0.0player
    Expand Collapse

    Joined:
    Nov 30, 2018
    Messages:
    1,925
    SOLVED
    Code:
    local outputAV1Smoother = newExponentialSmoothing(50)
    local outputAV2Smoother = newExponentialSmoothing(50)
    Code:
      local outputAV1 = outputAV1Smoother:get(differential.outputAV1) --left wheel
      local outputAV2 = outputAV2Smoother:get(differential.outputAV2) --right wheel
    Explanation here
    I'm creating an active locking/torque vectoring differential/transfercase that working in a proactive manner without DSE. For the use of non-DSE equipped vehicle(s), The 1st gen Pessima is currently being used as a testbed.

    The proactive part is already complete, I successively acquired the steering angle, lateral and horizontal g-forces.
    The problem is the reactive part: when too much speed difference between the shafts of a diff, a locking torque is applied.
    For example, when the inner wheel is 100 RPM higher than the outer wheel, increase the locking force. When the RPM difference is lower than 50, do not interfere.
    A differential has one input and two output. There are inputTorque, outputTorque1, outputTorque2 in N*m, and inputAV, outputAV1, outputAV2 in rad/s. Therefore to make the locking torque
    Code:
    1000 * clamp(math.abs(outputAV2 - outputAV1) * 0.2 - 1,0,1)
    It can be interpreted as a mathematical functon Y = aX + b where a is 0.2 and b is -1
    If directly used
    Code:
    differential.outputAV2 - differential.outputAV1
    , then massive oscillation will occur.
    BeamNGdrive-0223011810-RELEASE-x646_17_20212_02_41PM.png
    However, if use newExponentialSmoothing(50) to smooth the outputAV, then the "math.abs(outputAV2 - outputAV1) * 0.2 - 1" is no longer accurate as shown below
    BeamNGdrive-0223011810-RELEASE-x646_17_20213_46_19PM.png
    Therefore, my "best guess" is set the function inaccurately, via trial and error "math.abs(outputAV2 - outputAV1) * 0.5 - 0.15", the a and b are 0.5 and -0.15 respectively.

    My question is how to make the outputAV not to oscillate during locking actuation and set the locking control with angular velocity accurately, and why does newExponentialSmoothing makes the values way off? and how to include a low-pass filter in the outputAV sensors?

    The WIP mod is in the attachment, the diffs are named "Torque Vectoring Rear Differential", "Clutched Front Differential" and "Clutched2 Front Differential", Clutched and Torque Vectoring are based on LSD, Clutched2 is based on Welded.
     

    Attached Files:

    #1 default0.0player, Jun 17, 2021
    Last edited: Jun 26, 2021
    • Like Like x 1
  2. Justy4WDTURBO

    Justy4WDTURBO
    Expand Collapse

    Joined:
    May 14, 2016
    Messages:
    648
  3. SKB

    SKB
    Expand Collapse

    Joined:
    Apr 22, 2017
    Messages:
    1,964
    Driving Safety Electronics.
     
    • Like Like x 1
  4. angelo234

    angelo234
    Expand Collapse
    Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    540
    After looking through your code, one thing that stands out to me that probably is causing problems is that you are using the same "ExponentialSmoothing" object for smoothing the two output angular velocities. You should create separate "ExponentialSmoothing" objects for smoothing each output angular velocity independently. The reason is that the "ExponentialSmoothing:get" function uses the previous smoothed value to determine the new smoothed value. And basically with the way you are doing it now, when you smooth "outputAV2", the previous smoothed value is based on "outputAV1", which obviously can cause some problems :)
     
    #4 angelo234, Jun 21, 2021
    Last edited: Jun 21, 2021
    • Like Like x 1
  5. Diamondback

    Diamondback
    Expand Collapse
    Vehicle Systems Lead
    BeamNG Team

    Joined:
    Apr 8, 2014
    Messages:
    1,957
    In addition to what was said above, a smoother will by design give you output values different than your input values, it will "invent" values inbetween your varying input values to make the transition smoother. Some types of smoothing can in theory also introduce values outside the original input range if not used correctly.
     
    • Like Like x 1
  6. default0.0player

    default0.0player
    Expand Collapse

    Joined:
    Nov 30, 2018
    Messages:
    1,925
    Thank you very much, the fixed version is here
     
    • Like Like 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