google-research / ravens

Train robotic agents to learn pick and place with deep learning for vision-based manipulation in PyBullet. Transporter Nets, CoRL 2020.
https://transporternets.github.io
Apache License 2.0
538 stars 93 forks source link

Running demos other than block-insertion fail on urdf loading #3

Closed ri-ceres closed 3 years ago

ri-ceres commented 3 years ago

This is a great project -- thanks for open-sourcing it! Looking forward to trying it out, however, only the block-insertion demo seems to be working at present. When trying to run demos.py on any other example, relative paths to description files appear to be causing issues resulting in errors.

For example for assembling-kits:

python ravens/demos.py  --assets_root=./ravens/environments/assets/ --disp=True --task=assembling-kits --mode=train --n=10
b3Printf: b3Warning[examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp,152]:

b3Printf: URDF file './ravens/environments/assets/assets/kitting/kit.urdf' not found

Traceback (most recent call last):
  File "ravens/demos.py", line 81, in <module>
    app.run(main)
  File "/home/user/.miniconda/envs/ravens/lib/python3.7/site-packages/absl/app.py", line 303, in run
    _run_main(main, args)
  File "/home/user/.miniconda/envs/ravens/lib/python3.7/site-packages/absl/app.py", line 251, in _run_main
    sys.exit(main(argv))
  File "ravens/demos.py", line 62, in main
    obs = env.reset()
  File "/home/user/.local/lib/python3.7/site-packages/ravens-0.1-py3.7.egg/ravens/environments/environment.py", line 168, in reset
    self.task.reset(self)
  File "/home/user/.local/lib/python3.7/site-packages/ravens-0.1-py3.7.egg/ravens/tasks/assembling_kits.py", line 80, in reset
    urdf = self.fill_template(template, replace)
  File "/home/user/.local/lib/python3.7/site-packages/ravens-0.1-py3.7.egg/ravens/tasks/task.py", line 324, in fill_template
    with open(template, 'r') as file:
FileNotFoundError: [Errno 2] No such file or directory: '/home/user/.local/lib/python3.7/site-packages/ravens-0.1-py3.7.egg/ravens/tasks/../assets/kitting/object-template.urdf'

Have also tried using pip install -e ., but error persists. Example for towers-of-hanoi:

python ravens/demos.py  --assets_root=./ravens/environments/assets/ --disp=True --task=towers-of-hanoi --mode=train --n=10
int args: [CNSFileIO is not enabled in this build.
Oracle demonstration: 1/10
ven = NVIDIA Corporation
ven = NVIDIA Corporation
b3Printf: b3Warning[examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp,152]:

b3Printf: URDF file './ravens/environments/assets/assets/hanoi/stand.urdf' not found

b3Printf: b3Warning[examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp,152]:

b3Printf: URDF file './ravens/environments/assets/assets/hanoi/disk0.urdf' not found

b3Printf: b3Warning[examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp,152]:

b3Printf: URDF file './ravens/environments/assets/assets/hanoi/disk1.urdf' not found

b3Printf: b3Warning[examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp,152]:

b3Printf: URDF file './ravens/environments/assets/assets/hanoi/disk2.urdf' not found

Traceback (most recent call last):
  File "ravens/demos.py", line 81, in <module>
    app.run(main)
  File "/home/user/.miniconda/envs/ravens/lib/python3.7/site-packages/absl/app.py", line 303, in run
    _run_main(main, args)
  File "/home/user/.miniconda/envs/ravens/lib/python3.7/site-packages/absl/app.py", line 251, in _run_main
    sys.exit(main(argv))
  File "ravens/demos.py", line 62, in main
    obs = env.reset()
  File "/home/user/code/ravens/ravens/environments/environment.py", line 173, in reset
    obs, _, _, _ = self.step()
  File "/home/user/code/ravens/ravens/environments/environment.py", line 193, in step
    while not self.is_static:
  File "/home/user/code/ravens/ravens/environments/environment.py", line 111, in is_static
    for i in self.obj_ids['rigid']]
  File "/home/user/code/ravens/ravens/environments/environment.py", line 111, in <listcomp>
    for i in self.obj_ids['rigid']]
TypeError: an integer is required (got type NoneType)

Or sweeping-piles:

python ravens/demos.py  --assets_root=./ravens/environments/assets/ --disp=True --task=sweeping-piles --mode=train --n=10
Traceback (most recent call last):
  File "/home/user/code/ravens/ravens/utils/pybullet_utils.py", line 29, in load_urdf
    return pybullet_client.loadURDF(file_path, *args, **kwargs)
AttributeError: 'str' object has no attribute 'loadURDF'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "ravens/demos.py", line 81, in <module>
    app.run(main)
  File "/home/user/.miniconda/envs/ravens/lib/python3.7/site-packages/absl/app.py", line 303, in run
    _run_main(main, args)
  File "/home/user/.miniconda/envs/ravens/lib/python3.7/site-packages/absl/app.py", line 251, in _run_main
    sys.exit(main(argv))
  File "ravens/demos.py", line 62, in main
    obs = env.reset()
  File "/home/user/code/ravens/ravens/environments/environment.py", line 152, in reset
    self.ee = self.task.ee(self.assets_root, self.ur5, 9, self.obj_ids)
  File "/home/user/code/ravens/ravens/tasks/grippers.py", line 59, in __init__
    os.path.join(self.assets_root, SPATULA_BASE_URDF), pose[0], pose[1])
  File "/home/user/code/ravens/ravens/utils/pybullet_utils.py", line 30, in load_urdf
    except pybullet_client.error:
AttributeError: 'str' object has no attribute 'error'

Note that this has been tested on all tasks listed in the README.md, and the three examples above cover the extent of errors seen in tasks not mentioned.

andyzeng commented 3 years ago

Thanks for testing this out. It looks like we forgot to remove the redundant "assets/" folder from the URDF string paths in the other task definitions. We’ll push a fix soon.

You can temporarily bypass this by deleting "assets/" from the path strings for whichever task you'll need to run. For example, L43 and L72 of ravens/tasks/assembling_kits.py. Same for L35 and L46 of ravens/tasks/towers_of_hanoi.py, and L40 and L51 of ravens/tasks/sweeping_piles.py. Etc...

ri-ceres commented 3 years ago

Yes, it looks like doing a find/replace on on the assets folder works, with one additional change for the path at L323 of ravens/tasks/task.py.

I'll leave this issue open for now since it sounds like you are working on a fix that hasn't been merged yet.

ri-ceres commented 3 years ago

This appears to have been fixed in https://github.com/google-research/ravens/commit/d7f9db3214ed730c6d16e5c248684688555c6d23 .

Thanks!