cram2 / pycram

Cognitive Robot Abstract Machine in Python
https://pycram.readthedocs.io/en/latest/index.html
GNU General Public License v3.0
20 stars 40 forks source link

PyBullet crashes with apartment urdf #77

Closed AbhijitVyas closed 3 weeks ago

AbhijitVyas commented 1 year ago

I am trying to test new apartmenet urdf with pyCRAM, here is the code.

import pycram
from pycram.bullet_world import BulletWorld, Object
import pycram.bullet_world_reasoning as btr
from pycram.robot_descriptions.robot_description_handler import InitializedRobotDescription as robot_description
from pycram.designators.motion_designator import MotionDesignatorDescription, MoveArmJointsMotion
from pycram.process_module import simulated_robot, with_simulated_robot
from pycram.language import macros, par
from pycram.designators.location_designator import *
from pycram.designators.action_designator import *
from pycram.designators.object_designator import *
from pycram.resolver.plans import Arms
from pycram.enums import Arms
from pycram.robot_descriptions.robot_description_handler import InitializedRobotDescription as robot_description
import pycram.task
from pycram.resolver.plans import Arms
from pycram.process_module import simulated_robot
import anytree
import pycram.plan_failures

world = BulletWorld()

# spawn robot
pr2 = Object("pr2", "robot", "pr2.urdf")
robot_desig = ObjectDesignatorDescription(names=["pr2"]).resolve()
# spawn apartment
apartment = Object("apartment", "environment", "apartment.urdf")
apartment_desig = ObjectDesignatorDescription(names=['apartment']).resolve()
# spawn Milkbox
milk = Object("milk", "milk", "milk.stl", position=[1.4, 1, 0.95])
milk_desig = ObjectDesignatorDescription(names=["milk"])

I am getting following error:

Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/home/avyas/pyCRAM_ws/src/pycram/src/pycram/bullet_world.py", line 459, in run
    shadow_obj.set_position(bulletworld_obj.get_position())
  File "/home/avyas/pyCRAM_ws/src/pycram/src/pycram/bullet_world.py", line 818, in get_position
    return p.getBasePositionAndOrientation(self.id, physicsClientId=self.world.client_id)[0]
pybullet.error: Not connected to physics server.
/usr/lib/python3/dist-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.26.12) or chardet (3.0.4) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
Traceback (most recent call last):
  File "run.py", line 5, in <module>
    import my_pouring_demo_apartment
  File "/home/avyas/pyCRAM_ws/src/pycram/demos/pycram_bullet_world_demo/my_pouring_demo_apartment.py", line 32, in <module>
    milk = Object("milk", "milk", "milk.stl", position=[1.4, 1, 0.95])
  File "/home/avyas/pyCRAM_ws/src/pycram/src/pycram/bullet_world.py", line 717, in __init__
    self.id, self.path = _load_object(name, path, position, orientation, self.world, color, ignoreCachedFiles)
  File "/home/avyas/pyCRAM_ws/src/pycram/src/pycram/bullet_world.py", line 1300, in _load_object
    raise (e)
  File "/home/avyas/pyCRAM_ws/src/pycram/src/pycram/bullet_world.py", line 1294, in _load_object
    obj = p.loadURDF(path, basePosition=position, baseOrientation=orientation, physicsClientId=world_id)
pybullet.error: Not connected to physics server.
tomsch420 commented 1 year ago

Please also provide the versions of your packages, e. g. the output of pip list

Tigul commented 1 year ago

I can confirm that this error occurs when loading the modified apartment.urdf from the example code. However, I was not able to reproduce the error in any other constellation. What I was able to confirm is that the error occurs when loading the apartment with 16 or more particle.dae and a Static Mesh.

Maybe this is some really weird edge case. In any case I will keep this issue open should this error occur again.

Tigul commented 1 year ago

After more digging I found the root of this error. The problem is that the apartment.urdf has more than 128 links, which can not be handled by PyBullet. https://pybullet.org/Bullet/phpBB3/viewtopic.php?t=12880

Tigul commented 3 weeks ago

Fixed with merge of #196