The method of processing joint of "slide" type ?
Closed this issue · 5 comments
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.
So how to process joint of "slide" type?
Should probably be enough to change this line
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