bindings_spatial.py
Go to the documentation of this file.
1 import unittest
2 
3 import numpy as np
4 from numpy.random import rand
5 
6 import pinocchio as pin
7 from pinocchio import skew, unSkew, skewSquare
8 
9 from test_case import PinocchioTestCase
10 
12  def test_skew(self):
13  v3 = rand(3)
14  self.assertApprox(v3, unSkew(skew(v3)))
15  self.assertLess(np.linalg.norm(skew(v3).dot(v3)), 1e-10)
16 
17  x, y, z = tuple(rand(3).tolist())
18  M = np.array([[ 0., x, y],
19  [-x, 0., z],
20  [-y, -z, 0.]])
21  self.assertApprox(M, skew(unSkew(M)))
22 
23  rhs = rand(3)
24  self.assertApprox(np.cross(v3,rhs,axis=0), skew(v3).dot(rhs))
25  self.assertApprox(M.dot(rhs), np.cross(unSkew(M),rhs,axis=0))
26 
27  x, y, z = tuple(v3.tolist())
28  self.assertApprox(skew(v3), np.array([[0, -z, y], [z, 0, -x], [-y, x, 0]]))
29 
30  def skewSquare(self):
31  v3 = rand(3)
32 
33  Mss = skewSquare(v3)
34 
35  Ms = skew(v3)
36  Mss_ref = Ms.dot(Ms)
37 
38  self.assertApprox(Mss,Mss_ref)
39 
40 if __name__ == '__main__':
41  unittest.main()
def assertApprox(self, a, b, eps=1e-6)
Definition: test_case.py:10
Eigen::Matrix< typename Matrix3::Scalar, 3, 1, Matrix3::Options > unSkew(const Matrix3 &mat)
Definition: expose-skew.cpp:32


pinocchio
Author(s):
autogenerated on Tue Jun 1 2021 02:45:02