File: test_dart_loader.py

package info (click to toggle)
dart 6.12.1%2Bdfsg4-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 57,000 kB
  • sloc: cpp: 269,461; python: 3,911; xml: 1,273; sh: 404; makefile: 30
file content (69 lines) | stat: -rw-r--r-- 2,192 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import platform

import pytest
import dartpy
from dartpy.utils import DartLoader
import os

from tests.util import get_asset_path


def test_parse_skeleton_non_existing_path_returns_null():
    assert os.path.isfile(get_asset_path('skel/cubes.skel')) is True
    loader = DartLoader()
    assert loader.parseSkeleton(get_asset_path('skel/test/does_not_exist.urdf')) is None


def test_parse_skeleton_invalid_urdf_returns_null():
    loader = DartLoader()
    assert loader.parseSkeleton(get_asset_path('urdf/invalid.urdf')) is None


def test_parse_skeleton_missing_mesh_returns_null():
    loader = DartLoader()
    assert loader.parseSkeleton(get_asset_path('urdf/missing_mesh.urdf')) is None


def test_parse_skeleton_invalid_mesh_returns_null():
    loader = DartLoader()
    assert loader.parseSkeleton(get_asset_path('urdf/invalid_mesh.urdf')) is None


def test_parse_skeleton_missing_package_returns_null():
    loader = DartLoader()
    assert loader.parseSkeleton(get_asset_path('urdf/missing_package.urdf')) is None


def test_parse_skeleton_loads_primitive_geometry():
    loader = DartLoader()
    assert loader.parseSkeleton(get_asset_path('urdf/test/primitive_geometry.urdf')) is not None


# Failing with following errors:
# TypeError: No to_python (by-value) converter found for C++ type: std::shared_ptr<dart::simulation::World>
#
# def test_parse_world():
#     loader = DartLoader()
#     assert loader.parseWorld(get_asset_path('urdf/testWorld.urdf')) is not None


def test_parse_joint_properties():
    loader = DartLoader()
    robot = loader.parseSkeleton(get_asset_path('urdf/test/joint_properties.urdf'))
    assert robot is not None

#    joint1 = robot.getJoint(1)
#    assert joint1 is not None
#    assert joint1.getDampingCoefficient(0) == pytest.approx(1.2, 1e-12)
#    assert joint1.getCoulombFriction(0) == pytest.approx(2.3, 1e-12)

#    joint2 = robot.getJoint(2)
#    assert joint2 is not None
#    assert joint2.getPositionLowerLimit(0) == -float("inf")
#    assert joint2.getPositionUpperLimit(0) == float("inf")
#    if not platform.linux_distribution()[1] == '14.04':
#        assert joint2.isCyclic(0)


if __name__ == "__main__":
    pytest.main()