Skip to content

Commit 0387f0f

Browse files
committed
nix
1 parent 2e219a3 commit 0387f0f

12 files changed

Lines changed: 874 additions & 112 deletions

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "monthly"

.github/workflows/ci_ros2.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: ROS2 Continuous Integration
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
jobs:
8+
build:
9+
strategy:
10+
matrix:
11+
env:
12+
- {ROS_DISTRO: jazzy}
13+
# - {ROS_DISTRO: kilted}
14+
# - {ROS_DISTRO: rolling}
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v6
18+
- uses: 'ros-industrial/industrial_ci@125164b9f1883cdf1858897a7146d1bebf2be5c6'
19+
env: ${{ matrix.env }}
20+
check:
21+
if: always()
22+
name: check-ros-ci
23+
runs-on: ubuntu-latest
24+
needs:
25+
- build
26+
steps:
27+
- uses: re-actors/alls-green@release/v1
28+
with:
29+
jobs: ${{ toJSON(needs) }}

.github/workflows/nix.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: "CI - Nix"
2+
on:
3+
push:
4+
branches:
5+
- devel
6+
- master
7+
- main
8+
pull_request:
9+
branches:
10+
- devel
11+
- master
12+
- main
13+
jobs:
14+
distros:
15+
name: "${{ matrix.build }} on ${{ matrix.os }}"
16+
runs-on: "${{ matrix.os }}"
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
os: [ubuntu-24.04]
21+
# build: ["humble", "jazzy", "kilted", "rolling"]
22+
build: ["jazzy"]
23+
steps:
24+
- uses: actions/checkout@v6
25+
- uses: cachix/install-nix-action@v31
26+
- uses: cachix/cachix-action@v17
27+
with:
28+
name: gepetto
29+
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
30+
extraPullNames: ros
31+
- run: nix build -L ".#ros-${{ matrix.build }}"
32+
main:
33+
needs: distros
34+
name: "${{ matrix.os }}"
35+
runs-on: "${{ matrix.os }}-latest"
36+
strategy:
37+
fail-fast: false
38+
matrix:
39+
os: [ubuntu]
40+
steps:
41+
- uses: actions/checkout@v6
42+
- uses: cachix/install-nix-action@v31
43+
- uses: cachix/cachix-action@v17
44+
with:
45+
name: gepetto
46+
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
47+
extraPullNames: ros
48+
- run: nix flake check -L
49+
- run: nix build -L
50+
check:
51+
if: always()
52+
name: check-macos-linux-nix
53+
runs-on: ubuntu-latest
54+
needs:
55+
- distros
56+
- main
57+
steps:
58+
- uses: re-actors/alls-green@release/v1
59+
with:
60+
jobs: ${{ toJSON(needs) }}

.github/workflows/ros-rolling-ci.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: update-flake-lock
2+
on:
3+
workflow_dispatch:
4+
schedule:
5+
- cron: '0 3 30 * *'
6+
jobs:
7+
update-flake-inputs:
8+
runs-on: ubuntu-slim
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
steps:
13+
- name: Generate GitHub App Token
14+
id: app-token
15+
uses: actions/create-github-app-token@v3
16+
with:
17+
app-id: ${{ secrets.GEPETTO_NIX_APP_ID }}
18+
private-key: ${{ secrets.GEPETTO_NIX_APP_PRIVATE_KEY }}
19+
- name: Checkout repository
20+
uses: actions/checkout@v6
21+
with:
22+
token: ${{ steps.app-token.outputs.token }}
23+
- name: Setup Nix
24+
uses: cachix/install-nix-action@v31
25+
- name: Update flake inputs
26+
uses: mic92/update-flake-inputs@v1
27+
with:
28+
github-token: ${{ steps.app-token.outputs.token }}
29+
pr-labels: 'no-changelog'
30+
git-author-name: 'hrp2-14'
31+
git-author-email: '40568249+hrp2-14@users.noreply.github.com'

.mergify.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pull_request_rules:
2+
- name: merge [bot] PRs when CI pass
3+
conditions:
4+
- check-success = "check-macos-linux-nix"
5+
- check-success = "check-ros-ci"
6+
- check-success = "pre-commit.ci - pr"
7+
- or:
8+
- author = dependabot[bot]
9+
- author = gepetto-flake-updater[bot]
10+
- author = github-actions[bot]
11+
- author = hrp2-14
12+
- author = pre-commit-ci[bot]
13+
actions:
14+
merge:

CMakeLists.txt

Lines changed: 20 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1-
cmake_minimum_required(VERSION 3.14)
1+
cmake_minimum_required(VERSION 3.22)
22
set(CMAKE_VERBOSE_MAKEFILE True)
33

44
project(odri_gz_ros2_control)
55

6-
# Default to C11
7-
if(NOT CMAKE_C_STANDARD)
8-
set(CMAKE_C_STANDARD 11)
9-
endif()
10-
# Default to C++17
11-
if(NOT CMAKE_CXX_STANDARD)
12-
set(CMAKE_CXX_STANDARD 17)
13-
endif()
14-
156
# Compiler options
167
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
178
add_compile_options(-Wall -Wextra -Wpedantic)
@@ -26,54 +17,30 @@ find_package(pluginlib REQUIRED)
2617
find_package(rclcpp REQUIRED)
2718
find_package(yaml_cpp_vendor REQUIRED)
2819

29-
# Detects Ubuntu release
30-
find_program(LSB_RELEASE_EXEC lsb_release)
31-
execute_process(COMMAND ${LSB_RELEASE_EXEC} -c
32-
OUTPUT_VARIABLE LSB_RELEASE_CODENAME_PPREFIX
33-
OUTPUT_STRIP_TRAILING_WHITESPACE
34-
)
35-
36-
# Remove prefix Codename:
37-
string(REGEX REPLACE "Codename:\t" "" LSB_RELEASE_CODENAME ${LSB_RELEASE_CODENAME_PPREFIX})
38-
message(STATUS "LSB_RELEASE_CODENAME=${LSB_RELEASE_CODENAME}")
39-
40-
if(${LSB_RELEASE_CODENAME} STREQUAL "jammy")
41-
# If Jammy is detected uses Gazebo Fortress
42-
find_package(ignition-gazebo6 REQUIRED)
43-
set(GZ_SIM_VER ${ignition-gazebo6_VERSION_MAJOR})
44-
message(STATUS "Compiling against Gazebo Fortress")
45-
find_package(ignition-plugin1 REQUIRED)
46-
set(GZ_PLUGIN_VER ${ignition-plugin1_VERSION_MAJOR})
47-
set(GZ_PLUGIN ignition-plugin${GZ_PLUGIN_VER}::register)
48-
set(GZ_SIM ignition-gazebo${GZ_SIM_VER}::core)
49-
elseif(${LSB_RELEASE_CODENAME} STREQUAL "noble")
50-
# If Jammy is detected uses Harmonic
51-
find_package(gz_sim_vendor)
52-
find_package(gz-sim)
53-
54-
find_package(gz_plugin_vendor)
55-
find_package(gz-plugin)
20+
if(NOT DEFINED ENV{GZ_VERSION} OR "$ENV{GZ_VERSION}" STREQUAL "harmonic")
21+
set(GZ_SIM "gz-sim8")
22+
set(GZ_PLUGIN "gz-plugin2")
23+
else()
24+
message(FATAL_ERROR "Gazebo $ENV{GZ_VERSION} is not yet supported")
5625
endif()
5726

27+
find_package("${GZ_SIM}" REQUIRED)
28+
find_package("${GZ_PLUGIN}" REQUIRED)
29+
5830
include_directories(include)
5931

6032
add_library(${PROJECT_NAME}-system SHARED
6133
src/gz_ros2_control_plugin.cpp
6234
)
6335

64-
if(${LSB_RELEASE_CODENAME} STREQUAL "jammy")
65-
target_link_libraries(${PROJECT_NAME}-system
66-
${GZ_SIM}
67-
${GZ_PLUGIN}
68-
)
69-
elseif(${LSB_RELEASE_CODENAME} STREQUAL "noble")
70-
message(STATUS "Add target ${PROJECT_NAME}-system using noble")
71-
target_compile_definitions(${PROJECT_NAME}-system PUBLIC GZ_SIM_8)
36+
if(NOT DEFINED ENV{GZ_VERSION} OR "$ENV{GZ_VERSION}" STREQUAL "harmonic")
37+
target_compile_definitions(${PROJECT_NAME}-system PUBLIC GZ_SIM_8)
38+
endif()
39+
7240
target_link_libraries(${PROJECT_NAME}-system
73-
gz-sim::gz-sim
74-
gz-plugin::register
41+
"${GZ_SIM}::${GZ_SIM}"
42+
"${GZ_PLUGIN}::register"
7543
)
76-
endif()
7744

7845
ament_target_dependencies(${PROJECT_NAME}-system
7946
ament_index_cpp
@@ -96,16 +63,13 @@ ament_target_dependencies(gz_hardware_odri_plugins
9663
rclcpp
9764
)
9865

99-
if(${LSB_RELEASE_CODENAME} STREQUAL "jammy")
100-
target_link_libraries(gz_hardware_odri_plugins
101-
${GZ_SIM}
102-
)
103-
elseif(${LSB_RELEASE_CODENAME} STREQUAL "noble")
104-
target_compile_definitions(gz_hardware_odri_plugins PUBLIC GZ_SIM_8)
66+
if(NOT DEFINED ENV{GZ_VERSION} OR "$ENV{GZ_VERSION}" STREQUAL "harmonic")
67+
target_compile_definitions(gz_hardware_odri_plugins PUBLIC GZ_SIM_8)
68+
endif()
69+
10570
target_link_libraries(gz_hardware_odri_plugins
106-
gz-sim::gz-sim
71+
"${GZ_SIM}::${GZ_SIM}"
10772
)
108-
endif()
10973

11074
## Install
11175
install(TARGETS

0 commit comments

Comments
 (0)