263#include "SampleClock.h"
264#include "SensorFrame.h"
265#include "SensorNoise.h"
267#include <fhsim/simobject/SimObject.h>
269#include <marenv/marenv.h>
276class EnvironmentProvider;
383 static double AltitudeOf(
double slantRange,
const double beamDirection[3]);
465 const std::string& fieldName,
double depth,
marenv::Status status);
474 static double NoiseFloorLinear(
double noiseSvAt1mDb,
double absorptionDbPerKm,
double range);
477 void OdeFcn(
const double dT,
const double*
const adX,
double*
const adXDot)
const override;
492 void FinalSetup(
const double dT,
const double*
const adX, ISimObjectCreator*
const creator)
override;
494#ifdef FH_VISUALIZATION
505 void RenderInit(Ogre::Root*
const ogreRoot, ISimObjectCreator*
const creator)
override;
512 void RenderUpdate(
const double dT,
const double*
const adX)
override;
522 const std::vector<Species>&
GetSpecies()
const {
return m_species; }
528 const std::vector<double>&
Frequencies()
const {
return m_frequencykHz; }
538 const double*
OutAltitude(
const double dT,
const double*
const adX);
541 const double*
OutValid(
const double dT,
const double*
const adX);
544 const double*
OutPingTime(
const double dT,
const double*
const adX);
548 struct BeamFieldWarnings
550 bool outOfRange =
false;
558 void ReadFrequencyArrays(ISimObjectCreator*
const creator);
564 void ReadFileParameters(ISimObjectCreator*
const creator);
570 void ResolveEnvironment(ISimObjectCreator*
const creator);
578 void ResolveSpecies(ISimObjectCreator*
const creator);
585 void Ping(
double dT,
const double*
const adX);
595 double MeasureBottom(
double dT,
const double position[3],
const double beamDown[3]);
609 void WriteBeam(
double dT,
const double position[3],
const double direction[3],
610 const char* beamLabel,
double beamRange,
double bottomRange, BeamFieldWarnings& warned);
619 static double RangeToSurface(
const double position[3],
const double direction[3],
double maxRange);
625 void OpenFileAndWriteHeader(ISimObjectCreator*
const creator);
628 void Warn(
const std::string& text)
const;
637 std::vector<std::string> m_speciesFieldNames;
638 bool m_autoDiscover =
false;
639 std::vector<Species> m_species;
641 std::vector<double> m_frequencykHz;
642 std::vector<double> m_absorptionDbPerKm;
643 std::vector<double> m_bottomBackscatterDb;
644 std::vector<double> m_noiseSvAt1mDb;
645 std::vector<double> m_svBiasDb;
647 bool m_writeFile =
true;
648 std::string m_fileName;
649 int m_flushEveryNPings = 20;
650 int m_svPrecision = 2;
652 std::unique_ptr<std::ofstream> m_stream;
654 environment::EnvironmentProvider* m_environment =
nullptr;
655 PrintDuringExec* m_print =
nullptr;
657 bool m_hasPorts =
false;
658 int m_pingsTaken = 0;
660 BeamFieldWarnings m_downFieldWarned;
661 BeamFieldWarnings m_upFieldWarned;
666 std::vector<double> m_binConcentration;
671#ifdef FH_VISUALIZATION
672 Ogre::SceneManager* m_sceneMgr =
nullptr;
673 Ogre::SceneNode* m_beamNode =
nullptr;
674 Ogre::ManualObject* m_beamObject =
nullptr;
Definition SampleClock.h:40
Definition SensorEchosounder.h:280
static double NoiseFloorLinear(double noiseSvAt1mDb, double absorptionDbPerKm, double range)
const double * OutSeafloorDepth(const double dT, const double *const adX)
The inferred depth of the seafloor, m.
const double * OutAltitude(const double dT, const double *const adX)
The measured height above the seafloor, m.
const double * OutValid(const double dT, const double *const adX)
One when the last ping found a bottom, zero otherwise.
const std::vector< double > & Frequencies() const
The operating frequencies, kHz.
Definition SensorEchosounder.h:528
static double BackscatterCrossSection(const Species &species, double frequencykHz)
static double SampleRangeOf(int bin, double binSize, double beamRange)
static double AltitudeOf(double slantRange, const double beamDirection[3])
void FinalSetup(const double dT, const double *const adX, ISimObjectCreator *const creator) override
static double PerturbRange(double trueRange, const Settings &settings, SensorNoise &noise)
int PingsTaken() const
The number of pings taken so far.
Definition SensorEchosounder.h:525
const double * OutSeafloorDistance(const double dT, const double *const adX)
The measured slant range to the seafloor, m.
static double TargetStrengthDb(const Species &species, double frequencykHz)
static double BottomClearance(double rayTolerance, const double beamDirection[3])
SensorEchosounder(std::string simObjectName, const Settings &settings)
static int BinCountOf(double range, double binSize)
void OdeFcn(const double dT, const double *const adX, double *const adXDot) const override
Writes no derivatives: this SimObject declares no states.
SensorEchosounder(std::string simObjectName, ISimObjectCreator *creator)
const std::vector< Species > & GetSpecies() const
The species entering the acoustic model, in file column order.
Definition SensorEchosounder.h:522
const Reading & HeldReading() const
The reading currently held on the output ports.
Definition SensorEchosounder.h:516
static double DownSampleRangeOf(int bin, double binSize, double bottomRange, double clearance)
~SensorEchosounder() override
Flushes and closes the echogram file, and releases the visualisation geometry.
static bool IsValidMaxRange(double maxRange)
const double * OutPingTime(const double dT, const double *const adX)
The time of the ping the held reading came from, s.
static bool IsValidRaySearch(double rayStepSize, double rayTolerance)
void AcceptedStep(const double dT, const double *const adX) override
const Settings & GetSettings() const
The settings the instrument was built with.
Definition SensorEchosounder.h:519
static std::string FieldStatusWarning(const std::string &sensorName, const char *beamLabel, const std::string &fieldName, double depth, marenv::Status status)
Definition SensorFrame.h:36
Definition SensorNoise.h:39
Status
Definition marenv.h:40
The altimeter reading held on the output ports between pings.
Definition SensorEchosounder.h:305
double valid
One when a bottom was found, zero otherwise.
Definition SensorEchosounder.h:309
double pingTime
The time of the ping this reading came from, s.
Definition SensorEchosounder.h:310
double seafloorDepth
The inferred depth of the seafloor, m.
Definition SensorEchosounder.h:307
double seafloorDistance
The measured slant range to the seafloor, m.
Definition SensorEchosounder.h:306
double altitude
The measured height above the seafloor, m.
Definition SensorEchosounder.h:308
Everything the instrument is configured with.
Definition SensorEchosounder.h:284
double independentSamplesPerBin
The Gamma shape of the speckle.
Definition SensorEchosounder.h:298
double rayTolerance
The convergence tolerance of the ray intersection, m.
Definition SensorEchosounder.h:289
double maxRangeUp
The longest slant range binned upwards, m.
Definition SensorEchosounder.h:287
double rangeNoiseRelative
The relative range noise standard deviation.
Definition SensorEchosounder.h:292
double beamWidthDeg
The full opening angle of the drawn beam, degrees. Visualisation only.
Definition SensorEchosounder.h:294
double rangeBias
The constant offset of the measured range, m.
Definition SensorEchosounder.h:290
double svFloorDb
The lowest Sv ever reported, dB.
Definition SensorEchosounder.h:297
double rayStepSize
The search step of the ray intersection, m.
Definition SensorEchosounder.h:288
unsigned int noiseSeed
The random seed; zero is a perfect instrument.
Definition SensorEchosounder.h:300
double maxRangeDown
The longest slant range searched downwards, m.
Definition SensorEchosounder.h:286
double rangeNoiseStd
The absolute range noise standard deviation, m.
Definition SensorEchosounder.h:291
double binSize
The echogram range bin size, m.
Definition SensorEchosounder.h:296
double pingPeriod
The time between pings, s.
Definition SensorEchosounder.h:285
One species as the acoustic model sees it.
Definition SensorEchosounder.h:315
int handle
The field handle, resolved once in FinalSetup.
Definition SensorEchosounder.h:317
double slopeDbPerOctave
The target strength slope with frequency, dB per octave.
Definition SensorEchosounder.h:322
std::string name
The scalar field name.
Definition SensorEchosounder.h:316
double refFreqkHz
The frequency the target strength was measured at, kHz.
Definition SensorEchosounder.h:321
double tsRefDb
The target strength constant at the reference frequency, dB.
Definition SensorEchosounder.h:320
double lengthM
The median animal length, m.
Definition SensorEchosounder.h:319
double massKg
The mass of one animal, kg.
Definition SensorEchosounder.h:318