bindings_kinematics.py
Go to the documentation of this file.
1 import unittest
2 import pinocchio as pin
3 import numpy as np
4 
5 from test_case import PinocchioTestCase
6 
8 
9  def setUp(self):
10  self.model = pin.buildSampleModelHumanoidRandom()
11  self.joint_idx = self.model.getJointId("rarm2_joint") if self.model.existJointName("rarm2_joint") else (self.model.njoints-1)
12 
13  def test_getters(self):
14  data = self.model.createData()
15  q = pin.randomConfiguration(self.model)
16  v = np.random.rand(self.model.nv)
17  a = np.random.rand(self.model.nv)
18  pin.forwardKinematics(self.model, data, q, v, a)
19 
20  T = data.oMi[self.joint_idx]
21 
22  v = pin.getVelocity(self.model, data, self.joint_idx)
23  self.assertApprox(v, data.v[self.joint_idx])
24  v = pin.getVelocity(self.model, data, self.joint_idx, pin.ReferenceFrame.LOCAL)
25  self.assertApprox(v, data.v[self.joint_idx])
26  v = pin.getVelocity(self.model, data, self.joint_idx, pin.ReferenceFrame.WORLD)
27  self.assertApprox(v, data.oMi[self.joint_idx].act(data.v[self.joint_idx]))
28  v = pin.getVelocity(self.model, data, self.joint_idx, pin.ReferenceFrame.LOCAL_WORLD_ALIGNED)
29  self.assertApprox(v, pin.SE3(T.rotation, np.zeros(3)).act(data.v[self.joint_idx]))
30 
31  a = pin.getAcceleration(self.model, data, self.joint_idx)
32  self.assertApprox(a, data.a[self.joint_idx])
33  a = pin.getAcceleration(self.model, data, self.joint_idx, pin.ReferenceFrame.LOCAL)
34  self.assertApprox(a, data.a[self.joint_idx])
35  a = pin.getAcceleration(self.model, data, self.joint_idx, pin.ReferenceFrame.WORLD)
36  self.assertApprox(a, data.oMi[self.joint_idx].act(data.a[self.joint_idx]))
37  a = pin.getAcceleration(self.model, data, self.joint_idx, pin.ReferenceFrame.LOCAL_WORLD_ALIGNED)
38  self.assertApprox(a, pin.SE3(T.rotation, np.zeros(3)).act(data.a[self.joint_idx]))
39 
40  a = pin.getClassicalAcceleration(self.model, data, self.joint_idx)
41  a = pin.getClassicalAcceleration(self.model, data, self.joint_idx, pin.ReferenceFrame.LOCAL)
42  a = pin.getClassicalAcceleration(self.model, data, self.joint_idx, pin.ReferenceFrame.WORLD)
43  a = pin.getClassicalAcceleration(self.model, data, self.joint_idx, pin.ReferenceFrame.LOCAL_WORLD_ALIGNED)
44 
45 if __name__ == '__main__':
46  unittest.main()
def assertApprox(self, a, b, eps=1e-6)
Definition: test_case.py:10
static void act(const Eigen::MatrixBase< Mat > &iV, const ForceDense< ForceDerived > &f, Eigen::MatrixBase< MatRet > const &jF)
Action of a motion set on a force object. The input motion set is represented by a 6xN matrix whose e...


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