FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
TrawlGeometryController.h
1#pragma once
2
106#include "sfh/filters/FIR.h"
107
108#include <array>
109#include <fhsim/simobject/SimObject.h>
110#include <memory>
111#include <string>
112#include <vector>
113
114class TrawlGeometryController : public SimObject
115{
116public:
117 TrawlGeometryController(const std::string& simObjectName, ISimObjectCreator* const creator);
118
119 void OdeFcn(const double T, const double* const X, double* const XDot) const override;
120 void InitialConditionSetup(const double T, const double* const currentIC, double* const updatedIC, ISimObjectCreator* const creator) override;
121 void AcceptedStep(const double T, const double* const X) override;
122
123protected:
126 {
127 public:
128 RateLimitedFIR(int size, int order, double updatePeriod);
130 bool AddMeasurement(const double measurement[], double time);
131 const double* GetValue() { return m_filter.GetValue(); }
132
133 private:
134 sfh::filters::FIR m_filter;
135 double m_updatePeriod;
136 double m_lastUpdate = 0.0;
137 bool m_hasUpdate = false;
138 };
139
141 std::array<double, 2> MeanWingPosition(const double T, const double* const X) const;
142
144 std::vector<double> WarpsTooLong(const double T, const double* const X) const;
145
147 double BottomContactError() const;
148
149 const double* OutWarpLength(const double T, const double* const X, const int index);
150 const double* OutNetWidth(const double T, const double* const X, const int index);
151 const double* OutMinBottomContact(const double T, const double* const X);
152
153 std::vector<ISignalPort*> m_inNetPortPos;
154 std::vector<ISignalPort*> m_inNetStbPos;
155 std::vector<ISignalPort*> m_inBottomContact;
156 ISignalPort* m_inWarpLength = nullptr;
157 ISignalPort* m_inExternalEnable = nullptr;
158 std::unique_ptr<RateLimitedFIR> m_bottomContactFilter;
159
160 int m_numNets;
161 int m_numWarps;
162 int m_numBottomContactMeasurements;
163 bool m_controlBottomContact;
164 double m_initialWarpLength = 0.0;
165 double m_minBottomContactGoal;
166 double m_sinkTimeConstant;
167 double m_controllerMaxSpeedDepth;
168 double m_controllerMaxSpeedGeometry;
169 double m_controllerConstant;
170 double m_controllerDamping;
171 int m_indexStateWarpLength;
172
173 // Updated in AcceptedStep.
174 bool m_hasLastStep = false;
175 double m_lastTime = 0.0;
176 double m_minBottomContact = 0.0;
177 double m_lastBottomContactError = 0.0;
179 double m_lastBottomContactUpdate = 0.0;
180 bool m_hasBottomContactUpdate = false;
181 std::vector<double> m_lastWarpTooLong;
182 bool m_hasTravelReference = false;
183 std::array<double, 2> m_travelReference = {0.0, 0.0};
184 std::array<double, 2> m_travelDirection = {0.0, 0.0};
185
186 std::vector<double> m_outNetWidth;
187};
A FIR filter fed at a fixed period, whatever the step length.
Definition TrawlGeometryController.h:126
bool AddMeasurement(const double measurement[], double time)
Adds measurement once per update period since the last update (once, on the first call); true if it a...
Definition TrawlGeometryController.h:115
std::vector< double > m_outNetWidth
One value per Net<N>Width port: readers on other threads keep the pointer (FISH-0107).
Definition TrawlGeometryController.h:186
std::array< double, 2 > MeanWingPosition(const double T, const double *const X) const
The mean horizontal wing position of all nets.
std::vector< double > WarpsTooLong(const double T, const double *const X) const
How much too long each warp is, from the starboard lead of each net along the direction of travel [m]...
double m_bottomContactErrorRate
Between the last two filter updates [m/s].
Definition TrawlGeometryController.h:178
std::array< double, 2 > m_travelDirection
Unit vector, or zero before the first 1 m of travel.
Definition TrawlGeometryController.h:184
double BottomContactError() const
The bottom contact error of the last accepted step, as an equivalent warp length [m].
std::array< double, 2 > m_travelReference
The mean wing position the travel is measured from.
Definition TrawlGeometryController.h:183