Skip to content

ros2

ros2 #53

name: Build and Test OCS2 (ROS2 Jazzy)
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- build_type: Release
build_testing: "ON"
run_tests: true
packages_up_to: ""
# Full Debug + tests is too slow for GitHub-hosted runners; still build Debug
# (without tests) to catch compilation issues. Also only build up to core ROS
# interfaces to keep disk usage below GitHub runner limits.
- build_type: Debug
build_testing: "OFF"
run_tests: false
packages_up_to: "ocs2_ros_interfaces"
runs-on: ubuntu-latest
container:
image: ros:jazzy-ros-base
env:
DEBIAN_FRONTEND: noninteractive
steps:
- name: Environment Info
run: |
pwd
uname -r
cat /etc/os-release
- name: System deps
run: |
apt-get update && apt-get install -y --no-install-recommends \
build-essential cmake git ninja-build \
curl ca-certificates gnupg lsb-release \
python3-colcon-common-extensions python3-rosdep python3-pip \
python3-dev pybind11-dev \
libeigen3-dev libboost-all-dev libglpk-dev \
libgmp-dev libmpfr-dev libcgal-dev libopencv-dev libpcl-dev \
liburdfdom-dev \
ros-jazzy-eigen3-cmake-module \
ros-jazzy-hpp-fcl \
ros-jazzy-grid-map \
ros-jazzy-xacro ros-jazzy-robot-state-publisher ros-jazzy-rviz2 \
&& rm -rf /var/lib/apt/lists/*
- name: Install Pinocchio (robotpkg)
run: |
install -d -m 0755 /etc/apt/keyrings
curl -fsSL http://robotpkg.openrobots.org/packages/debian/robotpkg.asc | tee /etc/apt/keyrings/robotpkg.asc >/dev/null
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/robotpkg.asc] http://robotpkg.openrobots.org/packages/debian/pub $(. /etc/os-release && echo $VERSION_CODENAME) robotpkg" > /etc/apt/sources.list.d/robotpkg.list
apt-get update && apt-get install -y --no-install-recommends \
robotpkg-pinocchio robotpkg-coal \
&& rm -rf /var/lib/apt/lists/*
- name: Set OpenRobots env
run: |
echo "CMAKE_PREFIX_PATH=/opt/openrobots:${CMAKE_PREFIX_PATH}" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=/opt/openrobots/lib:${LD_LIBRARY_PATH}" >> $GITHUB_ENV
- name: Pin setuptools < 80
run: |
pip3 install --no-cache-dir --break-system-packages 'setuptools<80'
- name: Checkout
uses: actions/checkout@v4
with:
path: src/ocs2
- name: Checkout dependencies
run: |
git clone --depth 1 --branch ros2 --single-branch https://github.com/leggedrobotics/ocs2_robotic_assets.git src/ocs2_robotic_assets
git clone --depth 1 --filter=blob:none --sparse --branch ros2 --single-branch https://github.com/leggedrobotics/elevation_mapping_cupy.git src/elevation_mapping_cupy
cd src/elevation_mapping_cupy
git sparse-checkout set plane_segmentation
- name: Rosdep
shell: bash
run: |
if [ ! -f /etc/ros/rosdep/sources.list.d/20-default.list ]; then rosdep init; fi
rosdep update
source /opt/ros/jazzy/setup.bash
rosdep install --from-paths src --ignore-src -r -y --skip-keys pinocchio
- name: Build (${{ matrix.build_type }})
shell: bash
run: |
source /opt/ros/jazzy/setup.bash
if [ -n "${{ matrix.packages_up_to }}" ]; then
colcon build --packages-up-to ${{ matrix.packages_up_to }} --event-handlers console_direct+ \
--cmake-args -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DBUILD_TESTING=${{ matrix.build_testing }}
else
colcon build --event-handlers console_direct+ \
--cmake-args -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DBUILD_TESTING=${{ matrix.build_testing }}
fi
- name: Test
if: ${{ matrix.run_tests }}
shell: bash
run: |
source install/setup.bash
colcon test --event-handlers console_direct+
colcon test-result --verbose