haosulab / SAPIEN

SAPIEN Embodied AI Platform
https://sapien.ucsd.edu/
MIT License
430 stars 41 forks source link

Inconsistent simulation results #174

Closed Juzhan closed 1 month ago

Juzhan commented 2 months ago

System:

Describe the bug I want to use sapien as a stability checker for bin-packing, but the final results are not the same when I simulate it multiple times.

To Reproduce Here is my code: https://pastebin.com/fVEdsqxV

Expected behavior I generate a basic movable floor to place the boxes. Each time I want to check the stability of a packing solution, I will clean all the boxes (except the floor), add some new boxes on the floor, then shake the floor for a while, and check each box's final position. I set the same random seed before each stability check. However, the final position of boxes under the same input is not the same. I wonder how to set parameters to ensure consistent simulation results.

Screenshots image

fbxiang commented 1 month ago

The physical simulation is not guaranteed to be deterministic when adding and removing objects. (Each run is deterministic) You can try sapien.physx.set_scene_config(..., enable_enhanced_determinism=True, ...) but it probably will not help in your case. You can also try increasing solver iterations, which also improves the outcome. Overall, since physics is chaotic and any error will be magnified over time, you probably do not want to base your program on a deterministic outcome.

Juzhan commented 1 month ago

Thanks for your advice. I will try it out.