ADVRHumanoids / XBotControl

XBotControl framework: XBotCore + OpenSoT + CartesI/O
33 stars 3 forks source link

Use OpenSoT OSQPBackEnd in a XBotPlugin #23

Closed lpaparusso closed 5 years ago

lpaparusso commented 5 years ago

Hi, @alaurenzi I am trying to use the OpenSoT OSQPBackEnd in a XBotPlugin to solve an optimization problem.

If I simply #include <OpenSoT/solvers/OSQPBackEnd.h> and modify the CMakeLists.txt to include the OpenSoT package, XBotCore returns undefined symbol: _ZN7OpenSoT7solvers11OSQPBackEndD1Ev

How can I solve the problem?

Thanks, Luca Paparusso

alaurenzi commented 5 years ago

Basically opensot backends are not meant to be linked against during compile time, rather you have to load the dynamically as plugins. To do so, there is a convenience function named BackEndFactory, to be used as follows:

OpenSoT::solvers::BackEnd::Ptr testProblemOSQP = OpenSoT::solvers::BackEndFactory(
                OpenSoT::solvers::solver_back_ends::OSQP, 
                number_of_variables,
                number_of_constraints,
                hessian_type,
                eps_regularisation);