Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Wheelcolliders in self driving cars

Discussion in 'ML-Agents' started by m4l4, Sep 15, 2020.

  1. m4l4

    m4l4

    Joined:
    Jul 28, 2020
    Posts:
    42
    Hi everyone, i'm trying to understand how weheelcolliders behave, and even if i got a pretty decent results on my car, there are still things i can't grasp.

    The main things is how to completely stop the car from moving at the beginning of the episode.
    i've tried everything, brakeTorque = infinity, motorTorque = 0, rb.velocity & rb.angular velocity = vector3.zero, useGravity = false, isKinematic = true, and still after the agent reset there are still forces applied to the car.

    i'm using 2 booleans to be sure that the "full stop" is applied at least for 1 fixed update before calling EndEpisode().

    if rb.velocity.magnitude is around 0 for a certain time, the agent gets resetted, so i can check if the car got stuck. When it flips on a side, velocity goes down, the counter starts ticking, but if i keep accelerating while waiting for the reset, as the new episode begins, the car starts almost at full speed.

    In a videogame you could easily set it to kinematic for the first 4-5 frames or whatever, but being an ML agent, this could mess with the initial inputs of every episode.
    I think messing with the last input would be less problematic for the agent, that's why i tried stopping it completely right before EndEpisode, instead of doing it onEpisodeBegin.

    am i missing some forces? how can i make it stop completely?
     
  2. m4l4

    m4l4

    Joined:
    Jul 28, 2020
    Posts:
    42
    so, after debugging each force one by one, i found out that the problem is the motorTorque.
    setting motorTorque = 0 and brakeTorque = infinity for a single fixedUpdate doesn't completely stop the wheel from turning, it just slows down.

    they must be applied until the wheel stops completely, and the time varies based on the actual motorTorque and friction.

    that can easily be done with a timer when the car is upsidedown or flipped on a side, but if the car falls out of the track, the reset is immediate and i'm still unable to stop it completely in a single fixedUpdate.

    any idea?
     
  3. jasonb_unity797

    jasonb_unity797

    Unity Technologies

    Joined:
    Jan 18, 2020
    Posts:
    2
    You might have more success asking in the physics forum; https://forum.unity.com/forums/physics.78/

    I read through the docs on the collider and associated tutorial. Have you tried playing with the mass, forward friction, or physics time step values?
     
  4. m4l4

    m4l4

    Joined:
    Jul 28, 2020
    Posts:
    42
    thanks, i was thinking about asking in the physics forum, but i need an approach that won't mess with the inputs of the agent. i'll read the doc about the physics time step
     
unityunity