1 |
|
|
// |
2 |
|
|
// Copyright (c) 2018-2021 CNRS INRIA |
3 |
|
|
// |
4 |
|
|
|
5 |
|
|
#include "pinocchio/bindings/python/algorithm/algorithms.hpp" |
6 |
|
|
#include "pinocchio/algorithm/kinematics-derivatives.hpp" |
7 |
|
|
#include "pinocchio/algorithm/center-of-mass-derivatives.hpp" |
8 |
|
|
|
9 |
|
|
#include <boost/python/tuple.hpp> |
10 |
|
|
|
11 |
|
|
namespace pinocchio |
12 |
|
|
{ |
13 |
|
|
namespace python |
14 |
|
|
{ |
15 |
|
|
namespace bp = boost::python; |
16 |
|
|
|
17 |
|
2 |
bp::tuple getJointVelocityDerivatives_proxy(const Model & model, |
18 |
|
|
Data & data, |
19 |
|
|
const Model::JointIndex jointId, |
20 |
|
|
ReferenceFrame rf) |
21 |
|
|
{ |
22 |
|
|
typedef Data::Matrix6x Matrix6x; |
23 |
|
|
|
24 |
✓✗✓✗
|
4 |
Matrix6x partial_dq(Matrix6x::Zero(6,model.nv)); |
25 |
✓✗✓✗
|
4 |
Matrix6x partial_dv(Matrix6x::Zero(6,model.nv)); |
26 |
|
|
|
27 |
✓✗ |
2 |
getJointVelocityDerivatives(model,data,jointId,rf, |
28 |
|
|
partial_dq,partial_dv); |
29 |
|
|
|
30 |
✓✗ |
4 |
return bp::make_tuple(partial_dq,partial_dv); |
31 |
|
|
} |
32 |
|
|
|
33 |
|
2 |
bp::tuple getJointAccelerationDerivatives_proxy(const Model & model, |
34 |
|
|
Data & data, |
35 |
|
|
const Model::JointIndex jointId, |
36 |
|
|
ReferenceFrame rf) |
37 |
|
|
{ |
38 |
|
|
typedef Data::Matrix6x Matrix6x; |
39 |
|
|
|
40 |
✓✗✓✗
|
4 |
Matrix6x v_partial_dq(Matrix6x::Zero(6,model.nv)); |
41 |
✓✗✓✗
|
4 |
Matrix6x a_partial_dq(Matrix6x::Zero(6,model.nv)); |
42 |
✓✗✓✗
|
4 |
Matrix6x a_partial_dv(Matrix6x::Zero(6,model.nv)); |
43 |
✓✗✓✗
|
4 |
Matrix6x a_partial_da(Matrix6x::Zero(6,model.nv)); |
44 |
|
|
|
45 |
✓✗ |
2 |
getJointAccelerationDerivatives(model,data,jointId,rf, |
46 |
|
|
v_partial_dq,a_partial_dq, |
47 |
|
|
a_partial_dv,a_partial_da); |
48 |
|
|
|
49 |
✓✗ |
4 |
return bp::make_tuple(v_partial_dq,a_partial_dq,a_partial_dv,a_partial_da); |
50 |
|
|
} |
51 |
|
|
|
52 |
|
|
Data::Matrix3x getCoMVelocityDerivatives_proxy(const Model & model, |
53 |
|
|
Data & data) |
54 |
|
|
{ |
55 |
|
|
typedef Data::Matrix3x Matrix3x; |
56 |
|
|
Matrix3x partial_dq(Matrix3x::Zero(3,model.nv)); |
57 |
|
|
getCenterOfMassVelocityDerivatives(model,data,partial_dq); |
58 |
|
|
return partial_dq; |
59 |
|
|
} |
60 |
|
|
|
61 |
|
|
|
62 |
|
19 |
void exposeKinematicsDerivatives() |
63 |
|
|
{ |
64 |
|
|
using namespace Eigen; |
65 |
|
|
|
66 |
✓✗ |
19 |
bp::def("computeForwardKinematicsDerivatives", |
67 |
|
|
&computeForwardKinematicsDerivatives<double,0,JointCollectionDefaultTpl,VectorXd,VectorXd,VectorXd>, |
68 |
|
38 |
bp::args("model","data","q","v","a"), |
69 |
|
|
"Computes all the terms required to compute the derivatives of the placement, spatial velocity and acceleration\n" |
70 |
|
|
"for any joint of the model.\n" |
71 |
|
|
"The results are stored in data.\n\n" |
72 |
|
|
"Parameters:\n" |
73 |
|
|
"\tmodel: model of the kinematic tree\n" |
74 |
|
|
"\tdata: data related to the model\n" |
75 |
|
|
"\tq: the joint configuration vector (size model.nq)\n" |
76 |
|
|
"\tv: the joint velocity vector (size model.nv)\n" |
77 |
|
|
"\ta: the joint acceleration vector (size model.nv)\n"); |
78 |
|
|
|
79 |
✓✗ |
19 |
bp::def("getJointVelocityDerivatives", |
80 |
|
|
getJointVelocityDerivatives_proxy, |
81 |
|
38 |
bp::args("model","data","joint_id","reference_frame"), |
82 |
|
|
"Computes the partial derivatives of the spatial velocity of a given joint with respect to\n" |
83 |
|
|
"the joint configuration and velocity and returns them as a tuple.\n" |
84 |
|
|
"The Jacobians can be either expressed in the LOCAL frame of the joint, in the LOCAL_WORLD_ALIGNED frame or in the WORLD coordinate frame depending on the value of reference_frame.\n" |
85 |
|
|
"You must first call computeForwardKinematicsDerivatives before calling this function.\n\n" |
86 |
|
|
"Parameters:\n" |
87 |
|
|
"\tmodel: model of the kinematic tree\n" |
88 |
|
|
"\tdata: data related to the model\n" |
89 |
|
|
"\tjoint_id: index of the joint\n" |
90 |
|
|
"\treference_frame: reference frame in which the resulting derivatives are expressed\n"); |
91 |
|
|
|
92 |
✓✗ |
19 |
bp::def("getJointAccelerationDerivatives", |
93 |
|
|
getJointAccelerationDerivatives_proxy, |
94 |
|
38 |
bp::args("model","data","joint_id","reference_frame"), |
95 |
|
|
"Computes the partial derivatives of the spatial acceleration of a given joint with respect to\n" |
96 |
|
|
"the joint configuration, velocity and acceleration and returns them as a tuple.\n" |
97 |
|
|
"The Jacobians can be either expressed in the LOCAL frame of the joint, in the LOCAL_WORLD_ALIGNED frame or in the WORLD coordinate frame depending on the value of reference_frame.\n" |
98 |
|
|
"You must first call computeForwardKinematicsDerivatives before calling this function.\n\n" |
99 |
|
|
"Parameters:\n" |
100 |
|
|
"\tmodel: model of the kinematic tree\n" |
101 |
|
|
"\tdata: data related to the model\n" |
102 |
|
|
"\tjoint_id: index of the joint\n" |
103 |
|
|
"\treference_frame: reference frame in which the resulting derivatives are expressed\n"); |
104 |
|
|
|
105 |
✓✗ |
19 |
bp::def("getCenterOfMassVelocityDerivatives", |
106 |
|
|
getCoMVelocityDerivatives_proxy, |
107 |
|
38 |
bp::args("model","data"), |
108 |
|
|
"Computes the partial derivaties of the center of mass velocity with respect to\n" |
109 |
|
|
"the joint configuration.\n" |
110 |
|
|
"You must first call computeAllTerms(model,data,q,v) or centerOfMass(model,data,q,v) " |
111 |
|
|
"before calling this function.\n\n" |
112 |
|
|
"Parameters:\n" |
113 |
|
|
"\tmodel: model of the kinematic tree\n" |
114 |
|
|
"\tdata: data related to the model\n"); |
115 |
|
|
|
116 |
|
19 |
} |
117 |
|
|
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
} // namespace python |
121 |
|
|
} // namespace pinocchio |