Object dynamically created never stop moving

Typically: "How do I... ", "How can I... " questions
Post Reply
juhel
Posts: 28
Joined: 22 Nov 2020, 23:10

Object dynamically created never stop moving

Post by juhel »

Hi,

I use the following code to dynamically create a cylinder or a dumbbell.
When I run the simulation for the cylinder, the cylinder falls then quickly stop moving.
When I run the simulation for the dumbbell, it falls too but never stop moving. Its mass is the same than the cylinder one.

Why?

Code: Select all

import random

def sysCall_init():
    sim = require('sim')
    create_objects()

def create_objects():
    # The dumbbell model path
    model_path = 'dumbbell.ttm'
    size = [0.04, 0.13, 0.04]
    mass = 0.22
    # Load a copy of the model
    loaded_object = sim.loadModel(model_path)
    #loaded_object = sim.createPureShape(2, 16, size, mass)
        
    sim.setObjectPosition(loaded_object, -1, [0.1425, 0.4763, 0.145])
    sim.setObjectOrientation(loaded_object, -1, [3.141592 / 2, 0, 0])
    sim.setFloatProperty(loaded_object, 'bullet.angularDamping', 1.99)
    sim.setFloatProperty(loaded_object, 'bullet.linearDamping', 0.99)
    sim.setFloatProperty(loaded_object, 'bullet.frictionOld', 1.99)
    sim.setBoolProperty(loaded_object,'dynamic',True)
    sim.setBoolProperty(loaded_object,'respondable',True)
    sim.resetDynamicObject(loaded_object)
Philippe

coppelia
Site Admin
Posts: 10690
Joined: 14 Dec 2012, 00:25

Re: Object dynamically created never stop moving

Post by coppelia »

Hello,

this is probably because the object your are loading is non-convex. In addition to that, its mass and/or inertia is not appropriate with the physics engine you are currently using. Try to switch to another engine and see the difference.

Otherwise, stick with the current engine (Bullet) and carefully read the design considerations with dynamic simulations.

Cheers

juhel
Posts: 28
Joined: 22 Nov 2020, 23:10

Re: Object dynamically created never stop moving

Post by juhel »

Thank you for your reply.

Why is it a problem to have a non-convex object? How can it be avoided?

And why aren't mass and inertia appropriate for one physics engine (and I suppose for another)? I have little expertise in mechanics, but I think that physics is physics and that the behavior of a simulated object, with a fixed mass and inertia, should not depend on the simulator you use.

Philippe

coppelia
Site Admin
Posts: 10690
Joined: 14 Dec 2012, 00:25

Re: Object dynamically created never stop moving

Post by coppelia »

Each physics engine serves specific purposes. Some are more meant to be used as game engines (less precise but more stable, and faster), others are more fidel to reality but slower (and less stable), etc.

How to avoid non-convex meshes

Cheers

Post Reply