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

Incorrect collision detection causes strange rigid body floating #444

Open
Linmin1209 opened this issue Jan 2, 2025 · 6 comments
Open

Comments

@Linmin1209
Copy link

I am currently using Genesis to simulate a robotic arm performing a block assembly task. However, I’ve encountered a strange issue: after importing the blocks into the environment, they seem to float up and down erratically on the surface of the rigid body.

This behavior makes it challenging to achieve stable interactions in the simulation. I suspect it might be related to incorrect collision detection or physics settings.

2025-01-02.172131.mp4

The blocks were imported using 3D files in the .obj format, and I’ve checked the collision meshes using visualization tools—they appear to be perfectly normal.
屏幕截图 2025-01-02 172346

Could you please provide guidance on how to resolve this issue or suggest possible configurations to investigate?

@zhouxian
Copy link
Collaborator

zhouxian commented Jan 2, 2025

Oh by default, we convexify all the geoms

could you use vis_mode=‘collision’ when adding entity to visualize the collision geoms?

@Linmin1209
Copy link
Author

Thank you for your reply. When I use vis_mode="collision", the result is like this.
屏幕截图 2025-01-03 110325

@ZhiyuanZhou8
Copy link

Hi, thanks for your great work!
I want to ask how to set such a desk in the scene. By using .urdf?

@zhouxian
Copy link
Collaborator

zhouxian commented Jan 3, 2025

The collision mesh looks fine

can you share your script? are u using convex decomposition or sdf for nonconvex obj?

Also one tip: when there's multiple objects, turning on contact island (in rigid_options) could greatly improve speed

@Linmin1209
Copy link
Author

@ZhiyuanZhou8 Yeah, I use the asset from PartNet Dataset.

@Linmin1209
Copy link
Author

Linmin1209 commented Jan 3, 2025

@zhouxian Thank you for your tips. And, here is my script:

import genesis as gs
import numpy as np
import time
import json
from PIL import Image

gs.init(backend=gs.vulkan,precision='32')

scene = gs.Scene(show_viewer=True,
                 viewer_options = gs.options.ViewerOptions(
                    res           = (1280, 960),
                    camera_pos    = (3.5, 0.0, 2.5),
                    camera_lookat = (0.0, 0.0, 0.5),
                    camera_fov    = 40,
                    max_FPS       = 60
                ),
                vis_options = gs.options.VisOptions(
                    show_world_frame = True,
                    world_frame_size = 1.0,
                    show_link_frame  = False,
                    show_cameras     = False,
                    plane_reflection = True,
                    ambient_light    = (0.1, 0.1, 0.1),
                ),
                rigid_options= gs.options.RigidOptions(
                    enable_self_collision=True
                ),
                # renderer=gs.renderers.Rasterizer(),
                renderer = gs.renderers.RayTracer())

plane = scene.add_entity(gs.morphs.Plane(collision=True))

cam = scene.add_camera(
    res    = (1280, 960),
    pos    = (3.5, 0.0, 2.5),
    lookat = (0, 0, 0.5),
    fov    = 30,
    GUI    = False,
)

with open("./FMB/assets/scenes/scene1/scene_table.json","r")as f:
# with open("./FMB/assets/scenes/scene1/scene1.json","r")as f:
    scene_data = json.load(f)

scene_dict = {}
for i in scene_data: 
    if i["type"] == "urdf":
        obj = scene.add_entity(
        gs.morphs.URDF(**i["attribute"])
    )
    else:
        obj = scene.add_entity(
            gs.morphs.Mesh(**i["attribute"]),
            vis_mode="collision"
        )
      
    scene_dict[i["name"]] = obj
scene.build()
while True:
    # time.sleep(5)
    scene.step()

And the json file is:

[
    {
    "name":"robot",
    "type": "urdf",
    "attribute":
    {
    "file":"./FMB/assets/robots/gen3.urdf",
    "pos":[0.20,0.40,1.248],
    "euler":[0,0,90],
    "fixed": true,
    "merge_fixed_links": false 
    }
},
    {
    "name":"blue",
    "type": "mesh",
    "attribute":
    {
    "file":"./FMB/assets/scenes/scene1/blue.obj",
    "pos":[0.20,0,1.248],
    "euler":[90,0,0],
    "convexify": false,
    "decompose_nonconvex": false
    }
},
    {
    "name":"green",
    "type": "mesh",
    "attribute":
    {
    "file":"./FMB/assets/scenes/scene1/green.obj",
    "pos":[0.20,0,1.249],
    "euler":[90,0,0],
    "convexify": false,
    "decompose_nonconvex": false
    }
},
    {
    "name":"purple",
    "type": "mesh",
    "attribute":
    {
    "file":"./FMB/assets/scenes/scene1/purple.obj",
    "pos":[0.20,0,1.249],
    "euler":[90,0,0],
    "convexify": false,
    "decompose_nonconvex": false
    }
},
    {
    "name":"red_board",
    "type": "mesh",
    "attribute":
    {
    "file":"./FMB/assets/scenes/scene1/red.obj",
    "pos":[0.20,0,1.249],
    "euler":[90,0,0],
    "convexify": false,
    "decompose_nonconvex": false
    }
},
    {
    "name":"yellow",
    "type": "mesh",
    "attribute":{
    "file":"./FMB/assets/scenes/scene1/yellow.obj",
    "pos":[0.20,0,1.249],
    "euler":[90,0,0],
    "convexify": false,
    "decompose_nonconvex": false
    }
},
    {
    "name":"tool",
    "type": "mesh",
    "attribute":
    {
    "file":"./FMB/assets/scenes/scene1/tool.obj",
    "pos":[0.20,0,1.248],
    "euler":[90,0,0],
    "convexify": false,
    "decompose_nonconvex": false
    }
},
    {
    "name":"table",
    "type": "urdf",
    "attribute":
    {
    "file":"./FMB/assets/tables/table_01/mobility.urdf",
    "pos":[0.20,0,0.8047],
    "euler":[0,0,0],
    "fixed": true
    }
}
]

I set the convexify=False and decompose_nonconvex=False.

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

3 participants