0

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)

Mark
  • 25
  • 5
  • Try supplying the full path to the file. The default is to look for the file in the current working directory, which is often not what novices expect it to be. – BoarGules Sep 28 '21 at 07:37

1 Answers1

3

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())
Vishwas Chepuri
  • 711
  • 2
  • 10
  • I have the same problem with 'p.loadSoftBody'. Do you know a fix for this as well? – Mark Sep 28 '21 at 15:08
  • 1
    If you are trying to load a file from `pybullet_data` above line should solve the problem. Else if you are trying to load a custom urdf file then you need to specify the correct path. – Vishwas Chepuri Sep 28 '21 at 15:38
  • Ok thank you. I'm trying to run this example: https://github.com/bulletphysics/bullet3/blob/master/examples/pybullet/examples/load_soft_body.py However, I get the error message 'Cannot load soft body.' for the bunny. Do you know how to fix this? – Mark Oct 01 '21 at 08:41
  • Do you have `bunny.obj` in your directory. If not, you can download it from [here](https://graphics.stanford.edu/~mdfisher/Data/Meshes/bunny.obj). – Vishwas Chepuri Oct 01 '21 at 20:07