qp_solver_collection

Unified C++ interface for quadratic programming solvers

CI Documentation

Features

  • 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

Supported QP solvers

Installation

Installation procedure

It is assumed that ROS is installed.

  1. Install the QP solver you wish to use according to this section. You can skip installing QP solvers that you do not use.
  2. 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
  3. Install dependent packages.
    $ source /opt/ros/${ROS_DISTRO}/setup.bash
    $ rosdep install -y -r --from-paths src --ignore-src
  4. Build a package.
    $ catkin build -DCMAKE_BUILD_TYPE=RelWithDebInfo <qp-solver-flags> --catkin-make-args all tests

See this section for <qp-solver-flags>.

QP solver installation

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.

QLD

Install eigen-qld.
Add -DENABLE_QLD=ON to the catkin build command (i.e., <qp-solver-flags>).

QuadProg

Install eigen-quadprog.
Add -DENABLE_QUADPROG=ON to the catkin build command (i.e., <qp-solver-flags>).

JRLQP

Install master branch of jrl-qp. Add -DENABLE_JRLQP=ON to the catkin build command (i.e., <qp-solver-flags>).

qpOASES

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.

OSQP

Install master branch of osqp and osqp-eigen.
Add -DENABLE_OSQP=ON to the catkin build command (i.e., <qp-solver-flags>).

NASOQ

Install cmake-install branch of nasoq.
Add -DENABLE_NASOQ=ON to the catkin build command (i.e., <qp-solver-flags>).

HPIPM

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>).

ProxQP

Install main branch of proxsuite.
Add -DENABLE_PROXQP=ON to the catkin build command (i.e., <qp-solver-flags>).

qpmad

Install master branch of qpmad.
Add -DENABLE_QPMAD=ON to the catkin build command (i.e., <qp-solver-flags>).

LSSOL (private)

Install eigen-lssol.
Add -DENABLE_LSSOL=ON to the catkin build command (i.e., <qp-solver-flags>).

How to use

See documentation and test for examples of solving QP problems.

The following is a simple sample.

// sample.cpp
int main()
{
int dim_var = 2;
int dim_eq = 1;
int dim_ineq = 0;
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);
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. ``bash $ g++ sample.cpppkg-config –cflags qp_solver_collectionpkg-config –libs qp_solver_collection ``

QpSolverCollection::QpCoeff
Class of QP coefficient.
Definition: QpSolverCollection.h:137
QpSolverCollection::QpCoeff::obj_vec_
Eigen::VectorXd obj_vec_
Objective vector (corresponding to in QpSolver::solve.)
Definition: QpSolverCollection.h:170
QpSolverCollection::allocateQpSolver
std::shared_ptr< QpSolver > allocateQpSolver(const QpSolverType &qp_solver_type)
Allocate the specified QP solver.
QpSolverCollection::QpCoeff::obj_mat_
Eigen::MatrixXd obj_mat_
Objective matrix (corresponding to in QpSolver::solve.)
Definition: QpSolverCollection.h:167
QpSolverCollection::QpSolverType::Any
@ Any
QpSolverCollection::QpCoeff::x_max_
Eigen::VectorXd x_max_
Upper bound (corresponding to in QpSolver::solve.)
Definition: QpSolverCollection.h:188
QpSolverCollection.h
QpSolverCollection::QpCoeff::eq_mat_
Eigen::MatrixXd eq_mat_
Equality constraint matrix (corresponding to in QpSolver::solve.)
Definition: QpSolverCollection.h:173
QpSolverCollection::QpCoeff::eq_vec_
Eigen::VectorXd eq_vec_
Equality constraint vector (corresponding to in QpSolver::solve.)
Definition: QpSolverCollection.h:176
QpSolverCollection::QpCoeff::x_min_
Eigen::VectorXd x_min_
Lower bound (corresponding to in QpSolver::solve.)
Definition: QpSolverCollection.h:185
QpSolverCollection::QpCoeff::setup
void setup(int dim_var, int dim_eq, int dim_ineq)
Setup the coefficients with filling zero.