Skip to content

[Question] Randomizing the size and position of static objects (box geoms) makes them partially penetrable and leads to unexpected behavior #1295

Open
@Omer1Yuval1

Description

@Omer1Yuval1

Question

I added static obstacles (box geoms) to the half_cheetah.xml model, and I would like to randomize their position and size during training at the beginning of each episode (by adding a small random number to their original position and size). To do this, I set the following in the reset_model() method

self.model.geom(f"geom_{i}").pos[0] += np.random.uniform(a, b) # Position.
self.model.geom(f"geom_{i}").size[0] += np.random.uniform(c, d) # Depth.
self.model.geom(f"geom_{i}").size[2] += np.random.uniform(e, f) # Height.

The call to self.set_state() comes after setting the above.

However, it seems that this leads to some discrepancy within MuJoCo, as the box geoms become partially penetrable after modifying their position and size (i.e., the cheetah's body partially penetrates the box geoms, and sometimes even gets stuck inside them).

ChatGPT suggested adding mujoco.mj_forward(self.model, self.data) or self.sim.forward() before or after the call to self.set_state(), but this made no difference.

I am using
gymnasium 0.28.1
mujoco 3.2.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions