From 5cbd9ebd61c547c24a5aff8729238bffbac675a4 Mon Sep 17 00:00:00 2001 From: jcarpent <jcarpent@laas.fr> Date: Thu, 24 May 2018 23:36:33 +0200 Subject: [PATCH] [Python] Expose computeABADerivatives --- bindings/python/CMakeLists.txt | 1 + bindings/python/algorithm/algorithms.hpp | 1 + .../algorithm/expose-aba-derivatives.cpp | 52 +++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 bindings/python/algorithm/expose-aba-derivatives.cpp diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt index c9a4c9bd2..a90a2bf80 100644 --- a/bindings/python/CMakeLists.txt +++ b/bindings/python/CMakeLists.txt @@ -90,6 +90,7 @@ SET(${PROJECT_NAME}_PYTHON_SOURCES algorithm/expose-rnea.cpp algorithm/expose-rnea-derivatives.cpp algorithm/expose-aba.cpp + algorithm/expose-aba-derivatives.cpp algorithm/expose-jacobian.cpp algorithm/expose-joints.cpp algorithm/expose-energy.cpp diff --git a/bindings/python/algorithm/algorithms.hpp b/bindings/python/algorithm/algorithms.hpp index 781689d2a..43f0f25b0 100644 --- a/bindings/python/algorithm/algorithms.hpp +++ b/bindings/python/algorithm/algorithms.hpp @@ -42,6 +42,7 @@ namespace se3 void exposeRegressor(); void exposeRNEADerivatives(); + void exposeABADerivatives(); void exposeAlgorithms(); diff --git a/bindings/python/algorithm/expose-aba-derivatives.cpp b/bindings/python/algorithm/expose-aba-derivatives.cpp new file mode 100644 index 000000000..4658caa19 --- /dev/null +++ b/bindings/python/algorithm/expose-aba-derivatives.cpp @@ -0,0 +1,52 @@ +// +// Copyright (c) 2018 CNRS +// +// This file is part of Pinocchio +// Pinocchio is free software: you can redistribute it +// and/or modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation, either version +// 3 of the License, or (at your option) any later version. +// +// Pinocchio is distributed in the hope that it will be +// useful, but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Lesser Public License for more details. You should have +// received a copy of the GNU Lesser General Public License along with +// Pinocchio If not, see +// <http://www.gnu.org/licenses/>. + +#include "pinocchio/bindings/python/algorithm/algorithms.hpp" +#include "pinocchio/algorithm/aba-derivatives.hpp" + +namespace se3 +{ + namespace python + { + void computeABADerivativesDefault(const Model & model, Data & data, + const Eigen::VectorXd & q, + const Eigen::VectorXd & v, + const Eigen::VectorXd & tau) + { + computeABADerivatives(model,data,q,v,tau); + } + + void exposeABADerivatives() + { + using namespace Eigen; + typedef container::aligned_vector<Force> ForceAlignedVector; + + bp::def("computeABADerivatives", + computeABADerivativesDefault, + bp::args("Model","Data", + "Configuration q (size Model::nq)", + "Velocity v (size Model::nv)", + "Torque tau (size Model::nv)"), + "Computes the ABA derivatives, put the result in data.ddq_dq, data.ddq_dv and data.Minv\n" + "which correspond to the partial derivatives of the joint acceleration vector output with respect to the joint configuration,\n" + "velocity and torque vectors."); + } + + + + } // namespace python +} // namespace se3 -- GitLab