GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: bindings/python/algorithm/expose-regressor.cpp Lines: 13 20 65.0 %
Date: 2024-01-23 21:41:47 Branches: 7 16 43.8 %

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
    Eigen::MatrixXd bodyRegressor_proxy(const Motion & v, const Motion & a)
14
    {
15
      return bodyRegressor(v,a);
16
    }
17
18
    Eigen::MatrixXd jointBodyRegressor_proxy(const Model & model, Data & data, const JointIndex jointId)
19
    {
20
      return jointBodyRegressor(model,data,jointId);
21
    }
22
23
    Eigen::MatrixXd frameBodyRegressor_proxy(const Model & model, Data & data, const FrameIndex frameId)
24
    {
25
      return frameBodyRegressor(model,data,frameId);
26
    }
27
28
19
    void exposeRegressor()
29
    {
30
      using namespace Eigen;
31
32
19
      bp::def("computeStaticRegressor",
33
              &computeStaticRegressor<double,0,JointCollectionDefaultTpl,VectorXd>,
34
38
              bp::args("model","data","q"),
35
              "Compute the static regressor that links the inertia parameters of the system to its center of mass position,\n"
36
              "store the result in Data and return it.\n\n"
37
              "Parameters:\n"
38
              "\tmodel: model of the kinematic tree\n"
39
              "\tdata: data related to the model\n"
40
              "\tq: the joint configuration vector (size model.nq)\n",
41
              bp::return_value_policy<bp::return_by_value>());
42
43
19
      bp::def("bodyRegressor",
44
              &bodyRegressor_proxy,
45
38
              bp::args("velocity","acceleration"),
46
              "Computes the regressor for the dynamic parameters of a single rigid body.\n"
47
              "The result is such that "
48
              "Ia + v x Iv = bodyRegressor(v,a) * I.toDynamicParameters()\n\n"
49
              "Parameters:\n"
50
              "\tvelocity: spatial velocity of the rigid body\n"
51
              "\tacceleration: spatial acceleration of the rigid body\n");
52
53
19
      bp::def("jointBodyRegressor",
54
              &jointBodyRegressor_proxy,
55
38
              bp::args("model","data","joint_id"),
56
              "Compute the regressor for the dynamic parameters of a rigid body attached to a given joint.\n"
57
              "This algorithm assumes RNEA has been run to compute the acceleration and gravitational effects.\n\n"
58
              "Parameters:\n"
59
              "\tmodel: model of the kinematic tree\n"
60
              "\tdata: data related to the model\n"
61
              "\tjoint_id: index of the joint\n");
62
63
19
      bp::def("frameBodyRegressor",
64
              &frameBodyRegressor_proxy,
65
38
              bp::args("model","data","frame_id"),
66
              "Computes the regressor for the dynamic parameters of a rigid body attached to a given frame.\n"
67
              "This algorithm assumes RNEA has been run to compute the acceleration and gravitational effects.\n\n"
68
              "Parameters:\n"
69
              "\tmodel: model of the kinematic tree\n"
70
              "\tdata: data related to the model\n"
71
              "\tframe_id: index of the frame\n");
72
73
19
      bp::def("computeJointTorqueRegressor",
74
              &computeJointTorqueRegressor<double,0,JointCollectionDefaultTpl,VectorXd,VectorXd,VectorXd>,
75
38
              bp::args("model","data","q","v","a"),
76
              "Compute the joint torque regressor that links the joint torque "
77
              "to the dynamic parameters of each link according to the current the robot motion,\n"
78
              "store the result in Data and return it.\n\n"
79
              "Parameters:\n"
80
              "\tmodel: model of the kinematic tree\n"
81
              "\tdata: data related to the model\n"
82
              "\tq: the joint configuration vector (size model.nq)\n"
83
              "\tv: the joint velocity vector (size model.nv)\n"
84
              "\ta: the joint acceleration vector (size model.nv)\n",
85
19
              bp::return_value_policy<bp::return_by_value>());
86
19
    }
87
88
  } // namespace python
89
} // namespace pinocchio