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
123#ifdef FH_VISUALIZATION
124 void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const creator) { }
125 void RenderUpdate(const double T, const double* const X) { }
126#endif
127
128protected:
131 {
132 public:
133 RateLimitedFIR(int size, int order, double updatePeriod);
135 bool AddMeasurement(const double measurement[], double time);
136 const double* GetValue() { return m_filter.GetValue(); }
137
138 private:
139 sfh::filters::FIR m_filter;
140 double m_updatePeriod;
141 double m_lastUpdate = 0.0;
142 bool m_hasUpdate = false;
143 };
144
146 std::array<double, 2> MeanWingPosition(const double T, const double* const X) const;
147
149 std::vector<double> WarpsTooLong(const double T, const double* const X) const;
150
152 double BottomContactError() const;
153
154 const double* OutWarpLength(const double T, const double* const X, const int index);
155 const double* OutNetWidth(const double T, const double* const X, const int index);
156 const double* OutMinBottomContact(const double T, const double* const X);
157
158 std::vector<ISignalPort*> m_inNetPortPos;
159 std::vector<ISignalPort*> m_inNetStbPos;
160 std::vector<ISignalPort*> m_inBottomContact;
161 ISignalPort* m_inWarpLength = nullptr;
162 ISignalPort* m_inExternalEnable = nullptr;
163 std::unique_ptr<RateLimitedFIR> m_bottomContactFilter;
164
165 int m_numNets;
166 int m_numWarps;
167 int m_numBottomContactMeasurements;
168 bool m_controlBottomContact;
169 double m_initialWarpLength = 0.0;
170 double m_minBottomContactGoal;
171 double m_sinkTimeConstant;
172 double m_controllerMaxSpeedDepth;
173 double m_controllerMaxSpeedGeometry;
174 double m_controllerConstant;
175 double m_controllerDamping;
176 int m_indexStateWarpLength;
177
178 // Updated in AcceptedStep.
179 bool m_hasLastStep = false;
180 double m_lastTime = 0.0;
181 double m_minBottomContact = 0.0;
182 double m_lastBottomContactError = 0.0;
184 double m_lastBottomContactUpdate = 0.0;
185 bool m_hasBottomContactUpdate = false;
186 std::vector<double> m_lastWarpTooLong;
187 bool m_hasTravelReference = false;
188 std::array<double, 2> m_travelReference = {0.0, 0.0};
189 std::array<double, 2> m_travelDirection = {0.0, 0.0};
190
191 double m_outNetWidth = 0.0;
192};
A FIR filter fed at a fixed period, whatever the step length.
Definition TrawlGeometryController.h:131
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::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:183
std::array< double, 2 > m_travelDirection
Unit vector, or zero before the first 1 m of travel.
Definition TrawlGeometryController.h:189
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:188