haosulab / ManiSkill

SAPIEN Manipulation Skill Framework, a GPU parallelized robotics simulator and benchmark
https://maniskill.ai/
Apache License 2.0
734 stars 129 forks source link

[Question] Self-Collision Joints Issue - How to re-model/edit robot mesh structure #571

Open CreativeNick opened 3 hours ago

CreativeNick commented 3 hours ago

I'm experiencing this bug where the joints/hands of my robot are infinitely spinning when I have self-collisions enabled in bimanual_allegro.py.

@register_agent()
class Bimanual_Allegro(BaseAgent):
    uid = "Bimanual_Allegro"
    urdf_path = "assets/urdf/ur5e_allegro/robots/dual_ur5e_allegro_inertia_changed.urdf"
    fix_root_link = True
    disable_self_collisions = False # Set to True to disable self-collision
    arm_qpos = np.zeros(12)
    arm_qpos[::2] = left_arm_init_qpos
    arm_qpos[1::2] = right_arm_init_qpos

   ...

I'm thinking this is most likely due to the mesh structure of the robot (especially at the joints) clipping/colliding into each other. So when the robot begins moving and certain parts near the joints come into contact, they'll collide and cause a positive feedback loop of the joints spinning uncontrollably in one direction. This severely impacts accuracy and success rate and basically flatlines it to 0.

I'd like to edit and re-model the collision meshes at these areas and was wondering if you could provide some advice/insight on what would be the best way fix this issue? Is it better to edit the collision mesh .STL files (folder linked here) in Blender or edit the dual_ur5e_allegro_inertia_changed.urdf file? Or is there perhaps another solution that's more straight forward?

Thank you!

Here's a video demonstrating the bug:

https://github.com/user-attachments/assets/3b242536-6a8a-4972-954f-540a01867e06

StoneT2000 commented 2 hours ago

First try pip installing the latest git commit of maniskill, there may be some changes that could help.

Otherwise I recommend first running some random actions and opening the viewer and checking which contacts are occurring.

If there are contacts occurring that make no sense (eg 1 finger hitting the robot arm), you can create a .srdg file of the same base name as the urdf and add some rules for which links can't collide. I recommend checking out eg the Fetch robots .srdf file for an example usage

Using blender to model collision meshes is also possible but usually a last resort

StoneT2000 commented 2 hours ago

Also in the viewer i recommend clicking the robot and toggling on collision view to see what the collision mesh looks like

CreativeNick commented 34 minutes ago

I pip installed the latest git commit of maniskill (via running pip install git+https://github.com/haosulab/ManiSkill.git) but the issue still stands. Here's part of view_ycb_env.py that runs the random actions:

obs, _ = env.reset(seed=0)  # reset with a seed for determinism
done = False
while not done:
    action = env.action_space.sample()
    obs, reward, terminated, truncated, info = env.step(action)
    img = env.render()

I'm running python env_utils/view_ycb_env.py to view the environments while running random actions.

Here's a video of the collision meshes with self-collisions ENABLED. I'm not too sure how to interpret this since I don't think there are any weird contacts. The joints for the "hands" seem to be the ones that rotate the most, at the very beginning you can see that they rotate almost immediately and stop because they are blocked by the hand colliding with the rest of the arm.

https://github.com/user-attachments/assets/118c8d65-7637-44c6-a173-068232fb8f96

For comparison, here's a video of the collision meshes with self-collisions DISABLED. (The viewport was also a lot smoother which makes sense since it doesn't need to calculate self-collisions):

https://github.com/user-attachments/assets/eaa83aa4-8d42-4637-8532-2b47c37486f6