| Directory: | ./ |
|---|---|
| File: | bindings/python/algorithm/expose-regressor.cpp |
| Date: | 2025-02-12 21:03:38 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 23 | 26 | 88.5% |
| Branches: | 12 | 24 | 50.0% |
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2018-2020 CNRS INRIA | ||
| 3 | // | ||
| 4 | |||
| 5 | #include "pinocchio/bindings/python/algorithm/algorithms.hpp" | ||
| 6 | #include "pinocchio/algorithm/regressor.hpp" | ||
| 7 | |||
| 8 | namespace pinocchio | ||
| 9 | { | ||
| 10 | namespace python | ||
| 11 | { | ||
| 12 | |||
| 13 | 1 | context::MatrixXs bodyRegressor_proxy(const context::Motion & v, const context::Motion & a) | |
| 14 | { | ||
| 15 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | return bodyRegressor(v, a); |
| 16 | } | ||
| 17 | |||
| 18 | 1 | context::MatrixXs jointBodyRegressor_proxy( | |
| 19 | const context::Model & model, context::Data & data, const JointIndex jointId) | ||
| 20 | { | ||
| 21 | 1 | return jointBodyRegressor(model, data, jointId); | |
| 22 | } | ||
| 23 | |||
| 24 | 1 | context::MatrixXs frameBodyRegressor_proxy( | |
| 25 | const context::Model & model, context::Data & data, const FrameIndex frameId) | ||
| 26 | { | ||
| 27 | 1 | return frameBodyRegressor(model, data, frameId); | |
| 28 | } | ||
| 29 | |||
| 30 | 69 | void exposeRegressor() | |
| 31 | { | ||
| 32 | typedef context::Scalar Scalar; | ||
| 33 | typedef context::VectorXs VectorXs; | ||
| 34 | enum | ||
| 35 | { | ||
| 36 | Options = context::Options | ||
| 37 | }; | ||
| 38 | |||
| 39 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | bp::def( |
| 40 | "computeStaticRegressor", | ||
| 41 | &computeStaticRegressor<Scalar, Options, JointCollectionDefaultTpl, VectorXs>, | ||
| 42 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
138 | bp::args("model", "data", "q"), |
| 43 | "Compute the static regressor that links the inertia parameters of the system to its " | ||
| 44 | "center of mass position,\n" | ||
| 45 | "store the result in context::Data and return it.\n\n" | ||
| 46 | "Parameters:\n" | ||
| 47 | "\tmodel: model of the kinematic tree\n" | ||
| 48 | "\tdata: data related to the model\n" | ||
| 49 | "\tq: the joint configuration vector (size model.nq)\n", | ||
| 50 | ✗ | bp::return_value_policy<bp::return_by_value>()); | |
| 51 | |||
| 52 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | bp::def( |
| 53 | 138 | "bodyRegressor", &bodyRegressor_proxy, bp::args("velocity", "acceleration"), | |
| 54 | "Computes the regressor for the dynamic parameters of a single rigid body.\n" | ||
| 55 | "The result is such that " | ||
| 56 | "Ia + v x Iv = bodyRegressor(v,a) * I.toDynamicParameters()\n\n" | ||
| 57 | "Parameters:\n" | ||
| 58 | "\tvelocity: spatial velocity of the rigid body\n" | ||
| 59 | "\tacceleration: spatial acceleration of the rigid body\n"); | ||
| 60 | |||
| 61 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | bp::def( |
| 62 | 138 | "jointBodyRegressor", &jointBodyRegressor_proxy, bp::args("model", "data", "joint_id"), | |
| 63 | "Compute the regressor for the dynamic parameters of a rigid body attached to a " | ||
| 64 | "given joint.\n" | ||
| 65 | "This algorithm assumes RNEA has been run to compute the acceleration and " | ||
| 66 | "gravitational effects.\n\n" | ||
| 67 | "Parameters:\n" | ||
| 68 | "\tmodel: model of the kinematic tree\n" | ||
| 69 | "\tdata: data related to the model\n" | ||
| 70 | "\tjoint_id: index of the joint\n"); | ||
| 71 | |||
| 72 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | bp::def( |
| 73 | 138 | "frameBodyRegressor", &frameBodyRegressor_proxy, bp::args("model", "data", "frame_id"), | |
| 74 | "Computes the regressor for the dynamic parameters of a rigid body attached to a " | ||
| 75 | "given frame.\n" | ||
| 76 | "This algorithm assumes RNEA has been run to compute the acceleration and " | ||
| 77 | "gravitational effects.\n\n" | ||
| 78 | "Parameters:\n" | ||
| 79 | "\tmodel: model of the kinematic tree\n" | ||
| 80 | "\tdata: data related to the model\n" | ||
| 81 | "\tframe_id: index of the frame\n"); | ||
| 82 | |||
| 83 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | bp::def( |
| 84 | "computeJointTorqueRegressor", | ||
| 85 | &computeJointTorqueRegressor< | ||
| 86 | Scalar, Options, JointCollectionDefaultTpl, VectorXs, VectorXs, VectorXs>, | ||
| 87 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
138 | bp::args("model", "data", "q", "v", "a"), |
| 88 | "Compute the joint torque regressor that links the joint torque " | ||
| 89 | "to the dynamic parameters of each link according to the current the robot motion,\n" | ||
| 90 | "store the result in context::Data and return it.\n\n" | ||
| 91 | "Parameters:\n" | ||
| 92 | "\tmodel: model of the kinematic tree\n" | ||
| 93 | "\tdata: data related to the model\n" | ||
| 94 | "\tq: the joint configuration vector (size model.nq)\n" | ||
| 95 | "\tv: the joint velocity vector (size model.nv)\n" | ||
| 96 | "\ta: the joint acceleration vector (size model.nv)\n", | ||
| 97 | ✗ | bp::return_value_policy<bp::return_by_value>()); | |
| 98 | |||
| 99 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | bp::def( |
| 100 | "computeKineticEnergyRegressor", | ||
| 101 | &computeKineticEnergyRegressor< | ||
| 102 | Scalar, Options, JointCollectionDefaultTpl, VectorXs, VectorXs>, | ||
| 103 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
138 | bp::args("model", "data", "q", "v"), |
| 104 | "Compute the kinetic energy regressor that links the kinetic energy" | ||
| 105 | "to the dynamic parameters of each link according to the current the robot motion,\n" | ||
| 106 | "store the result in context::Data and return it.\n\n" | ||
| 107 | "Parameters:\n" | ||
| 108 | "\tmodel: model of the kinematic tree\n" | ||
| 109 | "\tdata: data related to the model\n" | ||
| 110 | "\tq: the joint configuration vector (size model.nq)\n" | ||
| 111 | "\tv: the joint velocity vector (size model.nv)\n", | ||
| 112 | ✗ | bp::return_value_policy<bp::return_by_value>()); | |
| 113 | |||
| 114 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | bp::def( |
| 115 | "computePotentialEnergyRegressor", | ||
| 116 | &computePotentialEnergyRegressor<Scalar, Options, JointCollectionDefaultTpl, VectorXs>, | ||
| 117 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
138 | bp::args("model", "data", "q"), |
| 118 | "Compute the potential energy regressor that links the potential energy" | ||
| 119 | "to the dynamic parameters of each link according to the current the robot motion,\n" | ||
| 120 | "store the result in context::Data and return it.\n\n" | ||
| 121 | "Parameters:\n" | ||
| 122 | "\tmodel: model of the kinematic tree\n" | ||
| 123 | "\tdata: data related to the model\n" | ||
| 124 | "\tq: the joint configuration vector (size model.nq)\n", | ||
| 125 | 69 | bp::return_value_policy<bp::return_by_value>()); | |
| 126 | 69 | } | |
| 127 | |||
| 128 | } // namespace python | ||
| 129 | } // namespace pinocchio | ||
| 130 |