Skip to content

Commit

Permalink
Merge pull request #208 from robotology/pixisupportionic
Browse files Browse the repository at this point in the history
Add support for both Gazebo Harmonic (gz-sim8) and Gazebo Ionic (gz-sim9)
  • Loading branch information
xela-95 authored Oct 4, 2024
2 parents 8ce978c + 470e5bd commit f8dda51
Show file tree
Hide file tree
Showing 5 changed files with 11,534 additions and 8,835 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/test-pixi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@ on:

jobs:
pixi-test:
name: '[pixi:${{ matrix.os }}]'
name: '[pixi:${{ matrix.os }}:env:${{ matrix.pixi_env }}]'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [
ubuntu-22.04,
macos-latest,
# Disabled until https://github.com/robotology/gz-sim-yarp-plugins/issues/205 is fixed
# windows-2019
windows-2019
]
pixi_env: [
default,
ionic
]

steps:
Expand All @@ -38,5 +41,11 @@ jobs:
- name: Print pixi info
run: pixi info

- name: Build the project
run: pixi run -e ${{ matrix.pixi_env }} build

# Windows disabled due to https://github.com/robotology/gz-sim-yarp-plugins/issues/205
# macOS on Ionic disabled due to https://github.com/robotology/gz-sim-yarp-plugins/issues/215
- name: Run tests
run: pixi run test
if: "!contains(matrix.os, 'windows') && !(contains(matrix.os, 'macos') && matrix.pixi_env == 'ionic')"
run: pixi run -e ${{ matrix.pixi_env }} test
33 changes: 28 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,38 @@ project(gz-sim-yarp-plugins
LANGUAGES CXX C
VERSION 0.3.0)

find_package(gz-cmake3 REQUIRED)
find_package(YARP REQUIRED COMPONENTS robotinterface os)
find_package(YCM REQUIRED)

gz_find_package(gz-plugin2 REQUIRED COMPONENTS register)
set(GZ_PLUGIN_VER ${gz-plugin2_VERSION_MAJOR})
# Initial value of GZ_SIM_YARP_PLUGINS_USED_GZ_SIM_VERSION is empty, and then is set to 8 or 9 depending if gz-sim8 or gz-sim9 are available
set(GZ_SIM_YARP_PLUGINS_USED_GZ_SIM_VERSION_DOCS "Version of gz-sim used to compile gz-sim-yarp-plugins (either 8 or 9)")
set(GZ_SIM_YARP_PLUGINS_USED_GZ_SIM_VERSION "" CACHE STRING ${GZ_SIM_YARP_PLUGINS_USED_GZ_SIM_VERSION_DOCS})

# If GZ_SIM_YARP_PLUGINS_USED_GZ_SIM_VERSION is not set, try to guess a suitable value
# based on the gz-sim version that can be found in the system
if(GZ_SIM_YARP_PLUGINS_USED_GZ_SIM_VERSION STREQUAL "")
find_package(gz-sim8 QUIET)
if(gz-sim8_FOUND)
set(GZ_SIM_YARP_PLUGINS_USED_GZ_SIM_VERSION "8" CACHE STRING ${GZ_SIM_YARP_PLUGINS_USED_GZ_SIM_VERSION_DOCS} FORCE)
else()
find_package(gz-sim9 REQUIRED)
set(GZ_SIM_YARP_PLUGINS_USED_GZ_SIM_VERSION "9" CACHE STRING ${GZ_SIM_YARP_PLUGINS_USED_GZ_SIM_VERSION_DOCS} FORCE)
endif()
endif()

gz_find_package(gz-sim8 REQUIRED)
set(GZ_SIM_VER ${gz-sim8_VERSION_MAJOR})
if(GZ_SIM_YARP_PLUGINS_USED_GZ_SIM_VERSION STREQUAL "8")
find_package(gz-sim8 REQUIRED)
set(GZ_SIM_VER ${gz-sim8_VERSION_MAJOR})
find_package(gz-plugin2 REQUIRED COMPONENTS register)
set(GZ_PLUGIN_VER ${gz-plugin2_VERSION_MAJOR})
elseif(GZ_SIM_YARP_PLUGINS_USED_GZ_SIM_VERSION STREQUAL "9")
find_package(gz-sim9 REQUIRED)
set(GZ_SIM_VER ${gz-sim9_VERSION_MAJOR})
find_package(gz-plugin3 REQUIRED COMPONENTS register)
set(GZ_PLUGIN_VER ${gz-plugin3_VERSION_MAJOR})
else()
message(FATAL_ERROR "Unsupported GZ_SIM_YARP_PLUGINS_USED_GZ_SIM_VERSION value ${GZ_SIM_YARP_PLUGINS_USED_GZ_SIM_VERSION}, only 8 or 9 are supported.")
endif()

option(GZ_SIM_YARP_PLUGINS_BUILD_TOOLS "If enabled, build command line helper tools" ON)

Expand Down
12 changes: 10 additions & 2 deletions docs/build-from-source.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ pixi shell

and then run your commands as in a normal shell.

The `default` environment of pixi uses Gazebo Harmonic (`gz-sim8`), if you want to use Gazebo Ionic (`gz-sim9`) just add `-e ionic` after `pixi run`, for example to run the tests under Ionic:

~~~
pixi run -e ionic test
~~~

## Compile from source with conda on Linux, macOS or Windows

If you are using conda, the dependencies of `gz-sim-yarp-plugins` can be installed with:
Expand All @@ -66,7 +72,7 @@ If you are using conda, the dependencies of `gz-sim-yarp-plugins` can be install
conda install -c conda-forge libgz-sim8 yarp ycm-cmake-modules cmake ninja pkg-config cmake compilers gtest cli11
```

This command should be executed in a terminal with the environment activated.
This command should be executed in a terminal with the environment activated. If you want to use Gazebo Ionic (`gz-sim9`) in place of Gazebo Harmonic (`gz-sim8`), just change `libgz-sim8` to `libgz-sim9`.

### Build

Expand Down Expand Up @@ -101,7 +107,7 @@ sudo apt-get update
sudo apt-get install lsb-release wget gnupg cmake pkg-config ninja-build build-essential libcli11-dev libgtest-dev
```

and then install Gazebo Harmonic:
and then install Gazebo:

```bash
sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg
Expand All @@ -110,6 +116,8 @@ sudo apt-get update
sudo apt-get install gz-harmonic
```

If you want to use Gazebo Ionic (`gz-sim9`) in place of Gazebo Harmonic (`gz-sim8`), just change `gz-harmonic` to `gz-ionic`.

Then, you need to install [`ycm-cmake-modules`](https://github.com/robotology/ycm) and [`yarp`](https://github.com/robotology/yarp), for which no apt binaries are available. You can install them easily via the `robotology-superbuild`, or otherwise with the following commands:

```bash
Expand Down
Loading

0 comments on commit f8dda51

Please sign in to comment.