Skip to content

Commit 69f610f

Browse files
author
Peter
committed
test with more menagerie models
1 parent 17f1085 commit 69f610f

File tree

4 files changed

+61
-48
lines changed

4 files changed

+61
-48
lines changed

.github/workflows/python-package.yml

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ jobs:
3030
python -m pip install .[test]
3131
python -m pip install flake8 pytest
3232
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
33+
- name: Clone mujoco_menagerie repository into the tests/ folder
34+
run: |
35+
git clone https://github.com/google-deepmind/mujoco_menagerie
36+
working-directory: ${{ runner.workspace }}/pytorch_kinematics/tests
3337
- name: Lint with flake8
3438
run: |
3539
# stop the build if there are Python syntax errors or undefined names
@@ -38,35 +42,4 @@ jobs:
3842
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
3943
- name: Test with pytest
4044
run: |
41-
pytest
42-
43-
test-shadow-hand:
44-
45-
runs-on: ubuntu-latest
46-
47-
steps:
48-
- uses: actions/checkout@v3
49-
- name: Install dependencies
50-
run: |
51-
python -m pip install --upgrade pip
52-
python -m pip install .[test]
53-
python -m pip install pytest
54-
- name: Clone mujoco_menagerie repository
55-
run: |
56-
git clone https://github.com/google-deepmind/mujoco_menagerie
57-
working-directory: ${{ runner.workspace }}
58-
59-
- name: Debug
60-
run: |
61-
tree
62-
working-directory: ${{ runner.workspace }}
63-
64-
- name: Copy test_shadow_hand.py to mujoco_menagerie/shadow_hand
65-
run: |
66-
cp pytorch_kinematics/tests/menagerie_test_shadow_hand.py mujoco_menagerie/shadow_hand/test_shadow_hand.py
67-
working-directory: ${{ runner.workspace }}
68-
69-
- name: Run test_shadow_hand.py
70-
run: |
71-
pytest test_shadow_hand.py
72-
working-directory: ${{ runner.workspace }}/mujoco_menagerie/shadow_hand
45+
pytest

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@
33
__pycache__
44
temp*
55
build
6-
dist
6+
dist
7+
# These are cloned/generated when testing with mujoco
8+
tests/MUJOCO_LOG.TXT
9+
tests/mujoco_menagerie/
10+

tests/menagerie_test_shadow_hand.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

tests/test_menagerie.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import os
2+
import pathlib
3+
4+
import numpy as np
5+
6+
import pytorch_kinematics as pk
7+
8+
# Find all files named "scene*.xml" in the "mujoco_menagerie" directory
9+
_MENAGERIE_ROOT = pathlib.Path(__file__).parent / 'mujoco_menagerie'
10+
_XMLS_AND_BODIES = {
11+
# 'agility_cassie/scene.xml': 'cassie-pelvis', # not supported because it has a ball joint
12+
'anybotics_anymal_b/scene.xml': 'base',
13+
'anybotics_anymal_c/scene.xml': 'base',
14+
'franka_emika_panda/scene.xml': 'link0',
15+
'google_barkour_v0/scene.xml': 'chassis',
16+
'google_barkour_v0/scene_barkour.xml': 'chassis',
17+
# 'hello_robot_stretch/scene.xml': 'base_link', # not supported because it has composite joints
18+
'kuka_iiwa_14/scene.xml': 'base',
19+
'rethink_robotics_sawyer/scene.xml': 'base',
20+
'robotiq_2f85/scene.xml': 'base_mount',
21+
'robotis_op3/scene.xml': 'body_link',
22+
'shadow_hand/scene_left.xml': 'lh_forearm',
23+
'shadow_hand/scene_right.xml': 'rh_forearm',
24+
'ufactory_xarm7/scene.xml': 'link_base',
25+
'unitree_a1/scene.xml': 'trunk',
26+
'unitree_go1/scene.xml': 'trunk',
27+
'universal_robots_ur5e/scene.xml': 'base',
28+
'wonik_allegro/scene_left.xml': 'palm',
29+
'wonik_allegro/scene_right.xml': 'palm',
30+
}
31+
32+
33+
def test_menagerie():
34+
for xml_filename, body in _XMLS_AND_BODIES.items():
35+
xml_filename = _MENAGERIE_ROOT / xml_filename
36+
xml_dir = xml_filename.parent
37+
# Menagerie files assume the current working directory is the directory of the scene.xml
38+
os.chdir(xml_dir)
39+
with xml_filename.open('r') as f:
40+
xml = f.read()
41+
chain = pk.build_chain_from_mjcf(xml, body)
42+
print(xml_filename)
43+
print("=" * 32)
44+
print(f"\t {chain.get_frame_names()}")
45+
print(f"\t {chain.get_joint_parameter_names()}")
46+
th = np.zeros(len(chain.get_joint_parameter_names()))
47+
fk_dict = chain.forward_kinematics(th, end_only=True)
48+
49+
50+
if __name__ == '__main__':
51+
test_menagerie()

0 commit comments

Comments
 (0)