Skip to content

[Bug]: Contacts detection of feet and ground, sometimes wrong #1899

@ucacaxm

Description

@ucacaxm

Bug Description

Hi,

I detect contact between feet and ground (flat).
I did it with 'get_contact' and inspect all the detected contact, and also with a sensor.

Most of the time, is is ok. But sometimes it is wrong like on the image. The left foot has the debug sphere of the sensor showing a contact but there is no contact.

Image

Is it because of a delay between what is displayed and the simulation?

Thanks,

Steps to Reproduce

If possible, provide a script triggering the bug, e.g.

import genesis as gs
import numpy as np

gs.init(backend=gs.gpu)

scene = gs.Scene(
    viewer_options=gs.options.ViewerOptions(
        camera_pos=(3, -1, 1.5),
        camera_lookat=(0, 0, 0.5),
        camera_fov=40,
    ),
    show_viewer=True,
)

scene.profiling_options.show_FPS = False

plane = scene.add_entity(
    gs.morphs.Plane(),
)

robot = scene.add_entity(
        morph=gs.morphs.URDF(
            file="data/urdf/tux.urdf",
            pos=(0, 0, 2.0),
            scale=1.0,
            links_to_keep = {"left_foot", "right_foot"},
        ),
    )

leftfoot_link = robot.get_link('left_foot')
rightfoot_link = robot.get_link('right_foot')




sensor_options = gs.sensors.Contact(
    entity_idx=robot.idx,
    link_idx_local=leftfoot_link.idx_local,
    draw_debug=True,
)
sensor = scene.add_sensor(sensor_options)

scene.build( )


for i in range(1000):
    scene.step()

    print(sensor.read())

    #ground_contacts = plane.get_contacts( with_entity=leftfoot_link.entity, exclude_self_contact=True )
    ground_contacts = leftfoot_link.entity.get_contacts( with_entity=plane, exclude_self_contact=False )

    if leftfoot_link.idx in ground_contacts["link_a"] or leftfoot_link.idx in ground_contacts["link_b"]:
        leftfoot_ground_contacts = True
    else:
        leftfoot_ground_contacts = False

    if rightfoot_link.idx in ground_contacts["link_a"] or rightfoot_link.idx in ground_contacts["link_b"]:
        rightfoot_ground_contacts = True
    else:
        rightfoot_ground_contacts = False

    print("contact: l", leftfoot_ground_contacts, "  r=", rightfoot_ground_contacts)

    


Make sure to attached any needed assets (here attachement.xml)!

Expected Behavior

Get correct contact information

Screenshots/Videos

No response

Relevant log output

Environment

  • OS: Ubuntu 24.04
  • GPU/CPU RTX 4090

Release version or Commit ID

[Genesis] [13:25:49] [INFO] Running on [NVIDIA GeForce RTX 4090] with backend gs.cuda. Device memory: 23.64 GB.
[Genesis] [13:25:49] [INFO] 🚀 Genesis initialized. 🔖 version: 0.3.4, 🌱 seed: None, 📏 precision: '32', 🐛 debug: False, 🎨 theme: 'dark'.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions