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
p.setGravity(0,0,-10)
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):
p.stepSimulation()
time.sleep(1./240.)
p.stopStateLogging(logID)
cubePos, cubeOrn = p.getBasePositionAndOrientation(boxId)
print(cubePos,cubeOrn)
p.disconnect()