Verified Commit ac6935dd authored by Justin Carpentier's avatar Justin Carpentier
Browse files

python/algo: expose rnea with external forces expressed as a list

parent b112dc30
//
// Copyright (c) 2015-2019 CNRS INRIA
// Copyright (c) 2015-2020 CNRS INRIA
//
#include "pinocchio/bindings/python/algorithm/algorithms.hpp"
#include "pinocchio/bindings/python/utils/list.hpp"
#include "pinocchio/algorithm/rnea.hpp"
namespace pinocchio
......@@ -10,6 +11,21 @@ namespace pinocchio
namespace python
{
template<typename Scalar, int Options, template<typename,int> class JointCollectionTpl, typename ConfigVectorType, typename TangentVectorType1, typename TangentVectorType2, typename Force>
const typename DataTpl<Scalar,Options,JointCollectionTpl>::TangentVectorType &
rnea_proxy_list(const ModelTpl<Scalar,Options,JointCollectionTpl> & model,
DataTpl<Scalar,Options,JointCollectionTpl> & data,
const Eigen::MatrixBase<ConfigVectorType> & q,
const Eigen::MatrixBase<TangentVectorType1> & v,
const Eigen::MatrixBase<TangentVectorType2> & a,
const bp::list & fext_list)
{
container::aligned_vector<Force> fext;
extract(fext_list,fext);
return rnea(model,data,q.derived(),v.derived(),a.derived(),fext);
}
void exposeRNEA()
{
using namespace Eigen;
......@@ -20,7 +36,7 @@ namespace pinocchio
"Configuration q (size Model::nq)",
"Velocity v (size Model::nv)",
"Acceleration a (size Model::nv)"),
"Compute the RNEA, put the result in Data and return it.",
"Compute the RNEA, store the result in Data and return it.",
bp::return_value_policy<bp::return_by_value>());
bp::def("rnea",
......@@ -33,6 +49,16 @@ namespace pinocchio
"Compute the RNEA with external forces, put the result in Data and return it.",
bp::return_value_policy<bp::return_by_value>());
bp::def("rnea",
&rnea_proxy_list<double,0,JointCollectionDefaultTpl,VectorXd,VectorXd,VectorXd,Force>,
bp::args("Model","Data",
"Configuration q (size Model::nq)",
"Velocity v (size Model::nv)",
"Acceleration a (size Model::nv)",
"List of external forces expressed in the local frame of each joint (size Model::njoints)"),
"Compute the RNEA with external forces, store the result in Data and return it.",
bp::return_value_policy<bp::return_by_value>());
bp::def("nonLinearEffects",
&nonLinearEffects<double,0,JointCollectionDefaultTpl,VectorXd,VectorXd>,
bp::args("Model","Data",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment