Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mesh-mesh collision not working #577

Open
HaoliangWang opened this issue Feb 6, 2025 · 0 comments
Open

Mesh-mesh collision not working #577

HaoliangWang opened this issue Feb 6, 2025 · 0 comments

Comments

@HaoliangWang
Copy link

HaoliangWang commented Feb 6, 2025

The collisions between two meshes seem to be not working? Although the meshes collides with the ground plane correctly. Here's a simple script to reproduce the behavior. The output video of this script can be found here

demo.mov

The cylinder.stl file used in this script is downloaded from the brax repo: https://github.com/google/brax/tree/241f9bc5bbd003f9cfc9ded7613388e2fe125af6/brax/v1/tests/testdata.

import brax.v1 as brax
import jax
import jax.numpy as jnp
from google.protobuf import text_format
from IPython.display import HTML, display
import brax.v1.io.html as html


CONFIG = """
    dt: 0.05 substeps: 10 friction: 1.0
    gravity { z: -9.8 }
    bodies {
      name: "Mesh1" mass: 1
      colliders { mesh { name: "Cylinder1" scale: 0.1 } }
      inertia { x: 1 y: 1 z: 1 }
    }
    bodies {
      name: "Mesh2" mass: 1
      colliders { mesh { name: "Cylinder2" scale: 0.1 } }
      inertia { x: 1 y: 1 z: 1 }
    }
    bodies { name: "Ground" frozen: { all: true } colliders { plane {} } }
    defaults {
      qps { name: "Mesh1" pos: {x: 0 y: 0 z: 1.5} }
      qps { name: "Mesh2" pos: {x: 0 y: 0 z: 5} rot: {x: 0 y: 90 z: 0} }
    }
    mesh_geometries {
      name: "Cylinder1"
      path: "cylinder.stl"
    }
    mesh_geometries {
      name: "Cylinder2"
      path: "cylinder.stl"
    }
  """


sys = brax.System(text_format.Parse(CONFIG, brax.Config()))
qp = sys.default_qp(0)
qp, _ = sys.step(qp, jnp.array([]))

jit_step = jax.jit(sys.step)

frames = []
for i in range(1000):
    print(i)
    qp, _ = jit_step(qp, jnp.array([]))
    frames.append(qp)

html_string = html.render(sys, frames)
display(HTML(html_string))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant