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

incoming wave height service #152

Merged
merged 20 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ab5960b
update spring to match at-sea polytropic process
andermi Jun 26, 2023
605c60d
can now specify spring params per batch
andermi Jun 27, 2023
36c4eb9
tune spring to match atsea
andermi Jul 6, 2023
b831d13
ros2 service for incwave height; issues so replace LinearIncidentWave…
andermi Jul 12, 2023
36c6b45
use parent folder for FreeSurfaceHydrodynamics includes
andermi Aug 9, 2023
d47aedf
add matrix_mode: False option to sim params yaml to allow vectorized …
andermi Aug 9, 2023
b79cd37
Merge branch 'andermi/fix_fshydro_includes' into andermi/atsea_spring
andermi Aug 9, 2023
353b83d
Merge branch 'andermi/add_vectorized_batch_mode' into andermi/atsea_s…
andermi Aug 9, 2023
51a58f4
Merge branch 'andermi/atsea_spring' into andermi/incoming_wave_service
andermi Aug 22, 2023
c3bfe60
added latent data and tweaked incwaveheight
andermi Aug 24, 2023
8fdfc12
can specify incwaveheight points in sdf
andermi Aug 24, 2023
39e063a
linters
andermi Aug 29, 2023
2d88d78
Merge branch 'main' into andermi/incoming_wave_service
andermi Aug 31, 2023
436a990
separate sdf incwaveheight points from service call; allow service to…
andermi Sep 6, 2023
a22f451
linters
andermi Sep 6, 2023
0950bb3
use array for relative_time/absolute_time in incwaveheight service re…
andermi Sep 6, 2023
3d8843e
always report incwaveheight in world coords
andermi Sep 6, 2023
a2af6c3
temporary checkout of andermi/incoming_wave_service in mbari_wec_util…
andermi Sep 6, 2023
1927170
linters
andermi Sep 6, 2023
13e7708
Update build-and-test.sh
andermi Sep 7, 2023
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
23 changes: 23 additions & 0 deletions buoy_description/models/mbari_wec_ros/model.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,29 @@
<publish_rate>10</publish_rate>
</plugin>

<plugin filename="LatentData" name="buoy_gazebo::LatentDataPublisher">
<namespace>/</namespace>
<node_name>latent_data</node_name>
<ros2_topic>latent_data</ros2_topic>
<publish_rate>10</publish_rate>
</plugin>

<plugin filename="IncWaveHeight" name="buoy_gazebo::IncWaveHeight">
<namespace>/</namespace>
<node_name>inc_wave_service</node_name>
<points use_buoy_origin="true">
<xy>-1.0 -1.0</xy>
<xy>0.0 -1.0</xy>
<xy>1.0 -1.0</xy>
<xy>-1.0 0.0</xy>
<xy>0.0 0.0</xy>
<xy>1.0 0.0</xy>
<xy>-1.0 1.0</xy>
<xy>0.0 1.0</xy>
<xy>1.0 1.0</xy>
</points>
</plugin>

<plugin
filename="gz-sim-joint-state-publisher-system"
name="gz::sim::systems::JointStatePublisher">
Expand Down
8 changes: 4 additions & 4 deletions buoy_gazebo/src/IncidentWaves/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ find_package(Boost 1.71.0 COMPONENTS system iostreams filesystem)

gz_add_plugin(IncidentWaves
SOURCES
IncidentWaves.cpp
IncidentWaves.cpp
PUBLIC_LINK_LIBS
FreeSurfaceHydrodynamics
INCLUDE_DIRS
..
../..
)

target_link_libraries(IncidentWaves PUBLIC FreeSurfaceHydrodynamics)

6 changes: 4 additions & 2 deletions buoy_gazebo/src/IncidentWaves/IncWaveState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@
#include <gz/sim/components/Factory.hh>
#include <gz/sim/components/Component.hh>
#include <gz/sim/config.hh>

#include <FreeSurfaceHydrodynamics/LinearIncidentWave.hpp>


namespace buoy_gazebo
{
/// \brief Structure that holds shared ptr to incident wave object(s), and other data
/// \brief Structure that holds incident wave object(s), and other data
struct IncWaveState
{
std::shared_ptr<LinearIncidentWave> Inc;
LinearIncidentWave Inc;
double x;
double y;
};
Expand Down
15 changes: 7 additions & 8 deletions buoy_gazebo/src/IncidentWaves/IncidentWaves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class IncidentWavesPrivate
/// \brief Model interface
gz::sim::Model model{gz::sim::kNullEntity};

std::shared_ptr<LinearIncidentWave> Inc = std::make_shared<LinearIncidentWave>();
LinearIncidentWave Inc{};

gz::sim::Entity IncWaveEntity;
buoy_gazebo::IncWaveState inc_wave_state;
Expand Down Expand Up @@ -82,7 +82,7 @@ void IncidentWaves::Configure(
}

double seed = SdfParamDouble(_sdf, "IncWaveSeed", 0.0);
this->dataPtr->Inc->SetSeed(seed);
this->dataPtr->Inc.SetSeed(seed);

auto linkName = _sdf->Get<std::string>("LinkName");

Expand All @@ -96,15 +96,15 @@ void IncidentWaves::Configure(
double A = SdfParamDouble(_sdf, "A", 0.0);
double T = SdfParamDouble(_sdf, "T", 14.0);
double phase = SdfParamDouble(_sdf, "Phase", 0.0);
this->dataPtr->Inc->SetToMonoChromatic(A, T, phase, beta);
this->dataPtr->Inc.SetToMonoChromatic(A, T, phase, beta);
}

if (!SpectrumType.compare("Bretschneider")) {
gzdbg << "SpectrumType " << SpectrumType << std::endl;
double Hs = SdfParamDouble(_sdf, "Hs", 0.0);
double Tp = SdfParamDouble(_sdf, "Tp", 14.0);
gzdbg << "Hs = " << Hs << " Tp = " << Tp << std::endl;
this->dataPtr->Inc->SetToBretschneiderSpectrum(Hs, Tp, beta);
this->dataPtr->Inc.SetToBretschneiderSpectrum(Hs, Tp, beta);
}

if (!SpectrumType.compare("Custom")) {
Expand All @@ -124,7 +124,7 @@ void IncidentWaves::Configure(
}

if (freq.size() > 2) { // \TODO(anyone): Add more checks on validity of spectrum
this->dataPtr->Inc->SetToCustomSpectrum(freq, S, beta);
this->dataPtr->Inc.SetToCustomSpectrum(freq, S, beta);
} else {
gzwarn << "Ill-formed custom wave-spectrum specification, no waves added" << std::endl;
}
Expand Down Expand Up @@ -153,8 +153,7 @@ void IncidentWaves::PreUpdate(
}
auto SimTime = std::chrono::duration<double>(_info.simTime).count();


// buoy_gazebo::IncWaveState inc_wave_state;
// buoy_gazebo::IncWaveState inc_wave_state;
if (_ecm.EntityHasComponentType(
this->dataPtr->IncWaveEntity,
buoy_gazebo::components::IncWaveState().TypeId()))
Expand All @@ -165,7 +164,7 @@ void IncidentWaves::PreUpdate(
this->dataPtr->inc_wave_state = buoy_gazebo::IncWaveState(inc_wave_state_comp->Data());
}
double deta_dx{0.0}, deta_dy{0.0};
double eta = this->dataPtr->Inc->eta(
double eta = this->dataPtr->Inc.eta(
this->dataPtr->inc_wave_state.x,
this->dataPtr->inc_wave_state.y,
SimTime, &deta_dx, &deta_dy);
Expand Down
6 changes: 6 additions & 0 deletions buoy_gazebo/src/LatentData/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
file(GLOB dirs LIST_DIRECTORIES true *)
foreach(dir ${dirs})
if(IS_DIRECTORY ${dir})
add_subdirectory(${dir})
endif()
endforeach()
16 changes: 16 additions & 0 deletions buoy_gazebo/src/LatentData/IncWaveHeight/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
find_package(FreeSurfaceHydrodynamics REQUIRED)
set(BOOST_USE_STATIC_LIBS OFF)
set(BOOST_USE_MULTITHREADED ON)
set(BOOST_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.71.0 COMPONENTS system iostreams filesystem)

gz_add_plugin(IncWaveHeight
SOURCES
IncWaveHeight.cpp
PUBLIC_LINK_LIBS
FreeSurfaceHydrodynamics
INCLUDE_DIRS
../..
..
ROS
)
Loading
Loading