kinematics-derivatives.py
Go to the documentation of this file.
1 import numpy as np
2 import pinocchio as pin
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
28 # velocity vectors.
29 
30 (dv_dq, dv_dv) = pin.getJointVelocityDerivatives(
31  model, data, joint_id, pin.ReferenceFrame.WORLD
32 )
33 # or to get them in the LOCAL frame of the joint
34 (dv_dq_local, dv_dv_local) = pin.getJointVelocityDerivatives(
35  model, data, joint_id, pin.ReferenceFrame.LOCAL
36 )
37 
38 # Derivatives of the spatial acceleration of the joint with respect to the joint
39 # configuration, velocity and acceleration vectors.
40 
41 (dv_dq, da_dq, da_dv, da_da) = pin.getJointAccelerationDerivatives(
42  model, data, joint_id, pin.ReferenceFrame.WORLD
43 )
44 # or to get them in the LOCAL frame of the joint
45 (dv_dq_local, da_dq_local, da_dv_local, da_da_local) = (
46  pin.getJointAccelerationDerivatives(model, data, joint_id, pin.ReferenceFrame.LOCAL)
47 )


pinocchio
Author(s):
autogenerated on Fri Nov 1 2024 02:41:46