pythonpybullet

Python cannot load URDF file


I have the following code:

import pybullet as p
import time
import pybullet_data

physicsClient = p.connect(p.GUI)
p.setGravity(0,0,-9.81)
planeId = p.loadURDF("plane.urdf")

startPos = [0,0,1]
startOrientation = p.getQuaternionFromEuler([0,0,0])

while True: 
    p.stepSimulation()
    time.sleep(1./240.)
cubePos, cubeOrn = p.getBasePositionAndOrientation(boxId)
print(cubePos,cubeOrn)
p.disconnect()

But this gives me the following error message:

error: Cannot load URDF file.

This is one of the example files from PyBullet itself, so this should be working. In fact it has worked, but I've changed some things on my system since.

How can I make ik work again?

(I use Windows 10, Jupyter notebook / Visual Studio 2019, both don't work)


Solution

  • You are trying to load plane.urdf which is in pybullet data. So adding this line before loading might help -

    p.setAdditionalSearchPath(pybullet_data.getDataPath())