UM-ARM-Lab/pytorch_kinematics

The method of processing joint of "slide" type ?

Closed this issue · 5 comments

c4cld commented

I try to use build_chain_from_mjcf function to read 'roboschool/mujoco_assets/hopper.xml'.

But I got error information as follows:

 File "/root/aliyun/mymirror/test.py", line 121, in test
    chain = pk.build_chain_from_mjcf(open(xml_path).read())
  File "/root/aliyun/pytorch_kinematics/pytorch_kinematics/mjcf.py", line 81, in build_chain_from_mjcf
    _build_chain_recurse(root_frame, root_body)
  File "/root/aliyun/pytorch_kinematics/pytorch_kinematics/mjcf.py", line 48, in _build_chain_recurse
    cur_frame, cur_base = add_composite_joint(root_frame, root_body.joint, base)
  File "/root/aliyun/pytorch_kinematics/pytorch_kinematics/mjcf.py", line 39, in add_composite_joint
    joint=joint_to_joint(joints[0], base)),)
  File "/root/aliyun/pytorch_kinematics/pytorch_kinematics/mjcf.py", line 32, in joint_to_joint
    joint_type=JOINT_TYPE_MAP[joint.type],
KeyError: 'slide'

In "/root/aliyun/pytorch_kinematics/pytorch_kinematics/mjcf.py", I notice that 'JOINT_TYPE_MAP' is defined as a dictionary {'hinge': 'revolute'} at the beginning of mjcf.py. So 'JOINT_TYPE_MAP' can only receive joint of 'hinge' type.

But in 'roboschool/mujoco_assets/hopper.xml' in following figure, there are some joints of "slide" type.
1652669456(1)

So how to process joint of "slide" type?

c4cld commented

@LemonPi @powertj Do you have any advice? Thanks for your help in advance ^_^

Should probably be enough to change this line

JOINT_TYPE_MAP = {'hinge': 'revolute'}

to:

JOINT_TYPE_MAP = {"hinge": "revolute", "slide": "prismatic"}

Though, I decided to convert my mujoco files to urdf using mjcf2urdf.

We are now using dm_control's mjcf parsing library so this should be resolved

Actually this is still a problem my bad; will be resolving this and adding a test for it. For now please consider the mjcf2urdf as johannespitz suggested

I could only ever find "slide" joints defined between the base link and the world (instead of between links), which are ignored by PK. e41f519 should fix their loading