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