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

how to get boxes to collide / rest on top of each other #22

Closed
grez72 opened this issue Jul 30, 2021 · 1 comment
Closed

how to get boxes to collide / rest on top of each other #22

grez72 opened this issue Jul 30, 2021 · 1 comment

Comments

@grez72
Copy link

grez72 commented Jul 30, 2021

Hi,

I'm having some trouble understanding how to correctly specify colliders. In the test below, I'm placing 1m boxes at z positions 1 and 3, and expect them to fall to z positions .5 and 1.5 (with Box2 resting on top of Box1), but Box2 passes through Box1. Is there something more I should specify to make the boxes collide?

import brax
from google.protobuf import text_format
from jax import numpy as jnp

_CONFIG = """
  dt: 1.5 substeps: 1000 friction: 0.6 baumgarte_erp: .1
  gravity { z: -9.8 }    
  bodies { name: "Ground" frozen: { all: true } colliders { plane {}}}
  bodies {    
    name: "Box1" mass: 1
    colliders { box { halfsize { x: 0.5 y: 0.5 z: 0.5 }}}
    inertia { x: 1 y: 1 z: 1 }
  }
  bodies {
    name: "Box2" mass: 1
    colliders { box { halfsize { x: 0.5 y: 0.5 z: 0.5 }}}
    inertia { x: 1 y: 1 z: 1 }
  }
  
"""

def test_boxes_fall_on_one_another():
  """Box1 falls onto the ground and stops, Box2 falls and rests on top of Box1."""
  sys = brax.System(text_format.Parse(_CONFIG, brax.Config()))
  qp = brax.QP(
      pos=jnp.array([[0, 0, 0],[0., 0., 1.],[0., 0., 3.]]),
      rot=jnp.array([[1., 0., 0., 0.], [1., 0., 0., 0.], [1., 0., 0., 0.]]),
      vel=jnp.array([[0., 0., 0.], [0., 0., 0.], [0., 0., 0.]]),
      ang=jnp.array([[0., 0., 0.], [0., 0., 0.], [0., 0., 0.]]))
  qp, _ = sys.step(qp, jnp.array([]))  
  return sys,qp

sys,qp = test_boxes_fall_on_one_another()
print(qp.pos)

# observed
#[[0.         0.         0.        ]
# [0.         0.         0.49988964]
# [0.         0.         0.49988964]]

# expected
#[[0.         0.         0.        ]
# [0.         0.         0.5]
# [0.         0.         1.5]]

@cdfreeman-google
Copy link
Collaborator

Ah, we currently don't have box-box collisions in. This is on our roadmap, and I'll be sure to ping you when they're ready!

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

2 participants