Wavefield.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Rhys Mainwaring
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #include <Eigen/Dense>
19 
20 #include <array>
21 #include <cmath>
22 #include <iostream>
23 #include <string>
24 
25 #include <gazebo/gazebo.hh>
26 #include <gazebo/common/common.hh>
27 #include <gazebo/msgs/msgs.hh>
28 
29 #include <ignition/math/Pose3.hh>
30 #include <ignition/math/Vector2.hh>
31 #include <ignition/math/Vector3.hh>
32 
37 
38 namespace asv
39 {
41 // Utilities
42 
43  std::ostream& operator<<(std::ostream& os, const std::vector<double>& _vec)
44  {
45  for (auto&& v : _vec ) // NOLINT
46  os << v << ", ";
47  return os;
48  }
49 
51 // WaveParametersPrivate
52 
56  {
59  model(""),
60  number(1),
61  scale(2.0),
62  angle(2.0*M_PI/10.0),
63  steepness(1.0),
64  amplitude(0.0),
65  period(1.0),
66  phase(0.0),
67  direction(1, 0),
68  angularFrequency(2.0*M_PI),
69  wavelength(2*M_PI/Physics::DeepWaterDispersionToWavenumber(2.0*M_PI)),
70  wavenumber(Physics::DeepWaterDispersionToWavenumber(2.0*M_PI)),
71  tau(1.0),
72  gain(1.0)
73  {
74  }
75 
77  public: std::string model;
78 
80  public: size_t number;
81 
83  public: double scale;
84 
86  public: double angle;
87 
89  public: double steepness;
90 
92  public: double amplitude;
93 
95  public: double period;
96 
98  public: double phase;
99 
101  public: ignition::math::Vector2d direction;
102 
104  public: double tau;
105 
107  public: double gain;
108 
110  public: double angularFrequency;
111 
113  public: double wavelength;
114 
116  public: double wavenumber;
117 
119  public: std::vector<double> angularFrequencies;
120 
122  public: std::vector<double> amplitudes;
123 
125  public: std::vector<double> phases;
126 
128  public: std::vector<double> steepnesses;
129 
131  public: std::vector<double> wavenumbers;
132 
134  public: std::vector<ignition::math::Vector2d> directions;
135 
137  public: void RecalculateCmr()
138  {
139  // Normalize direction
140  this->direction = Geometry::Normalize(this->direction);
141 
142  // Derived mean values
143  this->angularFrequency = 2.0 * M_PI / this->period;
144  this->wavenumber = \
145  Physics::DeepWaterDispersionToWavenumber(this->angularFrequency);
146  this->wavelength = 2.0 * M_PI / this->wavenumber;
147 
148  // Update components
149  this->angularFrequencies.clear();
150  this->amplitudes.clear();
151  this->phases.clear();
152  this->wavenumbers.clear();
153  this->steepnesses.clear();
154  this->directions.clear();
155 
156  for (size_t i = 0; i < this->number; ++i)
157  {
158  const int n = i - this->number/2;
159  const double scaleFactor = std::pow(this->scale, n);
160  const double a = scaleFactor * this->amplitude;
161  const double k = this->wavenumber / scaleFactor;
162  const double omega = Physics::DeepWaterDispersionToOmega(k);
163  const double phi = this->phase;
164  double q = 0.0;
165  if (a != 0)
166  {
167  q = std::min(1.0, this->steepness / (a * k * this->number));
168  }
169 
170  this->amplitudes.push_back(a);
171  this->angularFrequencies.push_back(omega);
172  this->phases.push_back(phi);
173  this->steepnesses.push_back(q);
174  this->wavenumbers.push_back(k);
175 
176  // Direction
177  const double c = std::cos(n * this->angle);
178  const double s = std::sin(n * this->angle);
179  // const TransformMatrix T(
180  // c, -s,
181  // s, c
182  // );
183  // const ignition::math::Vector2d d = T(this->direction);
184  const ignition::math::Vector2d d(
185  c * this->direction.X() - s * this->direction.Y(),
186  s * this->direction.X() + c * this->direction.Y());
187  directions.push_back(d);
188  }
189  }
190 
191  // \brief Pierson-Moskowitz wave spectrum
192  public: double pm(double omega, double omega_p)
193  {
194  double alpha = 0.0081;
195  double g = 9.81;
196  return alpha*std::pow(g, 2.0)/std::pow(omega, 5.0)* \
197  std::exp(-(5.0/4.0)*std::pow(omega_p/omega, 4.0));
198  }
199 
201  public: void RecalculatePms()
202  {
203  // Normalize direction
204  this->direction = Geometry::Normalize(this->direction);
205 
206  // Derived mean values
207  this->angularFrequency = 2.0 * M_PI / this->period;
208  this->wavenumber = \
209  Physics::DeepWaterDispersionToWavenumber(this->angularFrequency);
210  this->wavelength = 2.0 * M_PI / this->wavenumber;
211 
212  // Update components
213  this->angularFrequencies.clear();
214  this->amplitudes.clear();
215  this->phases.clear();
216  this->wavenumbers.clear();
217  this->steepnesses.clear();
218  this->directions.clear();
219 
220  // Vector for spaceing
221  std::vector<double> omega_spacing;
222  omega_spacing.push_back(this->angularFrequency*(1.0-1.0/this->scale));
223  omega_spacing.push_back(this->angularFrequency* \
224  (this->scale-1.0/this->scale)/2.0);
225  omega_spacing.push_back(this->angularFrequency*(this->scale-1.0));
226 
227  for (size_t i = 0; i < this->number; ++i)
228  {
229  const int n = i - 1;
230  const double scaleFactor = std::pow(this->scale, n);
231  const double omega = this->angularFrequency*scaleFactor;
232  const double pms = pm(omega, this->angularFrequency);
233  const double a = this->gain*std::sqrt(2.0*pms*omega_spacing[i]);
234  const double k = Physics::DeepWaterDispersionToWavenumber(omega);
235  const double phi = this->phase;
236  double q = 0.0;
237  if (a != 0)
238  {
239  q = std::min(1.0, this->steepness / (a * k * this->number));
240  }
241 
242  this->amplitudes.push_back(a);
243  this->angularFrequencies.push_back(omega);
244  this->phases.push_back(phi);
245  this->steepnesses.push_back(q);
246  this->wavenumbers.push_back(k);
247 
248  // Direction
249  const double c = std::cos(n * this->angle);
250  const double s = std::sin(n * this->angle);
251  // const TransformMatrix T(
252  // c, -s,
253  // s, c
254  // );
255  // const ignition::math::Vector2d d = T(this->direction);
256  const ignition::math::Vector2d d(
257  c * this->direction.X() - s * this->direction.Y(),
258  s * this->direction.X() + c * this->direction.Y());
259  directions.push_back(d);
260  }
261  }
263  public: void Recalculate()
264  {
265  if (!this->model.compare("PMS"))
266  {
267  gzmsg << "Using Pierson-Moskowitz spectrum sampling wavefield model "
268  << std::endl;
269  this->RecalculatePms();
270  }
271  else if (!this->model.compare("CWR"))
272  {
273  gzmsg << "Using Constant wavelength-ampltude ratio wavefield model "
274  << std::endl;
275  this->RecalculateCmr();
276  }
277  else
278  {
279  gzwarn<< "Wavefield model specified as <" << this->model
280  << "> which is not one of the two supported wavefield models: "
281  << "PMS or CWR!!!" << std::endl;
282  }
283  }
284  };
285 
287 // WaveParameters
288 
290  {
291  }
292 
294  : data(new WaveParametersPrivate())
295  {
296  this->data->Recalculate();
297  }
298 
299  void WaveParameters::SetFromSDF(sdf::Element& _sdf)
300  {
301  this->data->model = Utilities::SdfParamString(_sdf, "model", "default");
302  this->data->number = Utilities::SdfParamSizeT(_sdf, "number", \
303  this->data->number);
304  this->data->amplitude = Utilities::SdfParamDouble(_sdf, "amplitude", \
305  this->data->amplitude);
306  this->data->period = Utilities::SdfParamDouble(_sdf, "period", \
307  this->data->period);
308  this->data->phase = Utilities::SdfParamDouble(_sdf, "phase", \
309  this->data->phase);
310  this->data->direction = Utilities::SdfParamVector2(_sdf, "direction", \
311  this->data->direction);
312  this->data->scale = Utilities::SdfParamDouble(_sdf, "scale", \
313  this->data->scale);
314  this->data->angle = Utilities::SdfParamDouble(_sdf, "angle", \
315  this->data->angle);
316  this->data->steepness = Utilities::SdfParamDouble(_sdf, "steepness", \
317  this->data->steepness);
318  this->data->tau = Utilities::SdfParamDouble(_sdf, "tau", \
319  this->data->tau);
320  this->data->gain = Utilities::SdfParamDouble(_sdf, "gain", \
321  this->data->gain);
322  this->data->Recalculate();
323  }
324 
325  size_t WaveParameters::Number() const
326  {
327  return this->data->number;
328  }
329 
330  double WaveParameters::Angle() const
331  {
332  return this->data->angle;
333  }
334 
335  double WaveParameters::Scale() const
336  {
337  return this->data->scale;
338  }
339 
341  {
342  return this->data->steepness;
343  }
344 
346  {
347  return this->data->angularFrequency;
348  }
349 
351  {
352  return this->data->amplitude;
353  }
354 
355  double WaveParameters::Period() const
356  {
357  return this->data->period;
358  }
359 
360  double WaveParameters::Phase() const
361  {
362  return this->data->phase;
363  }
364 
366  {
367  return this->data->wavelength;
368  }
369 
371  {
372  return this->data->wavenumber;
373  }
374 
375  float WaveParameters::Tau() const
376  {
377  return this->data->tau;
378  }
379 
380  float WaveParameters::Gain() const
381  {
382  return this->data->gain;
383  }
384 
385  ignition::math::Vector2d WaveParameters::Direction() const
386  {
387  return this->data->direction;
388  }
389 
390  void WaveParameters::SetNumber(size_t _number)
391  {
392  this->data->number = _number;
393  this->data->Recalculate();
394  }
395 
396  void WaveParameters::SetAngle(double _angle)
397  {
398  this->data->angle = _angle;
399  this->data->Recalculate();
400  }
401 
402  void WaveParameters::SetScale(double _scale)
403  {
404  this->data->scale = _scale;
405  this->data->Recalculate();
406  }
407 
408  void WaveParameters::SetSteepness(double _steepness)
409  {
410  this->data->steepness = _steepness;
411  this->data->Recalculate();
412  }
413 
414  void WaveParameters::SetAmplitude(double _amplitude)
415  {
416  this->data->amplitude = _amplitude;
417  this->data->Recalculate();
418  }
419 
420  void WaveParameters::SetPeriod(double _period)
421  {
422  this->data->period = _period;
423  this->data->Recalculate();
424  }
425 
426  void WaveParameters::SetPhase(double _phase)
427  {
428  this->data->phase = _phase;
429  this->data->Recalculate();
430  }
431 
432  void WaveParameters::SetTau(double _tau)
433  {
434  this->data->tau = _tau;
435  }
436  void WaveParameters::SetGain(double _gain)
437  {
438  this->data->gain = _gain;
439  }
440 
441  void WaveParameters::SetDirection(const ignition::math::Vector2d& _direction)
442  {
443  this->data->direction = _direction;
444  this->data->Recalculate();
445  }
446 
447  const std::vector<double>& WaveParameters::AngularFrequency_V() const
448  {
449  return this->data->angularFrequencies;
450  }
451 
452  const std::vector<double>& WaveParameters::Amplitude_V() const
453  {
454  return this->data->amplitudes;
455  }
456 
457  const std::vector<double>& WaveParameters::Phase_V() const
458  {
459  return this->data->phases;
460  }
461 
462  const std::vector<double>& WaveParameters::Steepness_V() const
463  {
464  return this->data->steepnesses;
465  }
466 
467  const std::vector<double>& WaveParameters::Wavenumber_V() const
468  {
469  return this->data->wavenumbers;
470  }
471 
472  const std::vector<ignition::math::Vector2d>& \
473  WaveParameters::Direction_V() const
474  {
475  return this->data->directions;
476  }
477 
479  {
480  gzmsg << "Input Parameters:" << std::endl;
481  gzmsg << "model: " << this->data->model << std::endl;
482  gzmsg << "number: " << this->data->number << std::endl;
483  gzmsg << "scale: " << this->data->scale << std::endl;
484  gzmsg << "angle: " << this->data->angle << std::endl;
485  gzmsg << "steepness: " << this->data->steepness << std::endl;
486  gzmsg << "amplitude: " << this->data->amplitude << std::endl;
487  gzmsg << "period: " << this->data->period << std::endl;
488  gzmsg << "direction: " << this->data->direction << std::endl;
489  gzmsg << "tau: " << this->data->tau << std::endl;
490  gzmsg << "gain: " << this->data->gain << std::endl;
491  gzmsg << "Derived Parameters:" << std::endl;
492  gzmsg << "amplitudes: " << this->data->amplitudes << std::endl;
493  gzmsg << "wavenumbers: " << this->data->wavenumbers << std::endl;
494  gzmsg << "omegas: " << this->data->angularFrequencies << std::endl;
495  gzmsg << "periods: ";
496  for (auto&& omega : this->data->angularFrequencies) // NOLINT
497  {
498  gzmsg << 2.0 * M_PI / omega <<", ";
499  }
500  gzmsg << std::endl;
501  gzmsg << "phases: " << this->data->phases << std::endl;
502  gzmsg << "steepnesses: " << this->data->steepnesses << std::endl;
503  gzmsg << "directions: ";
504  for (auto&& d : this->data->directions) // NOLINT
505  {
506  gzmsg << d << "; ";
507  }
508  gzmsg << std::endl;
509  }
510 
512 // WavefieldSampler
513 
515  const WaveParameters& _waveParams,
516  const ignition::math::Vector3d& _point,
517  double time,
518  double time_init /*=0*/
519  )
520  {
521  double h = 0.0;
522  for (std::size_t ii = 0; ii < _waveParams.Number(); ++ii)
523  {
524  double k = _waveParams.Wavenumber_V()[ii];
525  double a = _waveParams.Amplitude_V()[ii];
526  double dx = _waveParams.Direction_V()[ii].X();
527  double dy = _waveParams.Direction_V()[ii].Y();
528  double dot = _point.X()*dx + _point.Y()*dy;
529  double omega = _waveParams.AngularFrequency_V()[ii];
530  double theta = k*dot - omega*time;
531  double c = cos(theta);
532  h += a*c;
533  }
534 
535  // Exponentially grow the waves
536  return h*(1-exp(-1.0*(time-time_init)/_waveParams.Tau()));
537  }
538 
540  const WaveParameters& _waveParams,
541  const ignition::math::Vector3d& _point,
542  double time,
543  double time_init)
544  {
545  // Struture for passing wave parameters to lambdas
546  struct WaveParams
547  {
548  WaveParams(
549  const std::vector<double>& _a,
550  const std::vector<double>& _k,
551  const std::vector<double>& _omega,
552  const std::vector<double>& _phi,
553  const std::vector<double>& _q,
554  const std::vector<ignition::math::Vector2d>& _dir) :
555  a(_a), k(_k), omega(_omega), phi(_phi), q(_q), dir(_dir) {}
556 
557  const std::vector<double>& a;
558  const std::vector<double>& k;
559  const std::vector<double>& omega;
560  const std::vector<double>& phi;
561  const std::vector<double>& q;
562  const std::vector<ignition::math::Vector2d>& dir;
563  };
564 
565  // Compute the target function and Jacobian. Also calculate pz,
566  // the z-component of the Gerstner wave, which we essentially get for free.
567  auto wave_fdf = [=](auto x, auto p, auto t, auto& wp, auto& F, auto& J)
568  {
569  double pz = 0;
570  F(0) = p.x() - x.x();
571  F(1) = p.y() - x.y();
572  J(0, 0) = -1;
573  J(0, 1) = 0;
574  J(1, 0) = 0;
575  J(1, 1) = -1;
576  const size_t n = wp.a.size();
577  for (auto&& i = 0; i < n; ++i) // NOLINT
578  {
579  const double dx = wp.dir[i].X();
580  const double dy = wp.dir[i].Y();
581  const double q = wp.q[i];
582  const double a = wp.a[i];
583  const double k = wp.k[i];
584  const double dot = x.x() * dx + x.y() * dy;
585  const double theta = k * dot - wp.omega[i] * t;
586  const double s = std::sin(theta);
587  const double c = std::cos(theta);
588  const double qakc = q * a * k * c;
589  const double df1x = qakc * dx * dx;
590  const double df1y = qakc * dx * dy;
591  const double df2x = df1y;
592  const double df2y = qakc * dy * dy;
593  pz += a * c;
594  F(0) += a * dx * s;
595  F(1) += a * dy * s;
596  J(0, 0) += df1x;
597  J(0, 1) += df1y;
598  J(1, 0) += df2x;
599  J(1, 1) += df2y;
600  }
601  // Exponentially grow the waves
602  return pz * (1-exp(-1.0*(time-time_init)/_waveParams.Tau()));
603  };
604 
605  // Simple multi-variate Newton solver -
606  // this version returns the z-component of the
607  // wave field at the desired point p.
608  auto solver = [=](auto& fdfunc, auto x0, auto p, auto t, \
609  auto& wp, auto tol, auto nmax)
610  {
611  int n = 0;
612  double err = 1;
613  double pz = 0;
614  auto xn = x0;
615  Eigen::Vector2d F;
616  Eigen::Matrix2d J;
617  while (std::abs(err) > tol && n < nmax)
618  {
619  pz = fdfunc(x0, p, t, wp, F, J);
620  xn = x0 - J.inverse() * F;
621  x0 = xn;
622  err = F.norm();
623  n++;
624  }
625  return pz;
626  };
627 
628  // Set up parameter references
629  WaveParams wp(
630  _waveParams.Amplitude_V(),
631  _waveParams.Wavenumber_V(),
632  _waveParams.AngularFrequency_V(),
633  _waveParams.Phase_V(),
634  _waveParams.Steepness_V(),
635  _waveParams.Direction_V());
636 
637  // Tolerances etc.
638  const double tol = 1.0E-10;
639  const double nmax = 30;
640 
641  // Use the target point as the initial guess
642  // (this is within sum{amplitudes} of the solution)
643  Eigen::Vector2d p2(_point.X(), _point.Y());
644  const double pz = solver(wave_fdf, p2, p2, time, wp, tol, nmax);
645  // Removed so that height is reported relative to mean water level
646  // const double h = pz - _point.Z();
647  const double h = pz;
648  return h;
649  }
650 }
d
const std::vector< double > & Amplitude_V() const
Access the component amplitudes.
Definition: Wavefield.cc:452
float Tau() const
Time-constant for starting waves.
Definition: Wavefield.cc:375
double angle
Set the angle between component waves and the mean direction.
Definition: Wavefield.cc:86
void SetPhase(double _phase)
Set the mean wave phase.
Definition: Wavefield.cc:426
void SetPeriod(double _period)
Set the mean wave period. Must be positive.
Definition: Wavefield.cc:420
void SetDirection(const ignition::math::Vector2d &_direction)
Set the mean wave direction.
Definition: Wavefield.cc:441
double Steepness() const
A parameter in [0, 1] controlling the wave steepness with 1 being steepest.
Definition: Wavefield.cc:340
double wavenumber
The mean wavenumber (derived).
Definition: Wavefield.cc:116
static ignition::math::Vector2d Normalize(const ignition::math::Vector2d &_v)
Normalise a Vector2 (i.e. ensure it has unit length)
Definition: Geometry.cc:58
double Amplitude() const
The amplitude of the mean wave in [m].
Definition: Wavefield.cc:350
This file defines utilities for extracting parameters from SDF.
XmlRpcServer s
static ignition::math::Vector2d SdfParamVector2(sdf::Element &_sdf, const std::string &_paramName, const ignition::math::Vector2d _defaultVal)
Extract a named Vector2 parameter from an SDF element.
Definition: Utilities.cc:81
std::vector< ignition::math::Vector2d > directions
The component wave dirctions (derived).
Definition: Wavefield.cc:134
double amplitude
The mean wave amplitude [m].
Definition: Wavefield.cc:92
static std::string SdfParamString(sdf::Element &_sdf, const std::string &_paramName, const std::string &_defaultVal)
Extract a named string parameter from an SDF element.
Definition: Utilities.cc:75
size_t Number() const
The number of wave components (3 max if visualisation required).
Definition: Wavefield.cc:325
double Wavelength() const
The mean wavelength.
Definition: Wavefield.cc:365
void SetTau(double _tau)
Set the time constant.
Definition: Wavefield.cc:432
std::vector< double > phases
The component wave phases (derived).
Definition: Wavefield.cc:125
std::shared_ptr< WaveParametersPrivate > data
Definition: Wavefield.hh:190
void SetGain(double _gain)
Set the PMS amplitude multiplier.
Definition: Wavefield.cc:436
This file contains definitions for the physics models.
static double DeepWaterDispersionToWavenumber(double _omega)
Compute the deep water dispersion.
Definition: Physics.cc:33
This file contains methods to calculate properties of simple geometrical objects. ...
double Angle() const
The angle between the mean wave direction and the largest / smallest component waves.
Definition: Wavefield.cc:330
size_t number
The number of component waves.
Definition: Wavefield.cc:80
ignition::math::Vector2d Direction() const
A two component vector specifiying the direction.
Definition: Wavefield.cc:385
WaveParameters()
Constructor.
Definition: Wavefield.cc:293
A class to manage the parameters for generating a wave.
Definition: Wavefield.hh:58
void DebugPrint() const
Print a summary of the wave parameters to the gzmsg stream.
Definition: Wavefield.cc:478
const std::vector< ignition::math::Vector2d > & Direction_V() const
Access the component directions.
Definition: Wavefield.cc:473
static double SdfParamDouble(sdf::Element &_sdf, const std::string &_paramName, const double _defaultVal)
Extract a named double parameter from an SDF element.
Definition: Utilities.cc:69
double Phase() const
The phase of the mean wave.
Definition: Wavefield.cc:360
void SetFromSDF(sdf::Element &_sdf)
Set the parameters from an SDF Element tree.
Definition: Wavefield.cc:299
std::vector< double > wavenumbers
The component wavenumbers (derived).
Definition: Wavefield.cc:131
void SetAmplitude(double _amplitude)
Set the mean wave amplitude. Must be positive.
Definition: Wavefield.cc:414
ignition::math::Vector2d direction
The mean wave direction.
Definition: Wavefield.cc:101
double AngularFrequency() const
The angular frequency.
Definition: Wavefield.cc:345
WaveParametersPrivate()
Constructor.
Definition: Wavefield.cc:58
void SetSteepness(double _steepness)
Set the steepness parameter controlling the steepness of the waves. In [0, 1].
Definition: Wavefield.cc:408
std::vector< double > amplitudes
The component wave amplitudes (derived).
Definition: Wavefield.cc:122
static double ComputeDepthDirectly(const WaveParameters &_waveParams, const ignition::math::Vector3d &_point, double time, double time_init=0)
Compute the depth at a point directly.
Definition: Wavefield.cc:539
double phase
The mean wave phase (not currently enabled).
Definition: Wavefield.cc:98
const std::vector< double > & Wavenumber_V() const
Access the component wavenumbers.
Definition: Wavefield.cc:467
double Scale() const
The scale between the mean and largest / smallest component waves.
Definition: Wavefield.cc:335
TFSIMD_FORCE_INLINE const tfScalar & x() const
void RecalculatePms()
Recalculate for Pierson-Moskowitz spectrum sampling model.
Definition: Wavefield.cc:201
float Gain() const
Amplitude multiplier for PMS.
Definition: Wavefield.cc:380
double wavelength
The mean wavelength (derived).
Definition: Wavefield.cc:113
void SetNumber(size_t _number)
Set the number of wave components (3 max).
Definition: Wavefield.cc:390
TFSIMD_FORCE_INLINE tfScalar dot(const Quaternion &q1, const Quaternion &q2)
const std::vector< double > & Steepness_V() const
Access the steepness components.
Definition: Wavefield.cc:462
static double ComputeDepthSimply(const WaveParameters &_waveParams, const ignition::math::Vector3d &_point, double time, double time_init=0)
Definition: Wavefield.cc:514
std::vector< double > steepnesses
The component wave steepness factors (derived).
Definition: Wavefield.cc:128
double steepness
Control the wave steepness. 0 is sine waves, 1 is Gerstner waves.
Definition: Wavefield.cc:89
std::string model
Name of wavefield model to use - must be "PMS" or "CWR".
Definition: Wavefield.cc:77
double angularFrequency
The mean wave angular frequency (derived).
Definition: Wavefield.cc:110
Definition: Geometry.hh:28
void RecalculateCmr()
Recalculate for constant wavelength-amplitude ratio.
Definition: Wavefield.cc:137
double tau
The time constant for exponential increasing waves on startup.
Definition: Wavefield.cc:104
This file contains definitions for classes used to manage a wave field. This includes wave parameters...
const std::vector< double > & Phase_V() const
Access the component phases.
Definition: Wavefield.cc:457
double period
The mean wave period [s].
Definition: Wavefield.cc:95
void Recalculate()
Recalculate all derived quantities from inputs.
Definition: Wavefield.cc:263
std::vector< double > angularFrequencies
The component wave angular frequencies (derived).
Definition: Wavefield.cc:119
double scale
Set the scale of the largest and smallest waves.
Definition: Wavefield.cc:83
~WaveParameters()
Destructor.
Definition: Wavefield.cc:289
double Wavenumber() const
The mean wavenumber.
Definition: Wavefield.cc:370
void SetScale(double _scale)
Set the scale parameter controlling the range of amplitudes of the component waves.
Definition: Wavefield.cc:402
double Period() const
The period of the mean wave in [s].
Definition: Wavefield.cc:355
static size_t SdfParamSizeT(sdf::Element &_sdf, const std::string &_paramName, const size_t _defaultVal)
Extract a named size_t parameter from an SDF element.
Definition: Utilities.cc:63
double pm(double omega, double omega_p)
Definition: Wavefield.cc:192
double gain
The multiplier applied to PM spectra.
Definition: Wavefield.cc:107
const std::vector< double > & AngularFrequency_V() const
Access the component angular frequencies.
Definition: Wavefield.cc:447
A collection of static methods for various physics calculations.
Definition: Physics.hh:30
static double DeepWaterDispersionToOmega(double _wavenumber)
Compute the deep water dispersion.
Definition: Physics.cc:26
void SetAngle(double _angle)
Set the angle parameter controlling the direction of the component waves.
Definition: Wavefield.cc:396


wave_gazebo_plugins
Author(s): Rhys Mainwaring
autogenerated on Thu May 7 2020 03:54:44