Spaces:
Sleeping
Sleeping
File size: 1,380 Bytes
5f38e95 | 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 | """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
@pytest.fixture(
params=[point_mass_3d, planar_translational, ipanema_class, cogiro_class],
ids=["point-mass", "planar", "ipanema", "cogiro"],
)
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()
|