diff --git a/.github/scripts/brew_install_deps.sh b/.github/scripts/brew_install_deps.sh index 3ecfb69d..97beee0a 100755 --- a/.github/scripts/brew_install_deps.sh +++ b/.github/scripts/brew_install_deps.sh @@ -51,3 +51,33 @@ do brew link $DEP_PKG done done + + +# keg only packages to install - only link dependencies +PKGS_KEG_ONLY=( + dartsim@6.10.0 +) + +# install packages +for PKG in "${PKGS_KEG_ONLY[@]}" +do + brew install ${PKG} +done + +# The GitHub actions cache does restore links, so we force +# (re-)linking on all dependencies of packages we install. + +for PKG in "${PKGS_KEG_ONLY[@]}" +do + # keg only do not link package + + DEPS=$(brew deps ${PKG}) + declare -a DEPS_ARRAY + DEPS_ARRAY=(${DEPS}) + + for DEP_PKG in "${DEPS_ARRAY[@]}" + do + # link package dependencies + brew link $DEP_PKG + done +done diff --git a/.github/scripts/macos_build.sh b/.github/scripts/macos_build.sh index 20b62020..3fa9a831 100755 --- a/.github/scripts/macos_build.sh +++ b/.github/scripts/macos_build.sh @@ -11,6 +11,9 @@ export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/usr/local/opt/dartsim@6.10.0/lib/pkgc export CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}:/usr/local/opt/qt@5 # Python scripts installed with: `pip3 install --user ` -export PATH=$PATH:$HOME/Library/Python/3.11/bin +export PATH=$PATH:$HOME/Library/Python/3.11/bin:$HOME/Library/Python/3.12/bin -colcon build --symlink-install --merge-install --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTING=ON -DCMAKE_CXX_STANDARD=17 -DCMAKE_MACOSX_RPATH=FALSE -DCMAKE_INSTALL_NAME_DIR=$(pwd)/install/lib +# Use desktop_notification- to suppress error: +# ERROR:colcon.colcon_notification.desktop_notification.terminal_notifier: +# Could not find the colcon-terminal-notifier.app in the install prefix '/Users/runner/Library/Python/3.12' +colcon build --symlink-install --merge-install --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTING=ON -DCMAKE_CXX_STANDARD=17 -DCMAKE_MACOSX_RPATH=FALSE -DCMAKE_INSTALL_NAME_DIR=$(pwd)/install/lib --event-handlers desktop_notification- diff --git a/.github/scripts/macos_test.sh b/.github/scripts/macos_test.sh index 7d6a40c5..055d4b57 100755 --- a/.github/scripts/macos_test.sh +++ b/.github/scripts/macos_test.sh @@ -1,7 +1,7 @@ #!/bin/bash # Python scripts installed with: `pip3 install --user ` -export PATH=$PATH:$HOME/Library/Python/3.11/bin +export PATH=$PATH:$HOME/Library/Python/3.11/bin:$HOME/Library/Python/3.12/bin colcon test --merge-install colcon test-result --all --verbose diff --git a/.github/workflows/macos-monterey-build-tools.yml b/.github/workflows/macos12-monterey-build-tools.yml similarity index 90% rename from .github/workflows/macos-monterey-build-tools.yml rename to .github/workflows/macos12-monterey-build-tools.yml index f66a03c7..26855ed1 100644 --- a/.github/workflows/macos-monterey-build-tools.yml +++ b/.github/workflows/macos12-monterey-build-tools.yml @@ -1,6 +1,6 @@ name: macOS Monterey Build Tools -on: [push, pull_request] +on: [pull_request] jobs: macos-monterey-ci: @@ -20,5 +20,5 @@ jobs: which pip3 which python3 python3 --version - export PATH=$PATH:/Users/runner/Library/Python/3.11/bin + export PATH=$PATH:/Users/runner/Library/Python/3.11/bin:/Users/runner/Library/Python/3.12/bin colcon graph diff --git a/.github/workflows/macos-monterey-ci.yml b/.github/workflows/macos12-monterey-ci.yml similarity index 100% rename from .github/workflows/macos-monterey-ci.yml rename to .github/workflows/macos12-monterey-ci.yml diff --git a/.github/workflows/macos13-ventura-build-tools.yml b/.github/workflows/macos13-ventura-build-tools.yml new file mode 100644 index 00000000..2c82a367 --- /dev/null +++ b/.github/workflows/macos13-ventura-build-tools.yml @@ -0,0 +1,24 @@ +name: macOS Ventura Build Tools + +on: [pull_request] + +jobs: + macos-ventura-ci: + runs-on: macos-13 + name: macOS Ventura Build Tools + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Build Tools + run: | + pip3 install --user vcstool + pip3 install --user colcon-common-extensions + + - name: Check Build Tools + run: | + which pip3 + which python3 + python3 --version + export PATH=$PATH:/Users/runner/Library/Python/3.11/bin:/Users/runner/Library/Python/3.12/bin + colcon graph diff --git a/.github/workflows/macos13-ventura-ci.yml b/.github/workflows/macos13-ventura-ci.yml new file mode 100644 index 00000000..bc644907 --- /dev/null +++ b/.github/workflows/macos13-ventura-ci.yml @@ -0,0 +1,42 @@ +name: macOS Ventura CI + +on: [pull_request] + +jobs: + macos-ventura-ci: + runs-on: macos-13 + name: macOS Ventura CI + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Cache brew packages + id: cache-brew-packages + uses: actions/cache@v3 + with: + path: | + /usr/local/Cellar + /usr/local/Frameworks + /usr/local/Homebrew + /usr/local/bin + /usr/local/lib + /usr/local/opt + /usr/local/share + key: macos-build-cache-${{ hashFiles('./.github/scripts/brew_install_deps.sh') }} + + - name: Install brew packages + run: | + bash ./.github/scripts/brew_install_deps.sh + + - name: Install Build Tools + run: | + python3 -m pip install --user vcstool + python3 -m pip install --user colcon-common-extensions + + - name: Build Wave Sim + run: | + bash ./.github/scripts/macos_build.sh + + - name: Test Wave Sim + run: | + bash ./.github/scripts/macos_test.sh diff --git a/gz-waves/CMakeLists.txt b/gz-waves/CMakeLists.txt index 00c0f17e..5133ed0c 100644 --- a/gz-waves/CMakeLists.txt +++ b/gz-waves/CMakeLists.txt @@ -51,35 +51,73 @@ gz_find_package(gz-common5 ) set(GZ_COMMON_VER ${gz-common5_VERSION_MAJOR}) -#-------------------------------------- -# Find gz-msgs -gz_find_package(gz-msgs9 REQUIRED) -set(GZ_MSGS_VER ${gz-msgs9_VERSION_MAJOR}) - -#-------------------------------------- -# Find gz-transport -gz_find_package(gz-transport12 REQUIRED) -set(GZ_TRANSPORT_VER ${gz-transport12_VERSION_MAJOR}) - #-------------------------------------- # Find gz-plugin gz_find_package(gz-plugin2 REQUIRED COMPONENTS loader register) set(GZ_PLUGIN_VER ${gz-plugin2_VERSION_MAJOR}) -#-------------------------------------- -# Find gz-rendering -gz_find_package(gz-rendering7 REQUIRED) -set(GZ_RENDERING_VER ${gz-rendering7_VERSION_MAJOR}) - -#-------------------------------------- -# Find gz-sim -gz_find_package(gz-sim7 REQUIRED) -set(GZ_SIM_VER ${gz-sim7_VERSION_MAJOR}) - -#-------------------------------------- -# Find SDFormat -gz_find_package(sdformat13 REQUIRED) -set(SDF_VER ${sdformat13_VERSION_MAJOR}) +# Garden (default) +if("$ENV{GZ_VERSION}" STREQUAL "garden" OR NOT DEFINED "ENV{GZ_VERSION}") + + #-------------------------------------- + # Find gz-msgs + gz_find_package(gz-msgs9 REQUIRED) + set(GZ_MSGS_VER ${gz-msgs9_VERSION_MAJOR}) + + #-------------------------------------- + # Find gz-transport + gz_find_package(gz-transport12 REQUIRED) + set(GZ_TRANSPORT_VER ${gz-transport12_VERSION_MAJOR}) + + #-------------------------------------- + # Find gz-rendering + gz_find_package(gz-rendering7 REQUIRED) + set(GZ_RENDERING_VER ${gz-rendering7_VERSION_MAJOR}) + + #-------------------------------------- + # Find gz-sim + gz_find_package(gz-sim7 REQUIRED) + set(GZ_SIM_VER ${gz-sim7_VERSION_MAJOR}) + + #-------------------------------------- + # Find SDFormat + gz_find_package(sdformat13 REQUIRED) + set(SDF_VER ${sdformat13_VERSION_MAJOR}) + + message(STATUS "Compiling against Gazebo Garden") + +# Harmonic +elseif("$ENV{GZ_VERSION}" STREQUAL "harmonic") + + #-------------------------------------- + # Find gz-msgs + gz_find_package(gz-msgs10 REQUIRED) + set(GZ_MSGS_VER ${gz-msgs10_VERSION_MAJOR}) + + #-------------------------------------- + # Find gz-transport + gz_find_package(gz-transport13 REQUIRED) + set(GZ_TRANSPORT_VER ${gz-transport13_VERSION_MAJOR}) + + #-------------------------------------- + # Find gz-rendering + gz_find_package(gz-rendering8 REQUIRED) + set(GZ_RENDERING_VER ${gz-rendering8_VERSION_MAJOR}) + + #-------------------------------------- + # Find gz-sim + gz_find_package(gz-sim8 REQUIRED) + set(GZ_SIM_VER ${gz-sim8_VERSION_MAJOR}) + + #-------------------------------------- + # Find SDFormat + gz_find_package(sdformat14 REQUIRED) + set(SDF_VER ${sdformat14_VERSION_MAJOR}) + + message(STATUS "Compiling against Gazebo Harmonic") +else() + message(FATAL_ERROR "Unsupported GZ_VERSION: $ENV{GZ_VERSION}") +endif() #-------------------------------------- # Find OGRE diff --git a/gz-waves/src/WavefieldSampler.cc b/gz-waves/src/WavefieldSampler.cc index 6fe054d0..2a830bf4 100644 --- a/gz-waves/src/WavefieldSampler.cc +++ b/gz-waves/src/WavefieldSampler.cc @@ -94,8 +94,8 @@ void WavefieldSampler::ApplyPose(const gz::math::Pose3d& pose) it.second != std::end(target.vertices()); ++it.first, ++it.second) { - auto& v0 = *it.first; - auto& v1 = *it.second; + const auto& v0 = *it.first; + const auto& v1 = *it.second; const cgal::Point3& p0 = source.point(v0); // Transformation: slide the patch in the xy - plane only diff --git a/gz-waves/src/gui/plugins/waves_control/CMakeLists.txt b/gz-waves/src/gui/plugins/waves_control/CMakeLists.txt index efbf3f6f..4f4b7051 100644 --- a/gz-waves/src/gui/plugins/waves_control/CMakeLists.txt +++ b/gz-waves/src/gui/plugins/waves_control/CMakeLists.txt @@ -8,7 +8,25 @@ project(WavesControl) set(CMAKE_AUTOMOC ON) -find_package(gz-sim7 REQUIRED COMPONENTS gui) +# Garden (default) +if("$ENV{GZ_VERSION}" STREQUAL "garden" OR NOT DEFINED "ENV{GZ_VERSION}") + + find_package(gz-sim7 REQUIRED COMPONENTS gui) + set(GZ_SIM_VER ${gz-sim7_VERSION_MAJOR}) + + message(STATUS "Compiling against Gazebo Garden") + +# Harmonic +elseif("$ENV{GZ_VERSION}" STREQUAL "harmonic") + + find_package(gz-sim8 REQUIRED COMPONENTS gui) + set(GZ_SIM_VER ${gz-sim8_VERSION_MAJOR}) + + message(STATUS "Compiling against Gazebo Harmonic") +else() + message(FATAL_ERROR "Unsupported GZ_VERSION: $ENV{GZ_VERSION}") +endif() + QT5_ADD_RESOURCES(resources_RCC ${PROJECT_NAME}.qrc) @@ -17,5 +35,5 @@ add_library(${PROJECT_NAME} SHARED ${resources_RCC} ) target_link_libraries(${PROJECT_NAME} - PRIVATE gz-sim7::gui + PRIVATE gz-sim${GZ_SIM_VER}::gui ) diff --git a/gz-waves/src/systems/hydrodynamics/Hydrodynamics.cc b/gz-waves/src/systems/hydrodynamics/Hydrodynamics.cc index 2045f80d..42b4fee9 100644 --- a/gz-waves/src/systems/hydrodynamics/Hydrodynamics.cc +++ b/gz-waves/src/systems/hydrodynamics/Hydrodynamics.cc @@ -91,8 +91,8 @@ void ApplyPose( it.second != std::end(_target.vertices()); ++it.first, ++it.second) { - auto& v0 = *it.first; - auto& v1 = *it.second; + const auto& v0 = *it.first; + const auto& v1 = *it.second; const cgal::Point3& p0 = _source.point(v0); // Affine transformation @@ -183,7 +183,7 @@ math::AxisAlignedBox CreateAxisAlignedBox(cgal::MeshPtr _mesh) double max_y = min_y; double max_z = min_z; - for (auto& vertex : _mesh->vertices()) + for (const auto& vertex : _mesh->vertices()) { auto& point = _mesh->point(vertex); min_x = std::min(point.x(), min_x);