-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Maritime tutorials 💧 - Part 4 of 4 (#2260)
* Adding a maritime surface vehicle tutorial. --------- Signed-off-by: Carlos Agüero <[email protected]> Co-authored-by: Alejandro Hernández Cordero <[email protected]> Co-authored-by: crvogt <[email protected]> Co-authored-by: Ian Chen <[email protected]>
- Loading branch information
1 parent
beada29
commit 8f84b05
Showing
42 changed files
with
388,808 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -336,4 +336,4 @@ | |
<scene> | ||
<instance_visual_scene url="#Scene"/> | ||
</scene> | ||
</COLLADA> | ||
</COLLADA> |
71 changes: 71 additions & 0 deletions
71
tutorials/files/surface_vehicles/gazebo_maritime_ws/src/gazebo_maritime/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) | ||
|
||
project(gazebo_maritime) | ||
|
||
find_package(gz-sim8 REQUIRED) | ||
set(GZ_SIM_VER ${gz-sim8_VERSION_MAJOR}) | ||
find_package(gz-common5 REQUIRED COMPONENTS graphics) | ||
set(GZ_COMMON_VER ${gz-common5_VERSION_MAJOR}) | ||
find_package(gz-math7 REQUIRED) | ||
set(GZ_MATH_VER ${gz-math7_VERSION_MAJOR}) | ||
find_package(gz-msgs10 REQUIRED) | ||
set(GZ_MSGS_VER ${gz-msgs10_VERSION_MAJOR}) | ||
find_package(gz-transport13 REQUIRED) | ||
set(GZ_TRANSPORT_VER ${gz-transport13_VERSION_MAJOR}) | ||
find_package(gz-plugin2 REQUIRED COMPONENTS loader register) | ||
set(GZ_PLUGIN_VER ${gz-plugin2_VERSION_MAJOR}) | ||
find_package(gz-rendering8 REQUIRED) | ||
set(GZ_RENDERING_VER ${gz-rendering8_VERSION_MAJOR}) | ||
find_package(gz-sensors8 REQUIRED) | ||
set(GZ_SENSORS_VER ${gz-sensors8_VERSION_MAJOR}) | ||
find_package(gz-utils2 REQUIRED) | ||
set(GZ_UTILS_VER ${gz-utils2_VERSION_MAJOR}) | ||
find_package(sdformat14 REQUIRED) | ||
find_package(Eigen3 REQUIRED) | ||
|
||
# Waves | ||
add_library(Waves SHARED | ||
src/Wavefield.cc | ||
) | ||
target_link_libraries(Waves PUBLIC | ||
Eigen3::Eigen | ||
gz-common${GZ_COMMON_VER}::gz-common${GZ_COMMON_VER} | ||
gz-math${GZ_MATH_VER} | ||
gz-msgs${GZ_MSGS_VER}::gz-msgs${GZ_MSGS_VER} | ||
gz-sim${GZ_SIM_VER}::core | ||
) | ||
install( | ||
TARGETS Waves | ||
DESTINATION lib) | ||
|
||
# Other plugins | ||
list(APPEND MARITIME_GZ_PLUGINS | ||
PublisherPlugin | ||
Surface | ||
WaveVisual | ||
) | ||
|
||
foreach(PLUGIN ${MARITIME_GZ_PLUGINS}) | ||
add_library(${PLUGIN} SHARED src/${PLUGIN}.cc) | ||
target_link_libraries(${PLUGIN} PUBLIC | ||
Eigen3::Eigen | ||
gz-plugin${GZ_PLUGIN_VER}::gz-plugin${GZ_PLUGIN_VER} | ||
gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} | ||
gz-sensors${GZ_SENSORS_VER}::gz-sensors${GZ_SENSORS_VER} | ||
gz-sim${GZ_SIM_VER}::core | ||
gz-transport${GZ_TRANSPORT_VER}::gz-transport${GZ_TRANSPORT_VER} | ||
gz-utils${GZ_UTILS_VER}::gz-utils${GZ_UTILS_VER} | ||
Waves | ||
) | ||
endforeach() | ||
|
||
install( | ||
TARGETS ${MARITIME_GZ_PLUGINS} | ||
DESTINATION lib) | ||
|
||
#============================================================================ | ||
# Resources | ||
install(DIRECTORY | ||
models | ||
worlds | ||
DESTINATION share/${PROJECT_NAME}) |
73 changes: 73 additions & 0 deletions
73
...me_ws/src/gazebo_maritime/models/coast_waves/materials/programs/GerstnerWaves_fs_330.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright (c) 2016 The UUV Simulator Authors. | ||
// All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#version 330 | ||
|
||
////////// Input parameters ////////// | ||
// Textures | ||
uniform sampler2D bumpMap; | ||
uniform samplerCube cubeMap; | ||
|
||
// Colors | ||
uniform vec4 deepColor; | ||
uniform vec4 shallowColor; | ||
uniform float fresnelPower; | ||
uniform float hdrMultiplier; | ||
|
||
////////// Input computed in vertex shader ////////// | ||
in block | ||
{ | ||
mat3 rotMatrix; | ||
vec3 eyeVec; | ||
vec2 bumpCoord; | ||
} inPs; | ||
|
||
out vec4 fragColor; | ||
|
||
void main() | ||
{ | ||
// Apply bump mapping to normal vector to make waves look more detailed: | ||
vec4 bump = texture(bumpMap, inPs.bumpCoord)*2.0 - 1.0; | ||
vec3 N = normalize(inPs.rotMatrix * bump.xyz); | ||
|
||
// Reflected ray: | ||
vec3 E = normalize(inPs.eyeVec); | ||
vec3 R = reflect(E, N); | ||
|
||
// negate z for use with the skybox texture that comes with gz-rendering | ||
R = vec3(R.x, R.y, -R.z); | ||
|
||
// uncomment this line if using other textures that are Y up | ||
// Gazebo requires rotated cube map lookup. | ||
// R = vec3(R.x, R.z, R.y); | ||
|
||
// Get environment color of reflected ray: | ||
vec4 envColor = texture(cubeMap, R, 0.0); | ||
|
||
// Cheap hdr effect: | ||
envColor.rgb *= (envColor.r+envColor.g+envColor.b)*hdrMultiplier; | ||
|
||
// Compute refraction ratio (Fresnel): | ||
float facing = 1.0 - dot(-E, N); | ||
float waterEnvRatio = clamp(pow(facing, fresnelPower), 0.05, 1.0); | ||
|
||
// Refracted ray only considers deep and shallow water colors: | ||
vec4 waterColor = mix(shallowColor, deepColor, facing); | ||
|
||
// Perform linear interpolation between reflection and refraction. | ||
vec4 color = mix(waterColor, envColor, waterEnvRatio); | ||
|
||
fragColor = vec4(color.xyz, 0.9); | ||
} |
Oops, something went wrong.