Physics engine selection

Typically: "How do I... ", "How can I... " questions
Post Reply
SevenTRI
Posts: 15
Joined: 19 Mar 2022, 10:32

Physics engine selection

Post by SevenTRI »

Hello,

I would like to realize a palletizing task of goods with high accuracy, similar to the demo “ur5WithRgGrasping”. Uniquely, adjacent goods need to be aligned rather than cross-placed as in “ur5WithRgGrasping”. The stacking of goods in the vertical direction poses a challenge to the physics engine selection. There are two reasons:

1. Comparatively speaking, Bullet2.78 is better to ensure the stability of the end of the robot arm, other physical engines will lead to end jitter. Since I installed the camera at the end, there can be no shake at the end. So, I had to use Bullet 2.78. By the way, I used a suction pad as the end-effector.
2. As the number of stacked goods increases, in Bullet2.78, when the stack reaches the sixth piece, the vertical stack of goods begins to tilt and eventually collapse. It seems to be stacked very neatly and accurately, so the collapse of the stack is not caused by the robot arm operation but by the physics engine. Further, in Bullet2.83, the stack does not collapse, but I can not choose Bullet2.83 for the first reason.

So, how do I keep the end of the arm stable and the stack from collapsing at the same time? Any suggestions would be appreciated. Thanks in advance.

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

Re: Physics engine selection

Post by coppelia »

Hello,

jitter usually means that masses/inertia are too light, and/or proportions between them is too large. Each physics engine will react differently. Make sure to read on design considerations 7&8 for additional details.

Then, stability of stacked items can be improved in various ways, usually:
  • use some large linear/angular damping for the item to be stacked.
  • increase friction
  • make sure to use primitive shapes, e.g. a cuboid instead of a convex box, or a random mesh
  • eventually turn a dynamic shape into a static shape, if its position/orientation hasn't changed since x ms
To turn a dynamic shape into a static shape when it hasn't moved for a while, you can use a code similar to following (orientation change is not taken into account):

Code: Select all

function sysCall_init()
    self=sim.getObject('.')
    lastPos=sim.getObjectPosition(self,-1)
    lastMove=sim.getSystemTimeInMs(-1)
    distTol=0.001
    timeTol=1000
end

function sysCall_sensing()
    local t=sim.getSystemTimeInMs(-1)
    local pos=sim.getObjectPosition(self,-1)
    local dx={pos[1]-lastPos[1],pos[2]-lastPos[2],pos[3]-lastPos[3]}
    local dxx=math.sqrt(dx[1]*dx[1]+dx[2]*dx[2]+dx[3]*dx[3])
    if dxx<0.001 then
        if t-lastMove>timeTol then
            sim.setObjectInt32Param(self,sim.shapeintparam_static,1)
        end
    else
        lastMove=t
        lastPos=pos
    end
end
Cheers

SevenTRI
Posts: 15
Joined: 19 Mar 2022, 10:32

Re: Physics engine selection

Post by SevenTRI »

Physics engine selection
Last edited by SevenTRI on 03 Apr 2022, 13:12, edited 1 time in total.

SevenTRI
Posts: 15
Joined: 19 Mar 2022, 10:32

Re: Physics engine selection

Post by SevenTRI »

coppelia wrote: 01 Apr 2022, 14:19 Hello,

jitter usually means that masses/inertia are too light, and/or proportions between them is too large. Each physics engine will react differently. Make sure to read on design considerations 7&8 for additional details.

Then, stability of stacked items can be improved in various ways, usually:
  • use some large linear/angular damping for the item to be stacked.
  • increase friction
  • make sure to use primitive shapes, e.g. a cuboid instead of a convex box, or a random mesh
  • eventually turn a dynamic shape into a static shape, if its position/orientation hasn't changed since x ms
To turn a dynamic shape into a static shape when it hasn't moved for a while, you can use a code similar to following (orientation change is not taken into account):

Code: Select all

function sysCall_init()
    self=sim.getObject('.')
    lastPos=sim.getObjectPosition(self,-1)
    lastMove=sim.getSystemTimeInMs(-1)
    distTol=0.001
    timeTol=1000
end

function sysCall_sensing()
    local t=sim.getSystemTimeInMs(-1)
    local pos=sim.getObjectPosition(self,-1)
    local dx={pos[1]-lastPos[1],pos[2]-lastPos[2],pos[3]-lastPos[3]}
    local dxx=math.sqrt(dx[1]*dx[1]+dx[2]*dx[2]+dx[3]*dx[3])
    if dxx<0.001 then
        if t-lastMove>timeTol then
            sim.setObjectInt32Param(self,sim.shapeintparam_static,1)
        end
    else
        lastMove=t
        lastPos=pos
    end
end
Cheers

Hello, thank you for your reply. You've been a great help to me.

However, sorry to bother you again. You gave suggestions in terms of both eliminating jitter and improving stability. I've only tried improving stability so far. The stability problem was solved, but a new arisen question needs to be confirmed with you. And Here I report my experimental results to you.

First of all, in my scene, the stacked objects are 0.2*0.1*0.05(/m) rectangles using primitive shapes.

1. about “using a large linear/angular damping”: I can only increase up to 0.5, otherwise it seems as if the rectangles are fixed in the scene, and suction cups can not suck them away.

2. about “increasing the friction”: I am using 1e3. but the stacked rectangles will still collapse.

3. about “eventually turn a dynamic shape into a static shape“: this helped me a lot. By the way, after

Code: Select all

sim.setObjectInt32Param(self,sim.shapeintparam_static,1)
I need to add the code

Code: Select all

 sim.resetDynamicObject(bricks[i])
The new problem I encountered is that after modifying the dynamic properties of the object during the simulation, the properties can't be restored after the simulation is over. That is, before the simulation starts, the dynamic properties of the rectangles in the scene are static. After these properties have been modified from dynamic to static, they cannot be recovered to dynamic after the simulation is over.
I have used the following code, and it did work well. To make better use of this simulation platform, I would like to confirm that this is the correct operation to restore the initial settings of the scene when the simulation ends. Thanks in advance.

Code: Select all

function sysCall_cleanup() 
    for i=1,6,1 do  -- total number
            sim.setObjectInt32Parameter(block[i],sim.shapeintparam_static,0)
            sim.resetDynamicObject(block[i])
    end
end

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

Re: Physics engine selection

Post by coppelia »

Yes, that is the correct approach to use a clean-up section to restore properties that wouldn't automatically be restored.

Cheers

SevenTRI
Posts: 15
Joined: 19 Mar 2022, 10:32

Re: Physics engine selection

Post by SevenTRI »

coppelia wrote: 04 Apr 2022, 12:10 Yes, that is the correct approach to use a clean-up section to restore properties that wouldn't automatically be restored.

Cheers
You're one in a million. Thanks for everything.

Post Reply