Skip to content

Commit 256cbb9

Browse files
Merge pull request #19 from chuoru/ros2
Migrate to ROS2
2 parents 80526ab + 8953bb1 commit 256cbb9

File tree

11 files changed

+153
-206
lines changed

11 files changed

+153
-206
lines changed

.clang-format-common.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# This script is meant to be sourced from other scripts
22

3-
# Check for clang-format, prefer 10 if available
4-
if [[ -x "$(command -v clang-format-10)" ]]; then
5-
clang_format=clang-format-10
3+
# Check for clang-format, prefer 14 if available
4+
if [[ -x "$(command -v clang-format-14)" ]]; then
5+
clang_format=clang-format-14
66
elif [[ -x "$(command -v clang-format)" ]]; then
77
clang_format=clang-format
88
else
9-
echo "clang-format or clang-format-10 must be installed"
9+
echo "clang-format or clang-format-14 must be installed"
1010
exit 1
1111
fi
1212

.github/workflows/ci.yaml

+58-89
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ on:
1313
jobs:
1414

1515
clang-format:
16-
runs-on: ubuntu-20.04
16+
runs-on: ubuntu-22.04
1717
steps:
1818
- name: Checkout repository code
1919
uses: actions/checkout@v3
20-
- name: Install clang-format-10
20+
- name: Install clang-format-14
2121
run: |
2222
sudo apt-get -qq update
23-
sudo apt-get -qq install clang-format-10
23+
sudo apt-get -qq install clang-format-14
2424
- name: Run clang-format-check
2525
run: |
2626
./.clang-format-check.sh
@@ -29,25 +29,28 @@ jobs:
2929
strategy:
3030
fail-fast: false
3131
matrix:
32-
os: [ubuntu-20.04]
32+
os: [ubuntu-22.04, ubuntu-24.04]
3333
build-type: [Debug, RelWithDebInfo]
34-
standalone: [standalone, catkin]
34+
standalone: [standalone, colcon]
3535
solvers-from-source: [SolversFromSource, SolversFromAPT]
3636
runs-on: ${{ matrix.os }}
3737
steps:
3838
- name: Set environment variables
3939
run: |
40-
echo "LD_LIBRARY_PATH=/opt/blasfeo/lib:/opt/hpipm/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV # for HPIPM
41-
- name: Set ROS version
42-
if: matrix.standalone == 'catkin'
43-
run: |
44-
if [ "${{ matrix.os }}" == "ubuntu-20.04" ]
40+
set -e
41+
set -x
42+
echo "LD_LIBRARY_PATH=/opt/blasfeo/lib:/opt/hpipm/lib:/usr/local/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV # for HPIPM
43+
if [ "${{ matrix.os }}" == "ubuntu-22.04" ] && \
44+
[ "${{ matrix.build-type }}" == "RelWithDebInfo" ] && \
45+
[ "${{ matrix.standalone }}" == "colcon" ] && \
46+
[ "${{ matrix.solvers-from-source }}" == "SolversFromAPT" ] && \
47+
[ "${{ github.repository_owner }}" == "isri-aist" ] && \
48+
[ "${{ github.ref }}" == "refs/heads/master" ]
4549
then
46-
echo "ROS_DISTRO=noetic" >> $GITHUB_ENV
47-
echo "PYTHON_PACKAGE_PREFIX=python3" >> $GITHUB_ENV
48-
else # if [ "${{ matrix.os }}" == "ubuntu-18.04" ]
49-
echo "ROS_DISTRO=melodic" >> $GITHUB_ENV
50-
echo "PYTHON_PACKAGE_PREFIX=python" >> $GITHUB_ENV
50+
echo "UPLOAD_DOCUMENTATION=true" >> $GITHUB_ENV
51+
sudo apt-get install -qq doxygen graphviz
52+
else
53+
echo "UPLOAD_DOCUMENTATION=false" >> $GITHUB_ENV
5154
fi
5255
- name: Check secrets
5356
run: |
@@ -63,52 +66,14 @@ jobs:
6366
fi
6467
env:
6568
GITLAB_TOKEN : ${{ secrets.GITLAB_TOKEN }}
66-
- name: Install ROS
67-
if: matrix.standalone == 'catkin'
68-
run: |
69-
set -e
70-
set -x
71-
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
72-
wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
73-
sudo apt-get update -qq
74-
sudo apt-get install -qq ros-${ROS_DISTRO}-ros-base ${PYTHON_PACKAGE_PREFIX}-catkin-tools ${PYTHON_PACKAGE_PREFIX}-rosdep doxygen graphviz
75-
- name: Setup catkin workspace
76-
if: matrix.standalone == 'catkin'
77-
run: |
78-
set -e
79-
set -x
80-
mkdir -p ${GITHUB_WORKSPACE}/catkin_ws/src/
81-
cd ${GITHUB_WORKSPACE}/catkin_ws
82-
set +x
83-
. /opt/ros/${ROS_DISTRO}/setup.bash
84-
set -x
85-
catkin init
86-
catkin build --limit-status-rate 0.1
87-
- name: Checkout repository code
88-
if: matrix.standalone == 'catkin'
89-
uses: actions/checkout@v3
90-
with:
91-
submodules: recursive
92-
path: catkin_ws/src/QpSolverCollection
93-
- name: Checkout repository code
94-
if: matrix.standalone == 'standalone'
95-
uses: actions/checkout@v3
69+
- name: Install ROS2
70+
if: matrix.standalone == 'colcon'
71+
uses: jrl-umi3218/github-actions/install-dependencies@master
9672
with:
97-
submodules: recursive
98-
- name: Rosdep install
99-
if: matrix.standalone == 'catkin'
100-
run: |
101-
set -e
102-
set -x
103-
cd ${GITHUB_WORKSPACE}/catkin_ws
104-
set +x
105-
. devel/setup.bash
106-
set -x
107-
sudo rosdep init
108-
rosdep update
109-
rosdep install -y -r --from-paths src --ignore-src
110-
- name: Install solvers via apt
111-
if: matrix.solvers-from-source == 'SolversFromAPT'
73+
ros: |
74+
apt: ros-base
75+
- name: Install solvers via apt (Ubuntu 22)
76+
if: matrix.solvers-from-source == 'SolversFromAPT' && matrix.os == 'ubuntu-22.04'
11277
uses: jrl-umi3218/github-actions/install-dependencies@master
11378
with:
11479
build-type: ${{ matrix.build-type }}
@@ -117,6 +82,20 @@ jobs:
11782
mc-rtc:
11883
cloudsmith: mc-rtc/head
11984
apt: libmetis-dev libeigen3-dev libgtest-dev graphviz doxygen libeigen-qld-dev libeigen-quadprog-dev libjrl-qp-dev libqpoases-dev libosqp-eigen-dev libnasoq-dev libhpipm-dev libproxsuite-dev libqpmad-dev
85+
- name: Install solvers via apt (Ubuntu 24)
86+
if: matrix.solvers-from-source == 'SolversFromAPT' && matrix.os == 'ubuntu-24.04'
87+
uses: jrl-umi3218/github-actions/install-dependencies@master
88+
with:
89+
build-type: ${{ matrix.build-type }}
90+
ubuntu: |
91+
apt-mirrors:
92+
mc-rtc:
93+
cloudsmith: mc-rtc/head
94+
apt: libmetis-dev libeigen3-dev libgtest-dev graphviz doxygen libeigen-qld-dev libeigen-quadprog-dev libjrl-qp-dev libqpoases-dev libosqp-eigen-dev libhpipm-dev libproxsuite-dev libqpmad-dev
95+
github: |
96+
- path: isri-aist/nasoq
97+
ref: debian
98+
options: -DCMAKE_INSTALL_PREFIX=/usr/local -DNASOQ_BLAS_BACKEND=OpenBLAS -DNASOQ_USE_CLAPACK=ON -DNASOQ_BUILD_CLI=OFF -DNASOQ_BUILD_EXAMPLES=OFF -DNASOQ_BUILD_TESTS=OFF -DNASOQ_BUILD_DOCS=OFF
12099
- name: Install solvers from source
121100
if: matrix.solvers-from-source == 'SolversFromSource'
122101
uses: jrl-umi3218/github-actions/install-dependencies@master
@@ -134,9 +113,9 @@ jobs:
134113
- path: coin-or/qpOASES
135114
options: -DBUILD_SHARED_LIBS=ON -DQPOASES_BUILD_EXAMPLES=OFF
136115
- path: osqp/osqp
137-
- path: robotology/osqp-eigen
138-
- path: mmurooka/nasoq
139-
ref: cmake-install
116+
- path: chuoru/osqp-eigen
117+
- path: isri-aist/nasoq
118+
ref: debian
140119
options: -DCMAKE_INSTALL_PREFIX=/usr/local -DNASOQ_BLAS_BACKEND=OpenBLAS -DNASOQ_USE_CLAPACK=ON -DNASOQ_BUILD_CLI=OFF -DNASOQ_BUILD_EXAMPLES=OFF -DNASOQ_BUILD_TESTS=OFF -DNASOQ_BUILD_DOCS=OFF
141120
- path: giaf/blasfeo
142121
options: -DBUILD_SHARED_LIBS=ON -DTARGET=X64_AUTOMATIC -DBLASFEO_EXAMPLES=OFF
@@ -154,38 +133,28 @@ jobs:
154133
github: |
155134
- path: [email protected]:multi-contact/eigen-lssol
156135
options: -DBUILD_TESTING=OFF -DPYTHON_BINDING=OFF -DINSTALL_DOCUMENTATION=OFF
157-
- name: Catkin build
158-
if: matrix.standalone == 'catkin'
159-
run: |
160-
set -e
161-
set -x
162-
cd ${GITHUB_WORKSPACE}/catkin_ws
163-
set +x
164-
. devel/setup.bash
165-
set -x
166-
catkin build --limit-status-rate 0.1 -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
167-
-DDEFAULT_ENABLE_ALL=ON -DENABLE_LSSOL=${{ env.ENABLE_PRIVATE_SOLVERS }} \
168-
-DSKIP_PRIVATE_SOLVER_TEST=${{ env.SKIP_PRIVATE_SOLVER_TEST }} -DFORCE_ALL_SOLVER_TEST=ON -DINSTALL_DOCUMENTATION=ON
169-
- name: Run tests
170-
if: matrix.standalone == 'catkin'
171-
run: |
172-
set -e
173-
set -x
174-
cd ${GITHUB_WORKSPACE}/catkin_ws
175-
set +x
176-
. devel/setup.bash
177-
set -x
178-
catkin build --limit-status-rate 0.1 --catkin-make-args run_tests -- qp_solver_collection --no-deps
179-
catkin_test_results --verbose --all build
180-
- name: Build and test
136+
- name: Checkout repository code
137+
if: matrix.standalone == 'standalone'
138+
uses: actions/checkout@v3
139+
with:
140+
submodules: recursive
141+
- name: Standalone build
181142
if: matrix.standalone == 'standalone'
182143
uses: jrl-umi3218/github-actions/build-cmake-project@master
183144
with:
184145
build-type: ${{ matrix.build-type }}
185-
options: -DDEFAULT_ENABLE_ALL=ON -DENABLE_LSSOL=${{ env.ENABLE_PRIVATE_SOLVERS }} -DSKIP_PRIVATE_SOLVER_TEST=${{ env.SKIP_PRIVATE_SOLVER_TEST }} -DFORCE_ALL_SOLVER_TEST=ON -DINSTALL_DOCUMENTATION=ON
146+
options: -DINSTALL_DOCUMENTATION=${{ env.UPLOAD_DOCUMENTATION }} -DDEFAULT_ENABLE_ALL=ON -DENABLE_LSSOL=${{ env.ENABLE_PRIVATE_SOLVERS }} -DSKIP_PRIVATE_SOLVER_TEST=${{ env.SKIP_PRIVATE_SOLVER_TEST }} -DFORCE_ALL_SOLVER_TEST=ON
147+
- name: Colcon build
148+
if: matrix.standalone == 'colcon'
149+
uses: jrl-umi3218/github-actions/build-colcon-project@master
150+
with:
151+
build-type: ${{ matrix.build-type }}
152+
cmake-args: -DUSE_ROS2=ON -DINSTALL_DOCUMENTATION=${{ env.UPLOAD_DOCUMENTATION }} -DDEFAULT_ENABLE_ALL=ON -DENABLE_LSSOL=${{ env.ENABLE_PRIVATE_SOLVERS }} -DSKIP_PRIVATE_SOLVER_TEST=${{ env.SKIP_PRIVATE_SOLVER_TEST }} -DFORCE_ALL_SOLVER_TEST=ON
153+
build-packages: qp_solver_collection
154+
test-packages: qp_solver_collection
186155
- name: Upload documentation
187156
# Only run for one configuration and on origin master branch
188-
if: matrix.os == 'ubuntu-20.04' && matrix.build-type == 'RelWithDebInfo' && matrix.standalone == 'catkin' && matrix.solvers-from-source == 'SolversFromAPT' && github.repository_owner == 'isri-aist' && github.ref == 'refs/heads/master'
157+
if: env.UPLOAD_DOCUMENTATION == 'true'
189158
run: |
190159
set -e
191160
set -x

.github/workflows/package.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@ jobs:
2020
package:
2121
uses: jrl-umi3218/github-actions/.github/workflows/package-project.yml@master
2222
with:
23+
latest-cmake: true
2324
deps: '["isri-aist/ForceControlCollection"]'
2425
main-repo: isri-aist/QpSolverCollection
26+
matrix: |
27+
{
28+
"dist": ["focal"],
29+
"arch": ["amd64"]
30+
}
2531
secrets:
2632
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
2733
GH_TOKEN: ${{ secrets.GH_PAGES_TOKEN }}

CMakeLists.txt

+21-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.8)
1+
cmake_minimum_required(VERSION 3.14)
22
project(qp_solver_collection)
33

44
# Options for solvers
@@ -15,19 +15,17 @@ option(ENABLE_NASOQ "Enable NASOQ" ${DEFAULT_ENABLE_VALUE})
1515
option(ENABLE_HPIPM "Enable HPIPM" ${DEFAULT_ENABLE_VALUE})
1616
option(ENABLE_PROXQP "Enable PROXQP" ${DEFAULT_ENABLE_VALUE})
1717
option(ENABLE_QPMAD "Enable QPMAD" ${DEFAULT_ENABLE_VALUE})
18+
option(USE_ROS2 "Use ROS2" OFF)
1819

1920
option(FORCE_ALL_SOLVER_TEST "Test for all solvers regardless of options" OFF)
2021
mark_as_advanced(FORCE FORCE_ALL_SOLVER_TEST)
2122

2223
option(SKIP_PRIVATE_SOLVER_TEST "Skip private solver test" OFF)
2324
mark_as_advanced(FORCE SKIP_PRIVATE_SOLVER_TEST)
2425

25-
if(DEFINED CATKIN_DEVEL_PREFIX)
26-
find_package(catkin REQUIRED COMPONENTS
27-
roscpp
28-
)
29-
else()
30-
option(BUILD_SHARED_LIBS "Build libraries as shared as opposed to static" ON)
26+
option(BUILD_SHARED_LIBS "Build libraries as shared as opposed to static" ON)
27+
28+
if(NOT USE_ROS2)
3129
option(BUILD_TESTING "Build test" ON)
3230
if(BUILD_TESTING)
3331
enable_testing()
@@ -93,15 +91,9 @@ if(NOT ${EXIST_ENABLED_SOLVER})
9391
message(FATAL_ERROR "None of the QP solvers are enabled. Enable at least one QP solver.")
9492
endif()
9593

96-
if(DEFINED CATKIN_DEVEL_PREFIX)
97-
catkin_package(
98-
CATKIN_DEPENDS
99-
roscpp
100-
DEPENDS EIGEN3
101-
INCLUDE_DIRS include
102-
LIBRARIES QpSolverCollection
103-
CFG_EXTRAS qp_solver_options.cmake
104-
)
94+
if(USE_ROS2)
95+
find_package(ament_cmake REQUIRED)
96+
find_package(rclcpp REQUIRED)
10597
endif()
10698

10799
set(QP_SOLVER_OPTIONS_HEADER_FILE "${PROJECT_SOURCE_DIR}/include/qp_solver_collection/QpSolverOptions.h")
@@ -112,7 +104,7 @@ configure_file("${QP_SOLVER_OPTIONS_CMAKE_FILE}.in" "${QP_SOLVER_OPTIONS_CMAKE_F
112104

113105
add_subdirectory(src)
114106

115-
if(NOT DEFINED CATKIN_DEVEL_PREFIX)
107+
if(NOT USE_ROS2)
116108
install(EXPORT ${PROJECT_NAME}
117109
FILE ${PROJECT_NAME}Targets.cmake
118110
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
@@ -161,11 +153,22 @@ set(\@PROJECT_NAME\@_LIBRARIES \@PROJECT_NAME\@::QpSolverCollection)
161153
)
162154
endif()
163155

164-
if(CATKIN_ENABLE_TESTING OR BUILD_TESTING)
156+
if(BUILD_TESTING)
165157
add_subdirectory(tests)
166158
endif()
167159

168160
OPTION(INSTALL_DOCUMENTATION "Generate and install the documentation" OFF)
169161
if(INSTALL_DOCUMENTATION)
170162
add_subdirectory(doc)
171163
endif()
164+
165+
if(USE_ROS2)
166+
ament_export_libraries(QpSolverCollection)
167+
ament_export_include_directories(include)
168+
ament_export_dependencies(
169+
rclcpp
170+
Eigen3
171+
)
172+
ament_export_targets(${PROJECT_NAME})
173+
ament_package()
174+
endif()

README.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
This is the branch for ROS2; use the [ros1](https://github.com/isri-aist/QpSolverCollection/tree/ros1) branch for ROS1.
2+
13
# [QpSolverCollection](https://github.com/isri-aist/QpSolverCollection)
24
Unified C++ interface for quadratic programming solvers
35

@@ -28,7 +30,7 @@ It is assumed that ROS is installed.
2830

2931
1. Install the QP solver you wish to use according to [this section](https://github.com/isri-aist/QpSolverCollection#qp-solver-installation). You can skip installing QP solvers that you do not use.
3032

31-
2. Setup catkin workspace.
33+
2. Setup colcon workspace.
3234
```bash
3335
$ mkdir -p ~/ros/ws_qp_solver_collection/src
3436
$ cd ~/ros/ws_qp_solver_collection
@@ -37,6 +39,8 @@ $ wstool set -t src isri-aist/QpSolverCollection [email protected]:isri-aist/QpSolv
3739
$ wstool update -t src
3840
```
3941

42+
> `wstool` can be installed with `apt install python3-wstool` or `pip install wstool`.
43+
4044
3. Install dependent packages.
4145
```bash
4246
$ source /opt/ros/${ROS_DISTRO}/setup.bash
@@ -45,7 +49,9 @@ $ rosdep install -y -r --from-paths src --ignore-src
4549

4650
4. Build a package.
4751
```bash
48-
$ catkin build -DCMAKE_BUILD_TYPE=RelWithDebInfo <qp-solver-flags> --catkin-make-args all tests
52+
$ cd ~/ros/ws_qp_solver_collection
53+
$ colcon build --packages-select qp_solver_collection --merge-install --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo <qp-solver-flags>
54+
$ colcon test --merge-install --packages-select qp_solver_collection # [optional] to compile and run tests
4955
```
5056
See [this section](https://github.com/isri-aist/QpSolverCollection#qp-solver-installation) for `<qp-solver-flags>`.
5157

doc/Doxyfile.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ PROJECT_LOGO =
5858
# entered, it will be relative to the location where doxygen was started. If
5959
# left blank the current directory will be used.
6060

61-
OUTPUT_DIRECTORY = @CMAKE_CURRENT_BINARY_DIR@
61+
OUTPUT_DIRECTORY = @PROJECT_BINARY_DIR@/doc
6262

6363
# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
6464
# directories (in 2 levels) under the output directory of each output format and

0 commit comments

Comments
 (0)