FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
TrawlDoorControlledLift.h
1#pragma once
2
91#include "trawl/subroutines/PidWithExternalState.h"
92
93#include <fhsim/simobject/SimObject.h>
94#include <fhsim_environment/EnvironmentProvider.h>
95#include <fhsim_environment/SeafloorForcesInterface.h>
96#include <string>
97#include <vector>
98
99class TrawlDoorControlledLift : public SimObject
100{
101public:
102 TrawlDoorControlledLift(const std::string& simObjectName, ISimObjectCreator* creator);
103
104 void OdeFcn(const double T, const double* const X, double* const XDot) const override;
105 void FinalSetup(const double T, const double* const X, ISimObjectCreator* const creator) override;
106 void AcceptedStep(const double T, const double* const X) override;
107
108#ifdef FH_VISUALIZATION
109 void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const creator);
110 void RenderUpdate(const double T, const double* const X);
111#endif
112
113protected:
115 enum class WeightModel
116 {
117 Controlled,
118 Mass,
119 };
120
121 TrawlDoorControlledLift(const std::string& simObjectName, ISimObjectCreator* creator, WeightModel weightModel);
122
124 double Mass(const double* const X) const;
125
127 struct Loads
128 {
129 double lift;
130 double drag;
131 double weight;
132 double seafloor[3];
133 double total[3];
134 double spreadError;
135 double bottomForceError;
136 };
137
139 Loads ComputeLoads(const double T, const double* const X) const;
140
141 const double* OutPos(const double T, const double* const X, const int index);
142 const double* OutVel(const double T, const double* const X, const int index);
143 const double* OutLift(const double T, const double* const X);
144 const double* OutDrag(const double T, const double* const X);
145 const double* OutWeight(const double T, const double* const X);
146 const double* OutBottomContact(const double T, const double* const X);
147
149 bool ResolvedForRead(const char* port);
150
152 bool m_isPort;
154 double m_mass;
155 double m_massMin;
156 double m_massMax;
158 double m_size;
159
160 ISimObjectCreator* m_creator = nullptr;
161 environment::SeafloorForcesInterface* m_seafloorForces = nullptr;
162 environment::EnvironmentProvider* m_environment = nullptr;
163
164 std::vector<ISignalPort*> m_inForces;
165 ISignalPort* m_inDistanceGoal;
166 ISignalPort* m_inDistance;
167 ISignalPort* m_inBottomForceGoal = nullptr;
168 ISignalPort* m_inMassGoal = nullptr;
169
170 int m_IStatePos;
171 int m_IStateVel;
172 int m_IStateIntegratedSpreadError;
174 int m_IStateMass = -1;
175
178
179 double m_outLift = 0.0;
180 double m_outDrag = 0.0;
181 double m_outWeight = 0.0;
182 double m_outBottomContact = 0.0;
183
184#ifdef FH_VISUALIZATION
185 Ogre::SceneNode* m_renderNode = nullptr;
186#endif
187};
PID controller for use inside a SimObject, whose integral is a state that FhSim integrates.
Definition PidWithExternalState.h:44
Definition TrawlDoorControlledLift.h:100
ISignalPort * m_inMassGoal
With WeightModel::Mass.
Definition TrawlDoorControlledLift.h:168
double m_mass
The mass [kg], with WeightModel::Controlled.
Definition TrawlDoorControlledLift.h:154
double m_massMax
The largest mass [kg], with WeightModel::Mass.
Definition TrawlDoorControlledLift.h:156
double m_massMin
The smallest mass [kg], with WeightModel::Mass.
Definition TrawlDoorControlledLift.h:155
PidWithExternalState m_weightController
Weight from the bottom force error.
Definition TrawlDoorControlledLift.h:177
double Mass(const double *const X) const
The mass at X [kg]: the mass state, or the fixed mass.
int m_IStateMass
With WeightModel::Mass.
Definition TrawlDoorControlledLift.h:174
ISignalPort * m_inBottomForceGoal
With WeightModel::Controlled.
Definition TrawlDoorControlledLift.h:167
bool ResolvedForRead(const char *port)
False, after reporting the read of output port port through FhSim, while FinalSetup has not resolved ...
double m_liftDragRatio
Lift divided by drag.
Definition TrawlDoorControlledLift.h:157
bool m_isPort
Is this the port door?
Definition TrawlDoorControlledLift.h:152
double m_size
The diameter of the contact sphere [m].
Definition TrawlDoorControlledLift.h:158
PidWithExternalState m_distanceController
Lift from the spread error.
Definition TrawlDoorControlledLift.h:176
Loads ComputeLoads(const double T, const double *const X) const
The loads at (T, X).
ISimObjectCreator * m_creator
Reports a read before FinalSetup; owned by FhSim.
Definition TrawlDoorControlledLift.h:160
WeightModel
What sets the door's weight in water.
Definition TrawlDoorControlledLift.h:116
@ Controlled
A PID controller on the bottom force error (this class).
@ Mass
A mass state that follows MassGoal (Trawl/TrawlDoorControlledLiftAndMass).
int m_IStateIntegratedBottomForceError
With WeightModel::Controlled.
Definition TrawlDoorControlledLift.h:173
bool m_useWidthMeasurement
Is Distance a measured width, rather than a reference position?
Definition TrawlDoorControlledLift.h:153
WeightModel m_weightModel
What sets the weight.
Definition TrawlDoorControlledLift.h:151
The forces and controller errors at one time and state.
Definition TrawlDoorControlledLift.h:128