How to make a script in BEAMNG to measure the wheel-vehicle body relative velocity

Discussion in 'Programming' started by 635013471, Dec 20, 2023.

  1. 635013471

    635013471
    Expand Collapse

    Joined:
    Dec 19, 2023
    Messages:
    2
    Is there any way to make a script to measure and record wheel-vehicle body relative speed?

    Use this relative speed, with suspension motion ratio, I would like to cauculate the damper velocity at each corner, to tune the dampers.

    For the streams, here might be a official value to record the wheel's vertical velocity at Z axis.
    upload_2023-12-20_20-3-21.png

    In my opinion, because the vehicle body motion is slow, so we can regard this wheel speed as wheel-vehicle body relative speed approximately.

    So the question is easy, does anyone have a script to real-time measure and record the wheel speed?
    Many thanks for your help.
     
  2. Derpitron

    Derpitron
    Expand Collapse

    Joined:
    Jun 25, 2017
    Messages:
    252
    I'm no expert but seems to me you could get and compare the velocity of the centre node of the wheel and the "velocity" of the car object? Been a while but I'm sure the BeamNG api exposed a way to get the velocity of a node. Someone please correct me if I am wrong.
     
  3. SineMatic

    SineMatic
    Expand Collapse

    Joined:
    Nov 17, 2022
    Messages:
    60
    I've made a mod that records wheel speed relative to the Gavril D-Series body by z-axis (select 'Measuring beam' part in the 'Tow Hitch' slot in part selector). You have to execute 'measuringBeam.dump()' command in console to dump the measurements to the 'beamVelocity.txt' file.

    How it works: there's a beam with 'beamSpring' and 'beamDamp' parameters set to 0, connecting the wheel hub node and some fender node. Once the car is spawned, the Lua code starts to insert beam contraction/expansion velocity in real-time to the 'data' table by running obj:getBeamVelocity(beamID) function.

    For example, it's easy to visualize the dumped values as a chart in Excel:

    Screenshot2024-03-02103101.png
     

    Attached Files:

    #3 SineMatic, Mar 2, 2024
    Last edited: Mar 6, 2024
  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