<commit_before>#ifndef __se3_python_algorithm_hpp__
#define __se3_python_algorithm_hpp__

#include <eigenpy/exception.hpp>
#include <eigenpy/eigenpy.hpp>

#include "pinocchio/python/model.hpp"
#include "pinocchio/python/data.hpp"

#include "pinocchio/algorithm/rnea.hpp"
#include "pinocchio/algorithm/crba.hpp"
#include "pinocchio/algorithm/kinematics.hpp"
#include "pinocchio/algorithm/jacobian.hpp"
#include "pinocchio/algorithm/center-of-mass.hpp"

namespace se3
{
  namespace python
  {
    struct AlgorithmsPythonVisitor
    {
      typedef typename eigenpy::UnalignedEquivalent<Eigen::VectorXd>::type VectorXd_fx;

      static Eigen::VectorXd rnea_proxy( const ModelHandler& model, 
			      DataHandler & data,
			      const VectorXd_fx & q,
			      const VectorXd_fx & qd,
			      const VectorXd_fx & qdd )
      { return rnea(*model,*data,q,qd,qdd); }

      static Eigen::MatrixXd crba_proxy( const ModelHandler& model, 
					 DataHandler & data,
					 const VectorXd_fx & q )
      { return crba(*model,*data,q); }

      static Eigen::VectorXd com_proxy( const ModelHandler& model, 
					DataHandler & data,
					const VectorXd_fx & q )
      { return centerOfMass(*model,*data,q); }

      static Eigen::MatrixXd Jcom_proxy( const ModelHandler& model, 
					 DataHandler & data,
					 const VectorXd_fx & q )
      { return jacobianCenterOfMass(*model,*data,q); }

      static Eigen::MatrixXd jacobian_proxy( const ModelHandler& model, 
					     DataHandler & data,
					     Model::Index jointId,
					     const VectorXd_fx & q,
					     bool local )
      {
	Eigen::MatrixXd J( 6,model->nv ); J.setZero();
	computeJacobians( *model,*data,q );
	if(local) getJacobian<true> (*model, *data, jointId, J);
	else getJacobian<false> (*model, *data, jointId, J);
	return J;
      }

      static void kinematics_proxy( const ModelHandler& model, 
				    DataHandler & data,
				    const VectorXd_fx & q,
				    const VectorXd_fx & qdot )
      {
	kinematics( *model,*data,q,qdot );
      }



      /* --- Expose --------------------------------------------------------- */
      static void expose()
      {
	bp::def("rnea",rnea_proxy,
		bp::args("Model","Data",
			 "Configuration q (size Model::nq)",
			 "Velocity qdot (size Model::nv)",
			 "Acceleration qddot (size Model::nv)"),
		"Compute the RNEA, put the result in Data and return it.");

	bp::def("crba",rnea_proxy,
		bp::args("Model","Data",
			 "Configuration q (size Model::nq)"),
		"Compute CRBA, put the result in Data and return it.");<commit_msg>Python: coorection of the CRBA bindings.<commit_after>#ifndef __se3_python_algorithm_hpp__
#define __se3_python_algorithm_hpp__

#include <eigenpy/exception.hpp>
#include <eigenpy/eigenpy.hpp>

#include "pinocchio/python/model.hpp"
#include "pinocchio/python/data.hpp"

#include "pinocchio/algorithm/rnea.hpp"
#include "pinocchio/algorithm/crba.hpp"
#include "pinocchio/algorithm/kinematics.hpp"
#include "pinocchio/algorithm/jacobian.hpp"
#include "pinocchio/algorithm/center-of-mass.hpp"

namespace se3
{
  namespace python
  {
    struct AlgorithmsPythonVisitor
    {
      typedef typename eigenpy::UnalignedEquivalent<Eigen::VectorXd>::type VectorXd_fx;

      static Eigen::VectorXd rnea_proxy( const ModelHandler& model, 
			      DataHandler & data,
			      const VectorXd_fx & q,
			      const VectorXd_fx & qd,
			      const VectorXd_fx & qdd )
      { return rnea(*model,*data,q,qd,qdd); }

      static Eigen::MatrixXd crba_proxy( const ModelHandler& model, 
					 DataHandler & data,
					 const VectorXd_fx & q )
      {
	data->M.fill(0);
	return crba(*model,*data,q); 
      }

      static Eigen::VectorXd com_proxy( const ModelHandler& model, 
					DataHandler & data,
					const VectorXd_fx & q )
      { return centerOfMass(*model,*data,q); }

      static Eigen::MatrixXd Jcom_proxy( const ModelHandler& model, 
					 DataHandler & data,
					 const VectorXd_fx & q )
      { return jacobianCenterOfMass(*model,*data,q); }

      static Eigen::MatrixXd jacobian_proxy( const ModelHandler& model, 
					     DataHandler & data,
					     Model::Index jointId,
					     const VectorXd_fx & q,
					     bool local )
      {
	Eigen::MatrixXd J( 6,model->nv ); J.setZero();
	computeJacobians( *model,*data,q );
	if(local) getJacobian<true> (*model, *data, jointId, J);
	else getJacobian<false> (*model, *data, jointId, J);
	return J;
      }

      static void kinematics_proxy( const ModelHandler& model, 
				    DataHandler & data,
				    const VectorXd_fx & q,
				    const VectorXd_fx & qdot )
      {
	kinematics( *model,*data,q,qdot );
      }



      /* --- Expose --------------------------------------------------------- */
      static void expose()
      {
	bp::def("rnea",rnea_proxy,
		bp::args("Model","Data",
			 "Configuration q (size Model::nq)",
			 "Velocity qdot (size Model::nv)",
			 "Acceleration qddot (size Model::nv)"),
		"Compute the RNEA, put the result in Data and return it.");

	bp::def("crba",crba_proxy,
		bp::args("Model","Data",
			 "Configuration q (size Model::nq)"),
		"Compute CRBA, put the result in Data and return it.");
{'fraction_non_alphanumeric': 0.14461598592925543, 'fraction_numerical': 0.0017588430721125659, 'mean_word_length': 3.0141176470588236, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5185256', 'n_tokens_mistral': 1889, 'n_tokens_neox': 1663, 'n_words': 377}