Spaces:
Sleeping
Sleeping
Download tests/test_robots.py from JoeTach/cdpr-simulator: direct link, hf CLI and curl.
- Browser
- Download file 1.38 kB
-
https://huggingface.co/spaces/JoeTach/cdpr-simulator/resolve/main/tests/test_robots.py
- Command line
-
hf download hf://spaces/JoeTach/cdpr-simulator/tests/test_robots.py
-
curl -L -o test_robots.py https://huggingface.co/spaces/JoeTach/cdpr-simulator/resolve/main/tests/test_robots.py
1.38 kB
| """Catalog smoke tests: each reference robot is consistent and runnable.""" | |
| from __future__ import annotations | |
| import numpy as np | |
| import pytest | |
| from cdpr.kinematics.inverse import cable_lengths | |
| from cdpr.kinematics.jacobian import structure_matrix | |
| from cdpr.robots import cogiro_class, ipanema_class, planar_translational, point_mass_3d | |
| def reference_robot(request): | |
| return request.param() | |
| def test_cable_count_matches_anchors(reference_robot): | |
| assert reference_robot.geometry.anchors.shape[0] == reference_robot.n_cables | |
| assert reference_robot.geometry.attachments.shape[0] == reference_robot.n_cables | |
| def test_redundancy_nonnegative(reference_robot): | |
| assert reference_robot.redundancy >= 1 | |
| def test_lengths_positive_at_home(reference_robot, home_pose): | |
| L = cable_lengths(home_pose, reference_robot) | |
| assert (L > 0).all() | |
| def test_structure_matrix_full_rank_at_home(reference_robot, home_pose): | |
| W = structure_matrix(home_pose, reference_robot) | |
| assert np.linalg.matrix_rank(W) == reference_robot.dof | |
| def test_inertia_present_and_positive_definite(reference_robot): | |
| I = reference_robot.inertia.inertia | |
| assert np.allclose(I, I.T) | |
| assert (np.linalg.eigvalsh(I) > 0).all() | |