huggingface / simulate

🎢 Creating and sharing simulation environments for embodied and synthetic data research
https://huggingface.co/docs/simulate
Apache License 2.0
187 stars 13 forks source link

Flat `Box` has a different rotation via `direction` #205

Closed natolambert closed 1 year ago

natolambert commented 2 years ago

In creating #147, I found that boxes that are flat in the y axis have a different rotation. Without the specified rotation in the constructor, the boxes are rotated off by 90 degrees.

Can we expose rotation to the construction of default Object3d's?

Code to reproduce:

    for i in range(len(CHUNK_X)-1):
        x1, x2 = CHUNK_X[i], CHUNK_X[i+1]
        y1, y2 = SMOOTH_Y[i], SMOOTH_Y[i+1]
        normal = [-(y2-y1), (x2-x1), 0]
        if y1==y2:
            rotation = [0, 90, 0]
        else:
            rotation = [0,0,0]

        block_i = sm.Box(position=[(x1+x2)/2, (y1+y2)/2, -0.5],
                         direction=normal,
                         bounds=[0.01, np.sqrt((x2-x1)**2 + (y2-y1)**2), 1],
                         material=sm.Material.GRAY,
                         rotation=rotation,
                         with_collider=True)
        sc += block_i

Example without rotation hard-coding:

Screen Shot 2022-09-14 at 10 22 40 AM

With rotation hard-coding:

Screen Shot 2022-09-14 at 10 22 57 AM
natolambert commented 2 years ago

Update, this was caused by the direction parameter being used to set orientation rather than rotation. A weird coupling happened.

Additionally, direction does not translate to colliders.

natolambert commented 1 year ago

Solved when removed direction argument in favor of rotation.