From fba4812bf884536a082a0b7f2a1e522dfbcfcb57 Mon Sep 17 00:00:00 2001 From: Rhys Mainwaring Date: Mon, 10 Oct 2022 08:34:24 +0100 Subject: [PATCH] Wave Body: use model:// URI to specify BEM file location (#72) - Use model:// URI syntax to locate BEM data files. Signed-off-by: Rhys Mainwaring --- gz-waves-models/worlds/ellipsoid_buoy.sdf | 333 +++++++++--------- gz-waves-models/worlds/spheroid_test1a.sdf | 3 +- .../linear_wave_body/LinearWaveBody.cc | 8 +- 3 files changed, 176 insertions(+), 168 deletions(-) diff --git a/gz-waves-models/worlds/ellipsoid_buoy.sdf b/gz-waves-models/worlds/ellipsoid_buoy.sdf index e335312e..ea7aaeec 100644 --- a/gz-waves-models/worlds/ellipsoid_buoy.sdf +++ b/gz-waves-models/worlds/ellipsoid_buoy.sdf @@ -104,181 +104,182 @@ - /Users/rhys/Code/robotics/gz_waves_ws/src/asv_wave_sim/gz-waves-models/models/ellipsoid_buoy/config/hydrodata/ellipsoid_f5244.h5 - - - - 6 - 4 - 0 - 0 - - + model://ellipsoid_buoy/config/hydrodata/ellipsoid_f5244.h5 - - - 9.81 - 1025 - + + + + 6 + 4 + 0 + 0 + + - - - 0 0 0 - 0 0 -0.935 - 129.1381 - + + + 9.81 + 1025 + + + + + 0 0 0 + 0 0 -0.935 + 129.1381 + - - - 0 - - - 0. 0. 0. 0. 0. 0. - 0. 0. 0. 0. 0. 0. - 0. 0. 777494.4 -3.6 -402.7 0. - 0. 0. -3.6 6167224.2 -0.1 0. - 0. 0. -402.7 -0.1 6179979.4 0. - 0. 0. 0. 0. 0. 0. - - - - - - 52732.7109003133 -0.0461102712478722 5.88390664387022 0.296417351644741 246367.266847758 -1.69953653780694 - -0.0678279438415122 52944.8240664938 -1.47610970294622 -246974.480351485 -0.376605346811632 34.7833617031108 - 5.56653991122738 0.0361713254775427 197297.142256690 0.802697521049529 -87.4935912381782 -0.0504125898702509 - 0.410840691063419 -247341.339091709 5.02714890072835 1214533.79620113 2.83888902153701 -166.779120688123 - 246734.857503928 -0.346433003966073 -87.1795788996776 2.60143644204397 1215195.98272167 -2.36242713115735 - -1.30857894347732 34.6478012553392 0.0173325214982212 -165.977540011457 -1.09781377470450 108.258384753611 - - - - - 7209.55521458289 -0.00241865277674112 -0.656452733818339 0.0362151909394597 33068.9436025348 -0.277065103262815 - -0.00574983097131929 7224.96421786452 0.0739544503252989 -33093.8859951854 -0.0481987286722465 4.65143300682749 - -0.894991216445364 1.44416946591210 114644.248735475 -6.26262145357765 -57.3651869899508 -0.0632414440092088 - 0.0458640797833837 -33189.4228421519 -2.06423557434899 152022.421220666 0.311347231737735 -21.3664338314253 - 33165.4358604128 -0.0326285489204398 -57.6246853052043 0.264850645030705 152122.332407559 -1.27495177084548 - -0.231015729667316 4.65422866544508 -0.00392458624416725 -21.3177927485565 -1.06001165595936 0.0259605842341352 - - - - - - 3750.27966906368 - 1.36136318915143 - 422045.810882563 - -12.1223298789796 - 17026.4196175993 - -0.120671686522160 - - - 154952.048410117 - 0.0258067417631121 - 119022.435012338 - -1.48920899489199 - 712781.363146319 - -5.43599198405567 - - - - - 9.23543827040243 - 0.0162480147898594 - 622401.014204239 - -6.38980408679980 - -282.389237456753 - -0.000103055222405902 - - - 126959.968499544 - -0.0166309938157517 - -34.6068541762491 - 0.533226736595381 - 590993.613169733 - -3.78930171294708 - - - - - 3741.04423079327 - 1.34511517436157 - -200355.203321676 - -5.73252579217983 - 17308.8088550560 - -0.120568631299754 - - - 27992.0799105738 - 0.0424377355788638 - 119057.041866514 - -2.02243573148737 - 121787.749976586 - -1.64669027110858 - - - - + + + 0 + + + 0. 0. 0. 0. 0. 0. + 0. 0. 0. 0. 0. 0. + 0. 0. 777494.4 -3.6 -402.7 0. + 0. 0. -3.6 6167224.2 -0.1 0. + 0. 0. -402.7 -0.1 6179979.4 0. + 0. 0. 0. 0. 0. 0. + + + + + + 52732.7109003133 -0.0461102712478722 5.88390664387022 0.296417351644741 246367.266847758 -1.69953653780694 + -0.0678279438415122 52944.8240664938 -1.47610970294622 -246974.480351485 -0.376605346811632 34.7833617031108 + 5.56653991122738 0.0361713254775427 197297.142256690 0.802697521049529 -87.4935912381782 -0.0504125898702509 + 0.410840691063419 -247341.339091709 5.02714890072835 1214533.79620113 2.83888902153701 -166.779120688123 + 246734.857503928 -0.346433003966073 -87.1795788996776 2.60143644204397 1215195.98272167 -2.36242713115735 + -1.30857894347732 34.6478012553392 0.0173325214982212 -165.977540011457 -1.09781377470450 108.258384753611 + + + + + 7209.55521458289 -0.00241865277674112 -0.656452733818339 0.0362151909394597 33068.9436025348 -0.277065103262815 + -0.00574983097131929 7224.96421786452 0.0739544503252989 -33093.8859951854 -0.0481987286722465 4.65143300682749 + -0.894991216445364 1.44416946591210 114644.248735475 -6.26262145357765 -57.3651869899508 -0.0632414440092088 + 0.0458640797833837 -33189.4228421519 -2.06423557434899 152022.421220666 0.311347231737735 -21.3664338314253 + 33165.4358604128 -0.0326285489204398 -57.6246853052043 0.264850645030705 152122.332407559 -1.27495177084548 + -0.231015729667316 4.65422866544508 -0.00392458624416725 -21.3177927485565 -1.06001165595936 0.0259605842341352 + + + + + + 3750.27966906368 + 1.36136318915143 + 422045.810882563 + -12.1223298789796 + 17026.4196175993 + -0.120671686522160 + + + 154952.048410117 + 0.0258067417631121 + 119022.435012338 + -1.48920899489199 + 712781.363146319 + -5.43599198405567 + + + + + 9.23543827040243 + 0.0162480147898594 + 622401.014204239 + -6.38980408679980 + -282.389237456753 + -0.000103055222405902 + + + 126959.968499544 + -0.0166309938157517 + -34.6068541762491 + 0.533226736595381 + 590993.613169733 + -3.78930171294708 + + + + + 3741.04423079327 + 1.34511517436157 + -200355.203321676 + -5.73252579217983 + 17308.8088550560 + -0.120568631299754 + + + 27992.0799105738 + 0.0424377355788638 + 119057.041866514 + -2.02243573148737 + 121787.749976586 + -1.64669027110858 + + + + - - - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + - - - 0 - 0 - 0 - 0 - 0 - + + + 0 + 0 + 0 + 0 + 0 + - - - 20 + + + 20 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - /force/gravity - /force/buoyancy - /force/restoring - /force/radiation_damping - /force/radiation_added_mass - /force/excitation - /force/excitation_froude_krylov - /force/excitation_scattering - + /force/gravity + /force/buoyancy + /force/restoring + /force/radiation_damping + /force/radiation_added_mass + /force/excitation + /force/excitation_froude_krylov + /force/excitation_scattering + diff --git a/gz-waves-models/worlds/spheroid_test1a.sdf b/gz-waves-models/worlds/spheroid_test1a.sdf index e3b8497c..e3b98ebc 100644 --- a/gz-waves-models/worlds/spheroid_test1a.sdf +++ b/gz-waves-models/worlds/spheroid_test1a.sdf @@ -53,7 +53,8 @@ - /Users/rhys/Code/robotics/gz_waves_ws/src/asv_wave_sim/gz-waves-models/models/spheroid_test1a/config/hydrodata/spheroid_f3676.h5 + + models://spheroid_test1a/config/hydrodata/spheroid_f3676.h5 diff --git a/gz-waves/src/systems/linear_wave_body/LinearWaveBody.cc b/gz-waves/src/systems/linear_wave_body/LinearWaveBody.cc index 7229f532..7ad82963 100644 --- a/gz-waves/src/systems/linear_wave_body/LinearWaveBody.cc +++ b/gz-waves/src/systems/linear_wave_body/LinearWaveBody.cc @@ -16,6 +16,7 @@ #include "LinearWaveBody.hh" #include +#include #include @@ -763,7 +764,12 @@ void LinearWaveBody::Configure(const Entity &_entity, // 1a. read WEC-Sim hdf5 BEM file if (_sdf->HasElement("hdf5_file")) { - this->dataPtr->hydroData.hdf5File = _sdf->Get("hdf5_file"); + std::string fileUri = _sdf->Get("hdf5_file"); + + // Find the file path + common::SystemPaths systemPaths; + this->dataPtr->hydroData.hdf5File = systemPaths.FindFileURI(fileUri); + this->dataPtr->ReadWECSim(_ecm); } else