Skip to content

Ocean waves and WAM-V #27

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

Open
wants to merge 6 commits into
base: ros2
Choose a base branch
from
Open
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
226 changes: 226 additions & 0 deletions gazebo/dave_gz_world_plugins/ocean-waves/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
cmake_minimum_required(VERSION 3.10.2)

#============================================================================
# Initialize the project
#============================================================================
project(wave VERSION 1.0.0)

# --------------------------------------------------------------------------- #
# If ament_cmake is found build as an ament package, otherwise ignore.
# This is so the system may be built for Gazebo only, if ROS is not available.
# find_package(ament_cmake QUIET)
# if(${ament_cmake_FOUND})
# message("Building ${PROJECT_NAME} as an `ament_cmake` project.")
# endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-Wno-psabi)
endif()

#============================================================================
# Find gz-cmake
#============================================================================
find_package(gz-cmake3 REQUIRED)
set(GZ_CMAKE_VER ${gz-cmake3_VERSION_MAJOR})

#============================================================================
# Configure the project
#============================================================================
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

gz_configure_project()

#============================================================================
# Include cmake
#============================================================================

include(${PROJECT_SOURCE_DIR}/cmake/URL.conf.cmake)

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

#============================================================================
# Set project-specific options
#============================================================================

#============================================================================
# Search for project-specific dependencies
#============================================================================

#--------------------------------------
# Find gnuplot-iostream - the header is used by the examples in test/plots
include(Add_gnuplot-iostream)


# Harmonic
#--------------------------------------
# Find gz-math
gz_find_package(gz-math7 REQUIRED COMPONENTS eigen3)
set(GZ_MATH_VER ${gz-math7_VERSION_MAJOR})

#--------------------------------------
# Find gz-plugin
gz_find_package(gz-plugin2 REQUIRED COMPONENTS loader register)
set(GZ_PLUGIN_VER ${gz-plugin2_VERSION_MAJOR})

#--------------------------------------
# Find gz-common
gz_find_package(gz-common5
REQUIRED COMPONENTS graphics events
)
set(GZ_COMMON_VER ${gz-common5_VERSION_MAJOR})

#--------------------------------------
# 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")

#--------------------------------------
# Find OGRE
list(APPEND gz_ogre_components "RTShaderSystem" "Terrain" "Overlay" "Paging")

gz_find_package(GzOGRE VERSION 1.9.0
COMPONENTS ${gz_ogre_components}
REQUIRED_BY ogre
PRIVATE_FOR ogre)

#--------------------------------------
# Find OGRE2: first try to find OGRE2 built with PlanarReflections support and
# fallback to look for OGRE2 without it. Both seems to works for gz-rendering.
# See https://github.com/gazebosim/gz-rendering/issues/597
gz_find_package(GzOGRE2 VERSION 2.3
COMPONENTS HlmsPbs HlmsUnlit Overlay PlanarReflections
PRIVATE_FOR ogre2
QUIET)

if("${OGRE2-PlanarReflections}" STREQUAL "OGRE2-PlanarReflections-NOTFOUND")
message(STATUS "PlanarReflections component was not found. Try looking without it:")
gz_find_package(GzOGRE2 VERSION 2.3
COMPONENTS HlmsPbs HlmsUnlit Overlay
REQUIRED_BY ogre2
PRIVATE_FOR ogre2)
endif()

if(OGRE2_FOUND)
set(HAVE_OGRE2 TRUE)
endif()

#####################################
# Define compile-time default variables
if(MSVC)
set(GZ_RENDERING_PLUGIN_PATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR})
else()
set(GZ_RENDERING_PLUGIN_PATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
endif()

#--------------------------------------
# Find eigen3

find_package(Eigen3 REQUIRED)

#--------------------------------------
# CGAL and its components...

find_package(CGAL REQUIRED COMPONENTS Core)

if(NOT CGAL_FOUND)
message(STATUS "This project requires the CGAL library, and will not be compiled.")
return()
endif()

# message("CGAL_VERSION_MAJOR: ${CGAL_VERSION_MAJOR}")

if(${CGAL_VERSION_MAJOR} LESS 6)
# include helper file
include(${CGAL_USE_FILE})
endif()

#--------------------------------------
# Find FFTW3 (double-precision) (GPL) as FFT library.

find_path(FFTW3-3_INCLUDE_DIR
NAMES fftw3.h
HINTS $ENV{FFTW3_DIR}/include
PATHS /usr/local/include
/usr/include
)

find_library(FFTW3-3_LIBRARY
NAMES fftw3 libfftw3
HINTS $ENV{FFTW3_DIR}/lib
PATHS /usr/local/lib
/usr/lib
)

add_definitions(-DUSE_FFTW3)
set(FFT_INCLUDE_DIRS ${FFTW3-3_INCLUDE_DIR})
set(FFT_LIBRARIES ${FFTW3-3_LIBRARY})

#--------------------------------------
# Find OpenCL

# find_package(OpenCL REQUIRED)

#--------------------------------------
# Find clFFT

# find_package(clFFT REQUIRED)

#============================================================================

# Location of "fake install folder" used in tests
# Defined here at root scope so it is available for tests in src and test folders
# set(FAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/fake/install")

#============================================================================
# Configure the build
#============================================================================

gz_configure_build(QUIT_IF_BUILD_ERRORS)

# add_subdirectory(examples)

#============================================================================
# Create package information
#============================================================================
gz_create_packages()

# --------------------------------------------------------------------------- #
# Register as an ament package if ament_cmake is available.
# if(${ament_cmake_FOUND})
# # Environment hooks
# ament_environment_hooks(
# "${CMAKE_CURRENT_SOURCE_DIR}/hooks/${PROJECT_NAME}.dsv.in"
# )

# ament_package()
# endif()


#============================================================================
# Configure documentation
#============================================================================

# TODO: add documentation api.md.in files
16 changes: 16 additions & 0 deletions gazebo/dave_gz_world_plugins/ocean-waves/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
For ocean-waves, you must add environment variables to your launch file to set the wave parameters.

```
# ensure the system plugins are found
export GZ_SIM_SYSTEM_PLUGIN_PATH=\
$GZ_SIM_SYSTEM_PLUGIN_PATH:\
/home/docker/HOST/dave_ws/install/wave/lib

# ensure the gui plugin is found
export GZ_GUI_PLUGIN_PATH=\
$GZ_GUI_PLUGIN_PATH:\
/home/docker/HOST/dave_ws/install/wave/src/gui/plugins/waves_control/build

# For current ogre vendor package bug, this is required (July 7, 2025)
ln -s /opt/ros/jazzy/opt/gz_ogre_next_vendor/lib/libOgreNextMain.so.2.3.3 /opt/ros/jazzy/opt/gz_ogre_next_vendor/lib/libOgreNextMain.so.2.3.1
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
include(FetchContent)

set(GnuPlotIostream_BuildTests OFF CACHE INTERNAL "BuildTests OFF")
set(GnuPlotIostream_BuildExamples OFF CACHE INTERNAL "BuildExamples OFF")

FetchContent_Declare(
gnuplot-iostream
GIT_REPOSITORY ${gnuplot-iostream_URL}
GIT_TAG ${gnuplot-iostream_TAG}
)

FetchContent_MakeAvailable(gnuplot-iostream)

# The project does not set gnuplot-iostream_INCLUDE_DIRS so use
# gnuplot-iostream_SOURCE_DIR instead.
set(gnuplot-iostream_INCLUDE_DIRS ${gnuplot-iostream_SOURCE_DIR})
8 changes: 8 additions & 0 deletions gazebo/dave_gz_world_plugins/ocean-waves/cmake/URL.conf.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

# Declare the PATH, TAG and PATCH used by FetchContent

# gnuplot-iostream: master HEAD
set(gnuplot-iostream_URL https://github.com/dstahlke/gnuplot-iostream.git)
set(gnuplot-iostream_TAG d674bdf23b93c76d491f03246d2e6f72bf5739ce
CACHE STRING "gnuplot-iostream version")

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
prepend-non-duplicate;GZ_SIM_SYSTEM_PLUGIN_PATH;lib/@PROJECT_NAME@/
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(gz)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_subdirectory(common)
add_subdirectory(waves)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# gz_install_all_headers()
Loading