Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gazebo: add support for Harmonic #149

Merged
merged 4 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/scripts/brew_install_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,33 @@ do
brew link $DEP_PKG
done
done


# keg only packages to install - only link dependencies
PKGS_KEG_ONLY=(
[email protected]
)

# 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
7 changes: 5 additions & 2 deletions .github/scripts/macos_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/usr/local/opt/[email protected]/lib/pkgc
export CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}:/usr/local/opt/qt@5

# Python scripts installed with: `pip3 install --user <package>`
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-
2 changes: 1 addition & 1 deletion .github/scripts/macos_test.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Python scripts installed with: `pip3 install --user <package>`
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: macOS Monterey Build Tools

on: [push, pull_request]
on: [pull_request]

jobs:
macos-monterey-ci:
Expand All @@ -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
24 changes: 24 additions & 0 deletions .github/workflows/macos13-ventura-build-tools.yml
Original file line number Diff line number Diff line change
@@ -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
42 changes: 42 additions & 0 deletions .github/workflows/macos13-ventura-ci.yml
Original file line number Diff line number Diff line change
@@ -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
86 changes: 62 additions & 24 deletions gz-waves/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions gz-waves/src/WavefieldSampler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 20 additions & 2 deletions gz-waves/src/gui/plugins/waves_control/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
)
6 changes: 3 additions & 3 deletions gz-waves/src/systems/hydrodynamics/Hydrodynamics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down