Page 1 of 1

Objects snapping into equilibrium position

Posted: Tue Oct 12, 2021 6:54 pm
by jparaujo
The "Hello Bullet World!" example from the Quickstart Guide with the R2D2 URDF runs fine. Changing that to the "objects/mug.urdf" file and keeping the default orientation at first seems to have no impact. However, if the initial orientation of the mug is changed, then it will snap back into the default orientation as if it was being pulled by a magnet (see; I use the mouse to move slightly the mug; the rest is the Bullet's doing). So far I haven't found any explanation for this in the documentation or the forums. Why does this happen, and how can I disable it?

Here is the code I'm using

Code: Select all

import pybullet as p
import pybullet_data

physicsClient = p.connect(p.GUI) # or p.DIRECT for non-graphical version
p.setAdditionalSearchPath(pybullet_data.getDataPath()) #optionally
planeId = p.loadURDF("plane.urdf")
startPos = [0,0,1]
startOrientation = [1, 0, 0, 0] # p.getQuaternionFromEuler([0,0,0])
boxId = p.loadURDF("objects/mug.urdf",startPos, startOrientation)
#set the center of mass frame (loadURDF sets base link frame) startPos/Orn
p.resetBasePositionAndOrientation(boxId, startPos, startOrientation)
logID = p.startStateLogging(p.STATE_LOGGING_VIDEO_MP4, "snapping.mp4")
for i in range (2000):
cubePos, cubeOrn = p.getBasePositionAndOrientation(boxId)