Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Revolute articulation body has different rotation

Discussion in 'Physics' started by Hatemsla, May 23, 2023.

  1. Hatemsla

    Hatemsla

    Joined:
    Oct 17, 2021
    Posts:
    61
    I am trying to make robot turns using articulation body with revolute type. Everything would be fine, but provided that my wheels are configured the same way, they rotate differently, to be more precise, one wheel turns by 10 degrees, and the other by 15 and I don't know what the problem is, I don't think the problem is in the errors of physics calculations, since the size is too big for this. Also, make no mistake, I give the wheels the same force to rotate, literally, all the parameters are the same, but in the end I get different wheel behavior. Can someone tell me what the problem is here? The same settings
    The same settings The same forces for rotation
    Here code for rotation:
    Code (CSharp):
    1. private void RobotRotationInput(float rotSpeed) // m/s and rad/s
    2.        {
    3.            if (rotSpeed > maxRotationalSpeed)
    4.            {
    5.                rotSpeed = maxRotationalSpeed;
    6.            }
    7.          
    8.            var wheelRotation = (rotSpeed / wheelRadius);
    9.            var wheelSpeedDiff = ((rotSpeed * trackWidth) / wheelRadius);
    10.          
    11.            if (rotSpeed != 0)
    12.            {
    13.                wheelRotation = (wheelRotation - (wheelSpeedDiff / 1)) * Mathf.Rad2Deg;
    14.            }
    15.            else
    16.            {
    17.                wheelRotation *= Mathf.Rad2Deg;
    18.            }
    19.  
    20.            var rotationOffset = (wheelRotation - rotationWheel1.xDrive.targetVelocity) / 4;
    21.            wheelRotation -= rotationOffset;
    22.          
    23.            SetSpeed(rotationWheel1, wheelRotation);
    24.            SetSpeed(rotationWheel2, wheelRotation);
    25.            SetSpeed(rotationWheel3, wheelRotation);
    26.            SetSpeed(rotationWheel4, wheelRotation);
    27.        }