Closed JanGlinko closed 2 years ago
Hey @JanGlinko,
it seems you are using MESH
collision_shapes. Although these collision shapes are very exact, they are also very unstable.
I would therefore recommend you to use "CONVEX_HULL"
collision shapes instead. If you have objects that are very non-convex, you can also use convex decomposition to get more exact but still stable collision shapes.
See this tutorial for more details: https://github.com/DLR-RM/BlenderProc/blob/main/docs/tutorials/physics.md#the-collision_shape-parameter
Let me know if that fixes your problem
Thank You for the response. Its little more stable. But still, in the first frame all items "jumps" a little. Should i change some physics parameters like mass, friction and dumping?
So the first frame is before physics positioning and the second one is afterwards or what exactly do the screen shots show? And you are now using CONVEX_HULL collision shapes, right?
Can you try loading only one object and see if the positioning works then?
Yes, the first frame is just after spawning on the surface and second one is just after running physics simulation. Yes, im using CONVEX_HULL. I think there is a problem with my models, because some of them are stable and some not
If you want, you can upload one model which does not work and I can take a look.
Apart from that, you could run your script in debug mode and then replace simulate_physics_and_fix_final_poses(
with simulate_physics(
. In this way, you should be able to see the full simulation in the blender GUI and not only the final fixed poses.
Hey @JanGlinko,
I cannot really reproduce this behaviour. In my test, the apple is placed nicely on the table:
I used your code, just replaced "MESH"
with "CONVEX_HULL"
collision shapes and used a simple cube as table (as I do not have Box_stol.blend):
table = blenderproc.object.create_primitive("CUBE")
table.set_scale([1, 1, 0.1])
Maybe there is something wrong with your table?
I was analyzing simulation of physics step by step and i have found that some objects' origins are not aligned with objects, and it makes simulation unstable.
Creating table with Your code helped with the jumping. I also set collision_margin=0
Thanks!
Yeah we know about the instabilities of misplaced object origins. Thats we shift origins to the center of mass before the simulation: https://github.com/DLR-RM/BlenderProc/blob/main/blenderproc/python/object/PhysicsSimulation.py#L95 This is then undone after the simulation.
Describe the bug After spawning items using function
blenderproc.object.sample_poses_on_surface
physics simulation seems unstable.General Information
blenderproc run generate_dataset.py dataset
parser = argparse.ArgumentParser() parser.add_argument('output', nargs='?') args = parser.parse_args()
def get_all_items_list(path_json: str) -> dict: with open(path_json, 'r') as f: return json.load(f)
def choose_items_to_load(items: dict, n: int) -> (list, list): ids = list(set(items.values())) ids_list = list(np.random.choice(ids, n)) ids_list = list(map(int, ids_list))
def sample_pose_wrapper(obj_parent: blenderproc.types.MeshObject, d1_max, d2_max): def sample_pose_inside(obj_sampled_inside): obj_sampled_inside.set_location(blenderproc.sampler.upper_region( objects_to_sample_on=obj_parent, min_height=0.2, max_height=0.4, use_ray_trace_check=True, upper_dir=[0.0, 0.0, 1.0], use_upper_dir=True )) obj_sampled_inside.set_rotation_euler(np.random.uniform([0, 0, 0], [d1_max, d2_max, np.pi * 2]))
def main(): n = 1 all_items = get_all_items_list("/home/avena/software/items3/loading_dictionaries/items_dictionary.json") consumables_items = get_all_items_list("/home/avena/software/items3/loading_dictionaries/consumables_dictionary.json") containers_items = get_all_items_list("/home/avena/software/items3/loading_dictionaries/containers_dictionary.json") plane_containers = {} capable_containers = {} for k, v in containers_items.items(): if "bowl" in k or "plate" in k: capable_containers[k] = v else: plane_containers[k] = v
if name == 'main': main()