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(model,data,joint_id,pin.ReferenceFrame.WORLD)
30 # or to get them in the LOCAL frame of the joint
31 (dv_dq_local,dv_dv_local) = pin.getJointVelocityDerivatives(model,data,joint_id,pin.ReferenceFrame.LOCAL)
32 
33 # Derivatives of the spatial acceleration of the joint with respect to the joint configuration, velocity and acceleration vectors
34 
35 (dv_dq,da_dq,da_dv,da_da) = pin.getJointAccelerationDerivatives(model,data,joint_id,pin.ReferenceFrame.WORLD)
36 # or to get them in the LOCAL frame of the joint
37 (dv_dq_local,da_dq_local,da_dv_local,da_da_local) = pin.getJointAccelerationDerivatives(model,data,joint_id,pin.ReferenceFrame.LOCAL)


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