Commit 5eab344a authored by Steve Tonneau's avatar Steve Tonneau
Browse files

testing eigenpy bindings

parent 00ba708e
......@@ -20,3 +20,4 @@
build/
build-rel/
bin/
lib/
......@@ -38,6 +38,8 @@ IF(BUILD_PYTHON_INTERFACE)
find_package( Boost COMPONENTS python REQUIRED )
include_directories( ${Boost_INCLUDE_DIR} )
SET(PKG_CONFIG_PYWRAP_REQUIRES "eigenpy >= 1.3.1")
ENDIF(BUILD_PYTHON_INTERFACE)
......
......@@ -81,7 +81,7 @@ private:
double convert_emax_to_b0(double emax);
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
/**
* @brief Equilibrium constructor.
* @param name Name of the object.
......@@ -93,8 +93,8 @@ public:
* @param canonicalize_cdd_matrix whether to remove redundant inequalities when computing double description matrices
* a small pertubation of the system
*/
Equilibrium(std::string name, double mass, unsigned int generatorsPerContact,
SolverLP solver_type = SOLVER_LP_QPOASES, bool useWarmStart=true, const unsigned int max_num_cdd_trials=0,
Equilibrium(const std::string& name, const double mass, const unsigned int generatorsPerContact,
const SolverLP solver_type = SOLVER_LP_QPOASES, bool useWarmStart=true, const unsigned int max_num_cdd_trials=0,
const bool canonicalize_cdd_matrix=false);
/**
......
#include "centroidal-dynamics-lib/centroidal_dynamics.hh"
#include "centroidal-dynamics-lib/util.hh"
#include <eigenpy/memory.hpp>
#include <eigenpy/eigenpy.hpp>
#include <boost/python.hpp>
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION(centroidal_dynamics::Equilibrium)
namespace centroidal_dynamics
{
using namespace boost::python;
bool wrapSetNewContacts(Equilibrium& self, MatrixX3 contactPoints, MatrixX3 contactNormals,
double frictionCoefficient, EquilibriumAlgorithm alg)
{
return self.setNewContacts(contactPoints, contactNormals, frictionCoefficient, alg);
}
BOOST_PYTHON_MODULE(centroidal_dynamics)
{
/** BEGIN eigenpy init**/
eigenpy::enableEigenPy();
eigenpy::enableEigenPySpecific<MatrixX3,MatrixX3>();
/*eigenpy::exposeAngleAxis();
eigenpy::exposeQuaternion();*/
/** END eigenpy init**/
/** BEGIN enum types **/
#ifdef CLP_FOUND
enum_<SolverLP>("SolverLP")
......@@ -36,6 +58,7 @@ BOOST_PYTHON_MODULE(centroidal_dynamics)
.def("setUseWarmStart", &Equilibrium::setUseWarmStart)
.def("getName", &Equilibrium::getName)
.def("getAlgorithm", &Equilibrium::getAlgorithm)
.def("setNewContacts", &wrapSetNewContacts)
;
}
......
......@@ -41,7 +41,7 @@ PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} qpOASES)
if(CLP_FOUND)
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${CLP_LIBRARIES}
/usr/lib/libCoinUtils.so)
/usr/lib/libCoinUtils.so)
endif()
SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
......
......@@ -17,8 +17,8 @@ namespace centroidal_dynamics
bool Equilibrium::m_is_cdd_initialized = false;
Equilibrium::Equilibrium(string name, double mass, unsigned int generatorsPerContact,
SolverLP solver_type, bool useWarmStart,
Equilibrium::Equilibrium(const string& name, const double mass, const unsigned int generatorsPerContact,
const SolverLP solver_type, const bool useWarmStart,
const unsigned int max_num_cdd_trials, const bool canonicalize_cdd_matrix)
: m_is_cdd_stable(true)
, max_num_cdd_trials(max_num_cdd_trials)
......@@ -31,18 +31,18 @@ Equilibrium::Equilibrium(string name, double mass, unsigned int generatorsPerCon
//srand ( (unsigned int) (time(NULL)) );
}
if(generatorsPerContact<3)
{
SEND_WARNING_MSG("Algorithm cannot work with less than 3 generators per contact!");
generatorsPerContact = 3;
}
m_name = name;
m_solver_type = solver_type;
m_solver = Solver_LP_abstract::getNewSolver(solver_type);
m_solver->setUseWarmStart(useWarmStart);
m_generatorsPerContact = generatorsPerContact;
if(generatorsPerContact<3)
{
SEND_WARNING_MSG("Algorithm cannot work with less than 3 generators per contact!");
m_generatorsPerContact = 3;
}
m_mass = mass;
m_gravity.setZero();
m_gravity(2) = -9.81;
......
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