kinematics-derivatives.py
Go to the documentation of this file.
1 import pinocchio as pin
2 import numpy as np
3 
4 # Create model and data
5 
6 model = pin.buildSampleModelHumanoidRandom()
7 data = model.createData()
8 
9 # Set bounds (by default they are undefinded)
10 
11 model.lowerPositionLimit = -np.ones((model.nq, 1))
12 model.upperPositionLimit = np.ones((model.nq, 1))
13 
14 q = pin.randomConfiguration(model) # joint configuration
15 v = np.random.rand(model.nv, 1) # joint velocity
16 a = np.random.rand(model.nv, 1) # joint acceleration
17 
18 # Evaluate all the terms required by the kinematics derivatives
19 
20 pin.computeForwardKinematicsDerivatives(model, data, q, v, a)
21 
22 # Evaluate the derivatives for a precise joint (e.g. rleg6_joint)
23 
24 joint_name = "rleg6_joint"
25 joint_id = model.getJointId(joint_name)
26 
27 # Derivatives of the spatial velocity with respect to the joint configuration and velocity vectors
28 
29 (dv_dq, dv_dv) = pin.getJointVelocityDerivatives(
30  model, data, joint_id, pin.ReferenceFrame.WORLD
31 )
32 # or to get them in the LOCAL frame of the joint
33 (dv_dq_local, dv_dv_local) = pin.getJointVelocityDerivatives(
34  model, data, joint_id, pin.ReferenceFrame.LOCAL
35 )
36 
37 # Derivatives of the spatial acceleration of the joint with respect to the joint configuration, velocity and acceleration vectors
38 
39 (dv_dq, da_dq, da_dv, da_da) = pin.getJointAccelerationDerivatives(
40  model, data, joint_id, pin.ReferenceFrame.WORLD
41 )
42 # or to get them in the LOCAL frame of the joint
43 (dv_dq_local, da_dq_local, da_dv_local, da_da_local) = (
44  pin.getJointAccelerationDerivatives(model, data, joint_id, pin.ReferenceFrame.LOCAL)
45 )


pinocchio
Author(s):
autogenerated on Sat Jun 1 2024 02:40:37