Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Sphere vs. Box colliders for Quatruped simulation joints become detached?

Discussion in 'Physics' started by CloudyVR, May 14, 2023.

  1. CloudyVR

    CloudyVR

    Joined:
    Mar 26, 2017
    Posts:
    714
    Hi I am trying to simulate bionic quadruped locomotion in Unity using ArticulationBody but am having a great amount of difficulty with setting up joints. I am having to constant adjust many parameters to avoid joint physics issues,

    But one of the major issues is the contact point colliders. The feet need to be high friction and low weight but in Unity when I use SphereCollider the friction is too low, the gait is stable but the contact points slips around on the floor even when the joint's force limits are very small: sphere.gif

    The locomotion looks decent however the feet slip around way too much: slip.gif
    I have tried adding physic materials with very high friction to both the floor and the feet but still the feet will slip around when the floor moves.

    Then I tried using Box colliders. The feet barely would slip on the moving floor while the robot was in a static pose.

    However once the legs were commanded to move the entire rig breaks apart and is very unstable:
    box.gif
    This is with default friction (no physic materials)..

    What can I do to create a realistic contact point that doesn't cause the ArticulationBody joints to fall apart?

    Thanks
     
  2. tjmaul

    tjmaul

    Joined:
    Aug 29, 2018
    Posts:
    467
    What you’re doing is probably way over my head but are you setting the joint positions directly or are you setting a target position and let the controller move the respective joint?

    same with the moving platform. Are you rotating it by setting transform position/rotation directly or are you using the kinematic rigidbody.moveRotation methods?
     
  3. leebissessar5

    leebissessar5

    Joined:
    Nov 15, 2022
    Posts:
    48
    I have done work on a quadruped robot but never managed to make it walk but just stand in place. I used box colliders for the feet, and I don't think that's the issue with mine. I think ArticulationBody is still in its early stages to accurately simulate walking robots. In my case, it's more complicated because my robot has loop joints (due to the diagonal spring).

    What controller are you using to control the robot though? Do you have a model of your robot?
     

    Attached Files:

  4. CloudyVR

    CloudyVR

    Joined:
    Mar 26, 2017
    Posts:
    714
    I have been trying to learn about Quadrupedal locomotion for only a week so I am not very really knowledgeable about the subject but I managed to write a kinematic model and Bezier trajectory gait planner using examples from MIT cheetah and mini cheetah.

    I'd like to use a neural network and reinforcement learning and train the platform to balance. However the contact points are absolutely critical and having very little configurability I'm afraid it won't be possible to accurately simulate the contact point without slipping or joints breaking.

    Even when setting force limits as high as 100 and damping on all joints to infinity the robot still wobbles around. Articulation joints appear to be very springy and seem to ignore their damping settings entirely.

    I was impressed when Unity introduce the ArticulationBody component but after working with it I am not sure they are designed for simulating anything more than a robot arm. And without a way to limit the springy behaviour I find ArticulationBody are limited.

    Would a mesh collider be more accurate than box collider?
     
    Last edited: May 14, 2023
    leebissessar5 likes this.
  5. CloudyVR

    CloudyVR

    Joined:
    Mar 26, 2017
    Posts:
    714
    The solver and SetDriveTarget are called from FixedUpdate():
    Code (CSharp):
    1. swingJoint.SetDriveTarget(ArticulationDriveAxis.X, angleX);
    2. hipJoint.SetDriveTarget(ArticulationDriveAxis.X, angleY);
    3. kneeJoint.SetDriveTarget(ArticulationDriveAxis.X, angleZ);

    To rotate the platform I am using random Perlin noise. The platform does have a attached kinematic rigidbody and the rotations are applied in FixedUpdate() :

    Code (CSharp):
    1.  private float t;
    2.     void FixedUpdate()
    3.     {
    4.         t += Time.deltaTime;
    5.         rb.rotation = RandomSmoothPointOnUnitSphere(t * _timeWeight);
    6.     }
    7.  
    Feet slipping still occurs despite very high values set for static and dynamic friction for all physic materials.
     
    Last edited: May 18, 2023
  6. leebissessar5

    leebissessar5

    Joined:
    Nov 15, 2022
    Posts:
    48
    Yeah, I only had success with a rover using the ArticulationBody component. Manipulators work also nicely as I heard from examples online. I've yet to try model verification because of how buggy it could be. Until then, I can't say ArticulationBody is reliable for simulation of walking robots.

    I'm also planning to try reinforcement learning but how are you doing it? What are you doing to reset the articulationbody when an episode terminates?

    To answer your last question, I doubt mesh collider would work any better. I think the problems are mostly due to the ArticulationBody component once again.
     
  7. CloudyVR

    CloudyVR

    Joined:
    Mar 26, 2017
    Posts:
    714
    I spent most of the day setting up hyperparameters and training environments. I started by training the Quadruped to balance on a moving platform:
     
    Last edited: May 20, 2023
  8. leebissessar5

    leebissessar5

    Joined:
    Nov 15, 2022
    Posts:
    48
    This is a big deal! You might have ArticulationBody figured out! Do you have a model documented? If so, can you share it?
     
  9. Cloudwalker_

    Cloudwalker_

    Joined:
    Jan 3, 2014
    Posts:
    140
    You need to use MoveRotation and MovePosition method for kinematic bodies. Anything else is teleporting and won't apply the proper friction forces.