Commit 07f85061 authored by Justin Carpentier's avatar Justin Carpentier Committed by GitHub
Browse files

Merge pull request #353 from jcarpent/devel

Clean Python bindings by removing useless proxy
parents b4b14fb3 5f0b0f62
......@@ -23,24 +23,15 @@ namespace se3
namespace python
{
static Eigen::MatrixXd aba_proxy(const Model & model,
Data & data,
const Eigen::VectorXd & q,
const Eigen::VectorXd & v,
const Eigen::VectorXd & tau)
{
aba(model,data,q,v,tau);
return data.ddq;
}
void exposeABA()
{
bp::def("aba",aba_proxy,
bp::def("aba",&aba,
bp::args("Model","Data",
"Joint configuration q (size Model::nq)",
"Joint velocity v (size Model::nv)",
"Joint torque tau (size Model::nv)"),
"Compute ABA, put the result in Data::ddq and return it.");
"Compute ABA, put the result in Data::ddq and return it.",
bp::return_value_policy<bp::return_by_value>());
}
......
......@@ -59,14 +59,6 @@ namespace se3
updateKinematics);
}
static Data::Matrix3x
Jcom_proxy(const Model& model,
Data & data,
const Eigen::VectorXd & q)
{
return jacobianCenterOfMass(model,data,q);
}
void exposeCOM()
{
bp::def("centerOfMass",com_0_proxy,
......@@ -92,10 +84,11 @@ namespace se3
"Computes the center of mass position, velocity and acceleration by storing the result in Data"
"and returns the center of mass position of the full model expressed in the world frame.");
bp::def("jacobianCenterOfMass",Jcom_proxy,
bp::def("jacobianCenterOfMass",jacobianCenterOfMass,
bp::args("Model","Data",
"Joint configuration q (size Model::nq)"),
"Computes the jacobian of the center of mass, puts the result in Data and return it.");
"Computes the jacobian of the center of mass, puts the result in Data and return it.",
bp::return_value_policy<bp::return_by_value>());
}
} // namespace python
......
......@@ -33,15 +33,6 @@ namespace se3
return data.M;
}
static Data::Matrix6x ccrba_proxy(const Model & model,
Data & data,
const Eigen::VectorXd & q,
const Eigen::VectorXd & v)
{
ccrba(model,data,q,v);
return data.Ag;
}
void exposeCRBA()
{
bp::def("crba",crba_proxy,
......@@ -49,11 +40,12 @@ namespace se3
"Joint configuration q (size Model::nq)"),
"Computes CRBA, put the result in Data and return it.");
bp::def("ccrba",ccrba_proxy,
bp::def("ccrba",ccrba,
bp::args("Model","Data",
"Joint configuration q (size Model::nq)",
"Joint velocity v (size Model::nv)"),
"Computes the centroidal mapping, the centroidal momentum and the Centroidal Composite Rigid Body Inertia, puts the result in Data and returns the centroidal mapping.");
"Computes the centroidal mapping, the centroidal momentum and the Centroidal Composite Rigid Body Inertia, puts the result in Data and returns the centroidal mapping.",
bp::return_value_policy<bp::return_by_value>());
}
......
......@@ -22,34 +22,16 @@ namespace se3
{
namespace python
{
static Eigen::MatrixXd fd_llt_proxy(const Model & model,
Data & data,
const Eigen::VectorXd & q,
const Eigen::VectorXd & v,
const Eigen::VectorXd & tau,
const Eigen::MatrixXd & J,
const Eigen::VectorXd & gamma,
const bool update_kinematics = true)
{
forwardDynamics(model,data,q,v,tau,J,gamma,update_kinematics);
return data.ddq;
}
static Eigen::MatrixXd id_llt_proxy(const Model & model,
Data & data,
const Eigen::VectorXd & q,
const Eigen::VectorXd & v_before,
const Eigen::MatrixXd & J,
const double r_coeff,
const bool update_kinematics = true)
{
impulseDynamics(model,data,q,v_before,J,r_coeff,update_kinematics);
return data.dq_after;
}
void exposeDynamics()
{
bp::def("forwardDynamics",fd_llt_proxy,
using namespace Eigen;
bp::def("forwardDynamics",
(const VectorXd & (*)(const Model &, Data &,
const VectorXd &, const VectorXd &, const VectorXd &,
const MatrixXd &, const VectorXd &, const bool))
&forwardDynamics,
bp::args("Model","Data",
"Joint configuration q (size Model::nq)",
"Joint velocity v (size Model::nv)",
......@@ -57,16 +39,22 @@ namespace se3
"Contact Jacobian J (size nb_constraint * Model::nv)",
"Contact drift gamma (size nb_constraint)",
"Update kinematics (if true, it updates the dynamic variable according to the current state)"),
"Solves the forward dynamics problem with contacts, puts the result in Data::ddq and return it. The contact forces are stored in data.lambda_c");
"Solves the forward dynamics problem with contacts, puts the result in Data::ddq and return it. The contact forces are stored in data.lambda_c",
bp::return_value_policy<bp::return_by_value>());
bp::def("impactDynamics",id_llt_proxy,
bp::def("impactDynamics",
(const VectorXd & (*)(const Model &, Data &,
const VectorXd &, const VectorXd &,
const MatrixXd &, const double, const bool))
&impulseDynamics,
bp::args("Model","Data",
"Joint configuration q (size Model::nq)",
"Joint velocity before impact v_before (size Model::nv)",
"Contact Jacobian J (size nb_constraint * Model::nv)",
"Coefficient of restitution r_coeff (0 = rigid impact; 1 = fully elastic impact.",
"Update kinematics (if true, it updates only the joint space inertia matrix)"),
"Solve the impact dynamics problem with contacts, put the result in Data::dq_after and return it. The contact impulses are stored in data.impulse_c");
"Solve the impact dynamics problem with contacts, put the result in Data::dq_after and return it. The contact impulses are stored in data.impulse_c",
bp::return_value_policy<bp::return_by_value>());
}
} // namespace python
......
......@@ -22,26 +22,10 @@ namespace se3
{
namespace python
{
static double kineticEnergy_proxy(const Model & model,
Data & data,
const Eigen::VectorXd & q,
const Eigen::VectorXd & v,
const bool update_kinematics = true)
{
return kineticEnergy(model,data,q,v,update_kinematics);
}
static double potentialEnergy_proxy(const Model & model,
Data & data,
const Eigen::VectorXd & q,
const bool update_kinematics = true)
{
return potentialEnergy(model,data,q,update_kinematics);
}
void exposeEnergy()
{
bp::def("kineticEnergy",kineticEnergy_proxy,
bp::def("kineticEnergy",kineticEnergy,
bp::args("Model","Data",
"Joint configuration q (size Model::nq)",
"Joint velocity v (size Model::nv)",
......@@ -50,7 +34,7 @@ namespace se3
"given joint configuration and velocity and stores the result "
" in data.kinetic_energy. By default, the kinematics of model is updated.");
bp::def("potentialEnergy",potentialEnergy_proxy,
bp::def("potentialEnergy",potentialEnergy,
bp::args("Model","Data",
"Joint configuration q (size Model::nq)",
"Update kinematics (bool)"),
......
......@@ -26,7 +26,7 @@ namespace se3
static Data::Matrix6x frame_jacobian_proxy(const Model & model,
Data & data,
const Eigen::VectorXd & q,
Model::FrameIndex frame_id,
const Model::FrameIndex frame_id,
bool local,
bool update_geometry
)
......@@ -42,20 +42,20 @@ namespace se3
return J;
}
static void frames_fk_0_proxy(const Model & model,
Data & data,
const Eigen::VectorXd & q
)
{
framesForwardKinematics( model,data,q );
}
void exposeFramesAlgo()
{
bp::def("framesKinematics",frames_fk_0_proxy,
bp::def("framesKinematics",
(void (*)(const Model &, Data &))&framesForwardKinematics,
bp::args("Model","Data"),
"Computes the placements of all the operational frames according to the current joint placement stored in data"
"and put the results in data.");
bp::def("framesKinematics",
(void (*)(const Model &, Data &, const Eigen::VectorXd &))&framesForwardKinematics,
bp::args("Model","Data",
"Configuration q (size Model::nq)"),
"Compute the placements of all the operational frames "
"Update first the placement of the joints according to the given configuration value."
"And computes the placements of all the operational frames"
"and put the results in data.");
bp::def("frameJacobian",frame_jacobian_proxy,
......
......@@ -23,105 +23,60 @@ namespace se3
namespace python
{
static void updateGeometryPlacements_proxy(const Model & model,
Data & data,
const GeometryModel & model_geom,
GeometryData & data_geom,
const Eigen::VectorXd & q
)
{
return updateGeometryPlacements(model, data, model_geom, data_geom, q);
}
#ifdef WITH_HPP_FCL
static bool computeCollision_proxy(const GeometryModel & model_geom,
GeometryData & data_geom,
const PairIndex & pairId)
{
return computeCollision(model_geom, data_geom, pairId);
}
static bool computeCollisions_proxy(const GeometryModel & model_geom,
GeometryData & data_geom,
const bool stopAtFirstCollision)
{
return computeCollisions(model_geom, data_geom, stopAtFirstCollision);
}
static bool computeGeometryAndCollisions_proxy(const Model & model,
Data & data,
const GeometryModel & model_geom,
GeometryData & data_geom,
const Eigen::VectorXd & q,
const bool stopAtFirstCollision)
{
return computeCollisions(model,data,model_geom, data_geom, q, stopAtFirstCollision);
}
static fcl::DistanceResult computeDistance_proxy(const GeometryModel & model_geom,
GeometryData & data_geom,
const PairIndex & pairId)
{
return computeDistance(model_geom, data_geom, pairId);
}
static std::size_t computeDistances_proxy(const GeometryModel & model_geom,
GeometryData & data_geom)
{
return computeDistances(model_geom, data_geom);
}
static std::size_t computeGeometryAndDistances_proxy(const Model & model,
Data & data,
const GeometryModel & model_geom,
GeometryData & data_geom,
const Eigen::VectorXd & q
)
{
return computeDistances<true>(model, data, model_geom, data_geom, q);
}
#endif // WITH_HPP_FCL
void exposeGeometryAlgo()
{
bp::def("updateGeometryPlacements",updateGeometryPlacements_proxy,
bp::args("Model", "Data", "GeometryModel", "GeometryData", "Configuration q (size Model::nq)"),
using namespace Eigen;
bp::def("updateGeometryPlacements",
(void (*)(const Model &, Data &, const GeometryModel &, GeometryData &, const VectorXd &))&updateGeometryPlacements,
bp::args("model", "data", "geometry model", "geometry data", "Configuration vector q (size Model::nq)"),
"Update the placement of the collision objects according to the current configuration."
"The algorithm also updates the current placement of the joint in Data."
);
bp::def("updateGeometryPlacements",
(void (*)(const Model &, const Data &, const GeometryModel &, GeometryData &))&updateGeometryPlacements,
bp::args("model", "data", "geometry model", "geometry data"),
"Update the placement of the collision objects according to the current joint placement stored in data."
);
#ifdef WITH_HPP_FCL
bp::def("computeCollision", computeCollision_proxy,
bp::args("GoometryModel", "GeometryData", "pairIndex"),
bp::def("computeCollision",computeCollision,
bp::args("geometry model", "geometry data", "collision pair index"),
"Check if the collision objects of a collision pair for a given Geometry Model and Data are in collision."
"The collision pair is given by the two index of the collision objects."
);
bp::def("computeCollisions",computeCollisions_proxy,
bp::args("GeometryData","bool"),
bp::def("computeCollisions",
(bool (*)(const GeometryModel &, GeometryData &, const bool))&computeCollisions,
bp::args("geometry model","geometry data","stop at first collision"),
"Determine if collision pairs are effectively in collision."
);
bp::def("computeGeometryAndCollisions",computeGeometryAndCollisions_proxy,
bp::args("Model","Data","GeometryModel","GeometryData","Configuration q (size Model::nq)", "bool"),
bp::def("computeCollisions",
(bool (*)(const Model &, Data &, const GeometryModel &, GeometryData &,
const VectorXd &, const bool))&computeCollisions,
bp::args("model","data","geometry model","geometry data","Configuration q (size Model::nq)", "bool"),
"Update the geometry for a given configuration and"
"determine if all collision pairs are effectively in collision or not."
);
bp::def("computeDistance",computeDistance_proxy,
bp::args("GeometryModel","GeometryData", "pairIndex"),
"Compute the distance between the two geometry objects of a given collision pair for a GeometryModel and associated GeometryData."
bp::def("computeDistance",&computeDistance,
bp::args("geometry model","geometry data", "pairIndex"),
"Compute the distance between the two geometry objects of a given collision pair for a GeometryModel and associated GeometryData.",
bp::return_value_policy<bp::return_by_value>()
// bp::with_custodian_and_ward_postcall<0,1>()
);
bp::def("computeDistances",computeDistances_proxy,
bp::args("GeometryModel","GeometryData"),
bp::def("computeDistances",
(std::size_t (*)(const GeometryModel &, GeometryData &))&computeDistances,
bp::args("geometry model","geometry data"),
"Compute the distance between each collision pair for a given GeometryModel and associated GeometryData."
);
bp::def("computeGeometryAndDistances",computeGeometryAndDistances_proxy,
bp::args("Model","Data","GeometryModel","GeometryData","Configuration q (size Model::nq)"),
bp::def("computeDistances",
(std::size_t (*)(const Model &, Data &, const GeometryModel &, GeometryData &, const VectorXd &))&computeDistances,
bp::args("model","data","geometry model","geometry data","Configuration q (size Model::nq)"),
"Update the geometry for a given configuration and"
"compute the distance between each collision pair"
);
......
......@@ -23,14 +23,6 @@ namespace se3
namespace python
{
static void compute_jacobians_proxy(const Model & model,
Data & data,
const Eigen::VectorXd & q)
{
computeJacobians(model,data,q);
}
static Data::Matrix6x
jacobian_proxy(const Model & model,
Data & data,
......@@ -52,10 +44,11 @@ namespace se3
void exposeJacobian()
{
bp::def("computeJacobians",compute_jacobians_proxy,
bp::def("computeJacobians",computeJacobians,
bp::args("Model","Data",
"Joint configuration q (size Model::nq)"),
"Calling computeJacobians");
"Calling computeJacobians",
bp::return_value_policy<bp::return_by_value>());
bp::def("jacobian",jacobian_proxy,
bp::args("Model, the model of the kinematic tree",
......
......@@ -22,92 +22,63 @@ namespace se3
{
namespace python
{
static Eigen::VectorXd integrate_proxy(const Model & model,
const Eigen::VectorXd & q,
const Eigen::VectorXd & v)
{
return integrate(model,q,v);
}
static Eigen::VectorXd interpolate_proxy(const Model & model,
const Eigen::VectorXd & q1,
const Eigen::VectorXd & q2,
const double u)
{
return interpolate(model,q1,q2,u);
}
static Eigen::VectorXd differentiate_proxy(const Model & model,
const Eigen::VectorXd & q1,
const Eigen::VectorXd & q2)
{
return differentiate(model,q1,q2);
}
static Eigen::VectorXd distance_proxy(const Model & model,
const Eigen::VectorXd & q1,
const Eigen::VectorXd & q2)
{
return distance(model,q1,q2);
}
static Eigen::VectorXd randomConfiguration_proxy(const Model & model,
const Eigen::VectorXd & lowerPosLimit,
const Eigen::VectorXd & upperPosLimit)
{
return randomConfiguration(model, lowerPosLimit, upperPosLimit);
}
static void normalize_proxy(const Model & model,
Eigen::VectorXd & config)
static Eigen::VectorXd normalize_proxy(const Model & model,
const Eigen::VectorXd & config)
{
Eigen::VectorXd q(config);
normalize(model, q);
config = q;
normalize(model,q);
return q;
}
static bool isSameConfiguration_proxy(const Model & model,
const Eigen::VectorXd & q1,
const Eigen::VectorXd & q2)
{
return isSameConfiguration(model, q1, q2);
}
void exposeJointsAlgo()
{
bp::def("integrate",integrate_proxy,
using namespace Eigen;
bp::def("integrate",
(VectorXd (*)(const Model &, const VectorXd &, const VectorXd &))&integrate,
bp::args("Model",
"Configuration q (size Model::nq)",
"Velocity v (size Model::nv)"),
"Integrate the model for a tangent vector during one unit time .");
bp::def("interpolate",interpolate_proxy,
bp::def("interpolate",
(VectorXd (*)(const Model &, const VectorXd &, const VectorXd &, const double))&interpolate,
bp::args("Model",
"Configuration q1 (size Model::nq)",
"Configuration q2 (size Model::nq)",
"Double u"),
"Interpolate the model between two configurations.");
bp::def("differentiate",differentiate_proxy,
bp::def("differentiate",
(VectorXd (*)(const Model &, const VectorXd &, const VectorXd &))&differentiate,
bp::args("Model",
"Configuration q1 (size Model::nq)",
"Configuration q2 (size Model::nq)"),
"Difference between two configurations, ie. the tangent vector that must be integrated during one unit time"
"to go from q1 to q2");
bp::def("distance",distance_proxy,
bp::def("distance",
(VectorXd (*)(const Model &, const VectorXd &, const VectorXd &))&distance,
bp::args("Model",
"Configuration q1 (size Model::nq)",
"Configuration q2 (size Model::nq)"),
"Distance between two configurations ");
bp::def("randomConfiguration",randomConfiguration_proxy,
bp::def("randomConfiguration",
(VectorXd (*)(const Model &, const VectorXd &, const VectorXd &))&randomConfiguration,
bp::args("Model",
"Joint lower limits (size Model::nq)",
"Joint upper limits (size Model::nq)"),
"Generate a random configuration ensuring provied joint limits are respected ");
bp::def("normalize",normalize_proxy,
bp::args("Model",
"Configuration q (size Model::nq)"),
"return the configuration normalized ");
bp::def("isSameConfiguration",isSameConfiguration_proxy,
bp::def("isSameConfiguration",
(bool (*)(const Model &, const VectorXd &, const VectorXd &))&isSameConfiguration,
bp::args("Model",
"Configuration q1 (size Model::nq)",
"Configuration q2 (size Model::nq)"),
......
......@@ -23,48 +23,26 @@ namespace se3
namespace python
{
static void fk_0_proxy(const Model & model,
Data & data,
const Eigen::VectorXd & q)
{
forwardKinematics(model,data,q);
}
static void fk_1_proxy(const Model & model,
Data & data,
const Eigen::VectorXd & q,
const Eigen::VectorXd & qdot )
{
forwardKinematics(model,data,q,qdot);
}
static void fk_2_proxy(const Model & model,
Data & data,
const Eigen::VectorXd & q,
const Eigen::VectorXd & v,
const Eigen::VectorXd & a)
{
forwardKinematics(model,data,q,v,a);
}
void exposeKinematics()
{
bp::def("forwardKinematics",fk_0_proxy,
using namespace Eigen;
bp::def("forwardKinematics",
(void (*)(const Model &, Data &, const VectorXd &))&forwardKinematics,
bp::args("Model","Data",
"Configuration q (size Model::nq)"),
"Compute the placements of all the frames of the kinematic "
"tree and put the results in data.");
bp::def("forwardKinematics",fk_1_proxy,
bp::def("forwardKinematics",
(void (*)(const Model &, Data &, const VectorXd &, const VectorXd &))&forwardKinematics,
bp::args("Model","Data",
"Configuration q (size Model::nq)",
"Velocity v (size Model::nv)"),
"Compute the placements and spatial velocities of all the frames of the kinematic "
"tree and put the results in data.");
bp::def("forwardKinematics",fk_2_proxy,
bp::def("forwardKinematics",
(void (*)(const Model &, Data &, const VectorXd &, const VectorXd &, const VectorXd &))&forwardKinematics,
bp::args("Model","Data",
"Configuration q (size Model::nq)",
"Velocity v (size Model::nv)",
......
......@@ -22,56 +22,39 @@ namespace se3
{
namespace python
{
static Eigen::VectorXd rnea_proxy(const Model & model,
Data & data,
const Eigen::VectorXd & q,
const Eigen::VectorXd & v,
const Eigen::VectorXd & a)
{
return rnea(model,data,q,v,a);
}
static Eigen::VectorXd rnea_fext_proxy(const Model & model,
Data & data,
const Eigen::VectorXd & q,
const Eigen::VectorXd & v,
const Eigen::VectorXd & a,