Experimental Old Automatic Emergency Braking Prototype (not WIP)

Discussion in 'Content Creation' started by angelo234, Feb 21, 2021.

  1. angelo234

    angelo234
    Expand Collapse
    Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    540
    Edit: I just did some calculations and found that I can make it work somewhat efficiently around corners but only under 45 mph, but I will be using this code for a "Driver's Assistance" mod.

    I'm not gonna be working on this anymore due to the technical challenges with the game (needs an extreme amount of CPU power to make it work properly). But if anybody would like to try out what I've made so far, you can now give it shot! :)
    • Only ETK 800
    • Only works in straight lines
    • Can detect both dynamic (vehicles) and static objects
    • Doesn't work well with small objects and only detects objects in path of raycasts

    If it's not working for you, press Ctrl + L to reset Lua.

    Github repo here:
    https://github.com/angelo234/aeb_angelo234
     

    Attached Files:

    #1 angelo234, Feb 21, 2021
    Last edited: Feb 26, 2021
    • Like Like x 7
  2. The_Kazoo_Meme

    The_Kazoo_Meme
    Expand Collapse

    Joined:
    Jul 4, 2018
    Messages:
    34
    It works really great! Very good job on this!
     
  3. DaddelZeit

    DaddelZeit
    Expand Collapse

    Joined:
    Jul 17, 2019
    Messages:
    3,319
    Yes! Amazing work!
     
  4. HeepXJ40

    HeepXJ40
    Expand Collapse

    Joined:
    Feb 6, 2020
    Messages:
    283
    how do you use it?
     
  5. angelo234

    angelo234
    Expand Collapse
    Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    540
    It only works with the ETK 800 car so it won't work with other cars and it should work right away (you'll see rays shooting out of the front of the car)
     
    • Agree Agree x 1
  6. DaddelZeit

    DaddelZeit
    Expand Collapse

    Joined:
    Jul 17, 2019
    Messages:
    3,319
    That's pretty weird, it doesn't shoot rays out the front but it still works for meo_O
     
  7. angelo234

    angelo234
    Expand Collapse
    Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    540
    Wait you don't see the rays being shot out on the top of the windshield? o_O I downloaded my uploaded mod and I see the rays. Well if it works then that's what counts :p

    Capture.png
     
  8. DaddelZeit

    DaddelZeit
    Expand Collapse

    Joined:
    Jul 17, 2019
    Messages:
    3,319
     
    • Like Like x 2
  9. angelo234

    angelo234
    Expand Collapse
    Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    540
    Hmmm... I think it's the graphics mod you've got installed causing it not to appear probably.
     
  10. DaddelZeit

    DaddelZeit
    Expand Collapse

    Joined:
    Jul 17, 2019
    Messages:
    3,319
    I only have ReShade and PostFX which both only have an overlay...the first time I installed it it worked, then I restarted the game and it was gone :p
    --- Post updated ---
    wait...no
    *facepalm*, I edited the lua so that it doesn't shoot the rays

    my brain is broke
     
    • Agree Agree x 2
    • Like Like x 1
  11. SuperShep1

    SuperShep1
    Expand Collapse

    Joined:
    Apr 14, 2019
    Messages:
    2,682
    lol.

    this is an interesting mod, would it be able to happen to the k-series?
     
  12. angelo234

    angelo234
    Expand Collapse
    Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    540
    If you want to make it work for another car, you first need to unzip the mod. Create a folder in the "mods" folder called "unpacked" and place the "aeb_angelo234" folder in there. Then open the "aeb_angelo234" folder and add a folder inside the "vehicles" folder with the name of the car (in this case "etkc"). And add a folder inside the "etkc" folder and name it "lua". And then copy and paste my "aeb_angelo234.lua" file from the "etk800/lua" folder into that new "lua" folder.

    So the file directory should look like this: "mods/unpacked/aeb_angelo234/vehicles/etkc/lua/aeb_angelo234.lua"
     
  13. SuperShep1

    SuperShep1
    Expand Collapse

    Joined:
    Apr 14, 2019
    Messages:
    2,682
    ah ok.
     
  14. Szymon2007

    Szymon2007
    Expand Collapse

    Joined:
    Nov 30, 2017
    Messages:
    745
    how do you do that?
     
  15. DaddelZeit

    DaddelZeit
    Expand Collapse

    Joined:
    Jul 17, 2019
    Messages:
    3,319
    Open aeb_angelo234\scripts\aeb_angelo234\extension.lua
    Replace
    Code:
            hit = castRayDebug(origin, dest, includeTerrain, renderGeometry)    
    with
    Code:
            hit = castRay(origin, dest, includeTerrain, renderGeometry)    
     
  16. Szymon2007

    Szymon2007
    Expand Collapse

    Joined:
    Nov 30, 2017
    Messages:
    745
    i've done some testing and:
    It sometimes prevents from launching the car if your car is directed at a building
    it stops collisions up to ~95 kph/60 mph, anything more and you slam into the thing in front at low speeds
    i'll try porting it to other cars
     
  17. Zero

    Zero
    Expand Collapse

    Joined:
    Sep 2, 2012
    Messages:
    1,386
    Just like IRL.
    Idk if the speed matches but at X speed, the point is no longer to prevent the crash but to minimize how bad it will be.
     
    • Agree Agree x 4
  18. angelo234

    angelo234
    Expand Collapse
    Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    540
    Yeah, the algorithm I used to cast rays is pretty crappy honestly. If you can, you can try to change some of the parameters to make it shoot lower, in other directions, and from different positions however else you want. If you can find a way to find the direction vector of the car without influence from the car rolling and pitching under braking, then you wouldn't need to be shooting rays into the sky, since they point parallel to the ground under braking lol.
     
    • Like Like x 1
  19. alentaylor22

    alentaylor22
    Expand Collapse

    Joined:
    Jan 19, 2018
    Messages:
    461
    NU UHHH I WAS THINKING THIS SHOULD HE IN THE GAME FOR LIKE A MONTH NOW AND SOMEONE DONE IT THANK YOUUU
    --- Post updated ---
    I know rn it’s still experimental but the only issue rn is sometimes it brakes too late and I end up slamming into the vehicle in front at me even if I’m going 30 mph maybe add more of the dot thing (ion know the name lol) to more in front of the car
     
  20. angelo234

    angelo234
    Expand Collapse
    Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    540
    I'm not gonna be revamping this highway AEB system code. But I just did some calculations (I had doubts in the past without doing calculations and someone else was supposed to work on this system but it seems like they aren't working on it now) and found that I can actually use this existing code with modifications to make an improved automatic braking system that can work around corners but only under 45 mph ish and still be somewhat efficient. And so I'm actually going to be using some of this code for my "Driver's Assistance/Parking Aid" mod.
     
    • Like Like x 2
  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