Unified C++ interface for quadratic programming solvers
- Unified C++ interface to many QP solvers
- Can be built as a standalone package or ROS package
- High portability decoupled from each QP solver by Pimpl technique
It is assumed that ROS is installed.
-
Install the QP solver you wish to use according to this section. You can skip installing QP solvers that you do not use.
-
Setup catkin workspace.
$ mkdir -p ~/ros/ws_qp_solver_collection/src
$ cd ~/ros/ws_qp_solver_collection
$ wstool init src
$ wstool set -t src isri-aist/QpSolverCollection git@github.com:isri-aist/QpSolverCollection.git --git -y
$ wstool update -t src
- Install dependent packages.
$ source /opt/ros/${ROS_DISTRO}/setup.bash
$ rosdep install -y -r --from-paths src --ignore-src
- Build a package.
$ catkin build -DCMAKE_BUILD_TYPE=RelWithDebInfo <qp-solver-flags> --catkin-make-args all tests
See this section for <qp-solver-flags>
.
As all supported QP solvers are installed in CI, please refer to the installation procedure.
Please refer to the license specified in each QP solver when using it.
Install eigen-qld.
Add -DENABLE_QLD=ON
to the catkin build command (i.e., <qp-solver-flags>
).
Install eigen-quadprog.
Add -DENABLE_QUADPROG=ON
to the catkin build command (i.e., <qp-solver-flags>
).
Install master branch of jrl-qp.
Add -DENABLE_JRLQP=ON
to the catkin build command (i.e., <qp-solver-flags>
).
Install master branch of qpOASES with -DBUILD_SHARED_LIBS=ON
cmake option.
Add -DENABLE_QPOASES=ON
to the catkin build command (i.e., <qp-solver-flags>
).
Also, add -DQPOASES_INCLUDE_DIR=<path to qpOASES.hpp>
and -DQPOASES_LIBRARY_DIR=<path to libqpOASES.so>
to the catkin build command.
Install master branch of osqp and osqp-eigen.
Add -DENABLE_OSQP=ON
to the catkin build command (i.e., <qp-solver-flags>
).
Install cmake-install branch of nasoq.
Add -DENABLE_NASOQ=ON
to the catkin build command (i.e., <qp-solver-flags>
).
Install master branch of blasfeo and hpipm.
Add /opt/blasfeo/lib
and /opt/hpipm/lib
to the environment variable LD_LIBRARY_PATH
.
Add -DENABLE_HPIPM=ON
to the catkin build command (i.e., <qp-solver-flags>
).
Install main branch of proxsuite.
Add -DENABLE_PROXQP=ON
to the catkin build command (i.e., <qp-solver-flags>
).
Install master branch of qpmad.
Add -DENABLE_QPMAD=ON
to the catkin build command (i.e., <qp-solver-flags>
).
Install eigen-lssol.
Add -DENABLE_LSSOL=ON
to the catkin build command (i.e., <qp-solver-flags>
).
See documentation and test for examples of solving QP problems.
The following is a simple sample.
// sample.cpp
#include <qp_solver_collection/QpSolverCollection.h>
int main()
{
int dim_var = 2;
int dim_eq = 1;
int dim_ineq = 0;
QpSolverCollection::QpCoeff qp_coeff;
qp_coeff.setup(dim_var, dim_eq, dim_ineq);
qp_coeff.obj_mat_ << 2.0, 0.5, 0.5, 1.0;
qp_coeff.obj_vec_ << 1.0, 1.0;
qp_coeff.eq_mat_ << 1.0, 1.0;
qp_coeff.eq_vec_ << 1.0;
qp_coeff.x_min_.setZero();
qp_coeff.x_max_.setConstant(1000.0);
auto qp_solver = QpSolverCollection::allocateQpSolver(QpSolverCollection::QpSolverType::Any);
Eigen::VectorXd solution = qp_solver->solve(qp_coeff);
std::cout << "solution: " << solution.transpose() << std::endl;
return 0;
}
In addition to building a sample in a catkin package, you can also build it standalone as follows.
$ g++ sample.cpp `pkg-config --cflags qp_solver_collection` `pkg-config --libs qp_solver_collection`