qp_solver_collection
qp_solver_collection Documentation

This is the branch for ROS2; use the ros1 branch for ROS1.

QpSolverCollection

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 colcon 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

wstool can be installed with apt install python3-wstool or pip install wstool.

  1. Install dependent packages.
    $ source /opt/ros/${ROS_DISTRO}/setup.bash
    $ rosdep install -y -r --from-paths src --ignore-src
  2. Build a package.
    $ cd ~/ros/ws_qp_solver_collection
    $ colcon build --packages-select qp_solver_collection --merge-install --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo <qp-solver-flags>
    $ colcon test --merge-install --packages-select qp_solver_collection # [optional] to compile and run 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;
}
Class of QP coefficient.
Eigen::MatrixXd eq_mat_
Equality constraint matrix (corresponding to in QpSolver::solve.)
Eigen::VectorXd obj_vec_
Objective vector (corresponding to in QpSolver::solve.)
Eigen::VectorXd x_min_
Lower bound (corresponding to in QpSolver::solve.)
Eigen::MatrixXd obj_mat_
Objective matrix (corresponding to in QpSolver::solve.)
Eigen::VectorXd x_max_
Upper bound (corresponding to in QpSolver::solve.)
void setup(int dim_var, int dim_eq, int dim_ineq)
Setup the coefficients with filling zero.
Eigen::VectorXd eq_vec_
Equality constraint vector (corresponding to in QpSolver::solve.)
std::shared_ptr< QpSolver > allocateQpSolver(const QpSolverType &qp_solver_type)
Allocate the specified QP solver.

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`