2 import pinocchio
as se3
6 print(
"Test Constraint Bound")
12 lb = -1.0 * np.ones(n)
14 ConstBound = tsid.ConstraintBound(
"bounds", lb, ub)
16 assert ConstBound.isBound
17 assert not ConstBound.isEquality
18 assert not ConstBound.isInequality
20 assert ConstBound.rows == n
21 assert ConstBound.cols == n
23 assert lb.all() == ConstBound.lowerBound.all()
24 assert ub.all() == ConstBound.upperBound.all()
27 assert np.linalg.norm(lb - ConstBound.lowerBound, 2) != 0
28 ConstBound.setLowerBound(lb)
29 assert lb.all() == ConstBound.lowerBound.all()
32 assert np.linalg.norm(ub - ConstBound.upperBound, 2) != 0
33 ConstBound.setUpperBound(ub)
34 assert ub.all() == ConstBound.upperBound.all()
35 assert np.linalg.norm(ub - ConstBound.upperBound, 2) < tol
38 print(
"Test Constraint Equality")
44 equality = tsid.ConstraintEquality(
"equality", A, b)
46 assert not equality.isBound
47 assert equality.isEquality
48 assert not equality.isInequality
50 assert equality.rows == m
51 assert equality.cols == n
53 assert np.linalg.norm(A - equality.matrix, 2) < tol
54 assert np.linalg.norm(b - equality.vector, 2) < tol
57 assert np.linalg.norm(b - equality.vector, 2) != 0
59 assert np.linalg.norm(b - equality.vector, 2) < tol
62 assert np.linalg.norm(A - equality.matrix, 2) != 0
64 assert np.linalg.norm(A - equality.matrix, 2) < tol
67 print(
"Test Constraint Inequality")
75 inequality = tsid.ConstraintInequality(
"inequality", A, lb, ub)
77 assert not inequality.isBound
78 assert not inequality.isEquality
79 assert inequality.isInequality
81 assert inequality.rows == m
82 assert inequality.cols == n
85 assert np.linalg.norm(lb - inequality.lowerBound, 2) != 0
86 inequality.setLowerBound(lb)
87 assert np.linalg.norm(lb - inequality.lowerBound, 2) < tol
90 assert np.linalg.norm(A - inequality.matrix, 2) != 0
91 inequality.setMatrix(A)
92 assert np.linalg.norm(A - inequality.matrix, 2) < tol
94 print(
"All test is done")