GCC Code Coverage Report


Directory: ./
File: bindings/python/algorithm/expose-frames-derivatives.cpp
Date: 2025-04-30 16:14:33
Exec Total Coverage
Lines: 28 40 70.0%
Branches: 24 80 30.0%

Line Branch Exec Source
1 //
2 // Copyright (c) 2020 INRIA
3 //
4
5 #include <boost/python/tuple.hpp>
6
7 #include "pinocchio/bindings/python/algorithm/algorithms.hpp"
8 #include "pinocchio/algorithm/frames-derivatives.hpp"
9
10 #include "pinocchio/bindings/python/utils/model-checker.hpp"
11
12 namespace pinocchio
13 {
14 namespace python
15 {
16 namespace bp = boost::python;
17
18 3 bp::tuple getFrameVelocityDerivatives_proxy1(
19 const context::Model & model,
20 context::Data & data,
21 const context::Model::FrameIndex frame_id,
22 ReferenceFrame rf)
23 {
24 typedef context::Data::Matrix6x Matrix6x;
25
26
2/4
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
3 Matrix6x partial_dq(Matrix6x::Zero(6, model.nv));
27
2/4
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
3 Matrix6x partial_dv(Matrix6x::Zero(6, model.nv));
28
29
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 getFrameVelocityDerivatives(model, data, frame_id, rf, partial_dq, partial_dv);
30
31
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
6 return bp::make_tuple(partial_dq, partial_dv);
32 3 }
33
34 bp::tuple getFrameVelocityDerivatives_proxy2(
35 const context::Model & model,
36 context::Data & data,
37 const context::Model::JointIndex joint_id,
38 const context::SE3 & placement,
39 ReferenceFrame rf)
40 {
41 typedef context::Data::Matrix6x Matrix6x;
42
43 Matrix6x partial_dq(Matrix6x::Zero(6, model.nv));
44 Matrix6x partial_dv(Matrix6x::Zero(6, model.nv));
45
46 getFrameVelocityDerivatives(model, data, joint_id, placement, rf, partial_dq, partial_dv);
47
48 return bp::make_tuple(partial_dq, partial_dv);
49 }
50
51 3 bp::tuple getFrameAccelerationDerivatives_proxy1(
52 const context::Model & model,
53 context::Data & data,
54 const context::Model::FrameIndex frame_id,
55 ReferenceFrame rf)
56 {
57 typedef context::Data::Matrix6x Matrix6x;
58
59
2/4
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
3 Matrix6x v_partial_dq(Matrix6x::Zero(6, model.nv));
60
2/4
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
3 Matrix6x a_partial_dq(Matrix6x::Zero(6, model.nv));
61
2/4
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
3 Matrix6x a_partial_dv(Matrix6x::Zero(6, model.nv));
62
2/4
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
3 Matrix6x a_partial_da(Matrix6x::Zero(6, model.nv));
63
64
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 getFrameAccelerationDerivatives(
65 model, data, frame_id, rf, v_partial_dq, a_partial_dq, a_partial_dv, a_partial_da);
66
67
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
6 return bp::make_tuple(v_partial_dq, a_partial_dq, a_partial_dv, a_partial_da);
68 3 }
69
70 bp::tuple getFrameAccelerationDerivatives_proxy2(
71 const context::Model & model,
72 context::Data & data,
73 const context::Model::JointIndex joint_id,
74 const context::SE3 & placement,
75 ReferenceFrame rf)
76 {
77 typedef context::Data::Matrix6x Matrix6x;
78
79 Matrix6x v_partial_dq(Matrix6x::Zero(6, model.nv));
80 Matrix6x a_partial_dq(Matrix6x::Zero(6, model.nv));
81 Matrix6x a_partial_dv(Matrix6x::Zero(6, model.nv));
82 Matrix6x a_partial_da(Matrix6x::Zero(6, model.nv));
83
84 getFrameAccelerationDerivatives(
85 model, data, joint_id, placement, rf, v_partial_dq, a_partial_dq, a_partial_dv,
86 a_partial_da);
87
88 return bp::make_tuple(v_partial_dq, a_partial_dq, a_partial_dv, a_partial_da);
89 }
90
91 72 void exposeFramesDerivatives()
92 {
93 using namespace Eigen;
94
95
1/2
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
72 bp::def(
96 "getFrameVelocityDerivatives", getFrameVelocityDerivatives_proxy1,
97
1/2
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
144 bp::args("model", "data", "frame_id", "reference_frame"),
98 "Computes the partial derivatives of the spatial velocity of a given frame with respect "
99 "to\n"
100 "the joint configuration and velocity and returns them as a tuple.\n"
101 "The partial derivatives can be either expressed in the LOCAL frame of the joint, in the "
102 "LOCAL_WORLD_ALIGNED frame or in the WORLD coordinate frame depending on the value of "
103 "reference_frame.\n"
104 "You must first call computeForwardKinematicsDerivatives before calling this function.\n\n"
105 "Parameters:\n"
106 "\tmodel: model of the kinematic tree\n"
107 "\tdata: data related to the model\n"
108 "\tframe_id: index of the frame\n"
109 "\treference_frame: reference frame in which the resulting derivatives are expressed\n",
110 72 mimic_not_supported_function<>(0));
111
112
1/2
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
72 bp::def(
113 "getFrameVelocityDerivatives", getFrameVelocityDerivatives_proxy2,
114
1/2
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
144 bp::args("model", "data", "joint_id", "placement", "reference_frame"),
115 "Computes the partial derivatives of the spatial velocity of a frame given by its relative "
116 "placement, with respect to\n"
117 "the joint configuration and velocity and returns them as a tuple.\n"
118 "The partial derivatives can be either expressed in the LOCAL frame of the joint, in the "
119 "LOCAL_WORLD_ALIGNED frame or in the WORLD coordinate frame depending on the value of "
120 "reference_frame.\n"
121 "You must first call computeForwardKinematicsDerivatives before calling this function.\n\n"
122 "Parameters:\n"
123 "\tmodel: model of the kinematic tree\n"
124 "\tdata: data related to the model\n"
125 "\tjoint_id: index of the joint\n"
126 "\tplacement: placement of the Frame w.r.t. the joint frame.\n"
127 "\treference_frame: reference frame in which the resulting derivatives are expressed\n",
128 72 mimic_not_supported_function<>(0));
129
130
1/2
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
72 bp::def(
131 "getFrameAccelerationDerivatives", getFrameAccelerationDerivatives_proxy1,
132
1/2
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
144 bp::args("model", "data", "frame_id", "reference_frame"),
133 "Computes the partial derivatives of the spatial acceleration of a given frame with "
134 "respect to\n"
135 "the joint configuration, velocity and acceleration and returns them as a tuple.\n"
136 "The partial derivatives can be either expressed in the LOCAL frame of the joint, in the "
137 "LOCAL_WORLD_ALIGNED frame or in the WORLD coordinate frame depending on the value of "
138 "reference_frame.\n"
139 "You must first call computeForwardKinematicsDerivatives before calling this function.\n\n"
140 "Parameters:\n"
141 "\tmodel: model of the kinematic tree\n"
142 "\tdata: data related to the model\n"
143 "\tframe_id: index of the frame\n"
144 "\treference_frame: reference frame in which the resulting derivatives are expressed\n",
145 72 mimic_not_supported_function<>(0));
146
147
1/2
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
72 bp::def(
148 "getFrameAccelerationDerivatives", getFrameAccelerationDerivatives_proxy2,
149
1/2
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
144 bp::args("model", "data", "joint_id", "placement", "reference_frame"),
150 "Computes the partial derivatives of the spatial acceleration of a frame given by its "
151 "relative placement, with respect to\n"
152 "the joint configuration, velocity and acceleration and returns them as a tuple.\n"
153 "The partial derivatives can be either expressed in the LOCAL frame of the joint, in the "
154 "LOCAL_WORLD_ALIGNED frame or in the WORLD coordinate frame depending on the value of "
155 "reference_frame.\n"
156 "You must first call computeForwardKinematicsDerivatives before calling this function.\n\n"
157 "Parameters:\n"
158 "\tmodel: model of the kinematic tree\n"
159 "\tdata: data related to the model\n"
160 "\tjoint_id: index of the joint\n"
161 "\tplacement: placement of the Frame w.r.t. the joint frame.\n"
162 "\treference_frame: reference frame in which the resulting derivatives are expressed\n",
163 72 mimic_not_supported_function<>(0));
164 72 }
165
166 } // namespace python
167 } // namespace pinocchio
168