Skip to content

Commit 4e9bb4a

Browse files
GiulioRomualdiStéphane Caron
authored andcommitted
Implement the unit test for the iDynTree loader
1 parent 9400d8a commit 4e9bb4a

File tree

4 files changed

+71
-3
lines changed

4 files changed

+71
-3
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
strategy:
6666
matrix:
6767
python-version: ["3.8"]
68-
loader: ["mujoco", "pinocchio", "pybullet", "robomeshcat", "yourdfpy"]
68+
loader: ["mujoco", "pinocchio", "pybullet", "robomeshcat", "yourdfpy", "idyntree"]
6969

7070
steps:
7171
- name: "Checkout sources"

tests/loaders/test_idyntree.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Copyright 2022 Giulio Romualdi
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
import unittest
19+
20+
from robot_descriptions._descriptions import DESCRIPTIONS
21+
22+
from robot_descriptions.loaders.idyntree import load_robot_description
23+
24+
class TestiDynTree(unittest.TestCase):
25+
26+
"""
27+
Check that all descriptions are loaded properly in iDynTree.
28+
"""
29+
30+
@staticmethod
31+
def get_test_for_description(description: str):
32+
"""
33+
Get test function for a given description.
34+
35+
Args:
36+
description: Name of the description.
37+
38+
Returns:
39+
Test function for that description.
40+
"""
41+
42+
def test(self):
43+
load_robot_description(description)
44+
45+
return test
46+
47+
# Add a test function for each URDF description
48+
for name, description in DESCRIPTIONS.items():
49+
if description.has_urdf:
50+
setattr(
51+
TestiDynTree,
52+
f"test_{name}",
53+
TestiDynTree.get_test_for_description(name),
54+
)

tests/test_loaders.py

100644100755
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434
from robot_descriptions.loaders.yourdfpy import (
3535
load_robot_description as load_yourdfpy,
3636
)
37-
37+
from robot_descriptions.loaders.idyntree import (
38+
load_robot_description as load_idyntree,
39+
)
3840

3941
class TestLoaders(unittest.TestCase):
4042

@@ -58,3 +60,6 @@ def test_robomeshcat(self):
5860

5961
def test_yourdfpy(self):
6062
self.assertIsNotNone(load_yourdfpy("upkie_description"))
63+
64+
def test_idyntree(self):
65+
self.assertIsNotNone(load_idyntree("upkie_description"))

tox.ini

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tox]
22
isolated_build = True
3-
envlist = coverage,lint,loader-{mujoco,pinocchio,pybullet,robomeshcat,yourdfpy}
3+
envlist = coverage,lint,loader-{mujoco,pinocchio,pybullet,robomeshcat,yourdfpy,idyntree}
44

55
[gh-actions]
66
python =
@@ -14,6 +14,7 @@ deps =
1414
coverage
1515
mujoco >=2.2.1
1616
pin >=2.6.10
17+
idyntree >= 5.0.1
1718
pybullet >=3.2.5
1819
robomeshcat >= 1.0.4
1920
yourdfpy >=0.0.52
@@ -30,6 +31,7 @@ deps =
3031
mujoco >=2.2.1
3132
mypy
3233
pin >=2.6.10
34+
idyntree >= 5.0.1
3335
pybullet >=3.2.5
3436
pylint
3537
robomeshcat >= 1.0.4
@@ -78,6 +80,13 @@ deps =
7880
commands =
7981
pytest --import-mode=importlib tests/loaders/test_yourdfpy.py
8082

83+
[testenv:loader-idyntree]
84+
deps =
85+
pytest
86+
idyntree >= 5.0.1
87+
commands =
88+
pytest --import-mode=importlib tests/loaders/test_idyntree.py
89+
8190
[flake8]
8291
max-line-length = 88
8392

0 commit comments

Comments
 (0)