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 m_isPort;
151 double m_mass;
152 double m_massMin;
153 double m_massMax;
155 double m_size;
156
157 environment::SeafloorForcesInterface* m_seafloorForces = nullptr;
158 environment::EnvironmentProvider* m_environment = nullptr;
159
160 std::vector<ISignalPort*> m_inForces;
161 ISignalPort* m_inDistanceGoal;
162 ISignalPort* m_inDistance;
163 ISignalPort* m_inBottomForceGoal = nullptr;
164 ISignalPort* m_inMassGoal = nullptr;
165
166 int m_IStatePos;
167 int m_IStateVel;
168 int m_IStateIntegratedSpreadError;
170 int m_IStateMass = -1;
171
174
175 double m_outLift = 0.0;
176 double m_outDrag = 0.0;
177 double m_outWeight = 0.0;
178 double m_outBottomContact = 0.0;
179
180#ifdef FH_VISUALIZATION
181 Ogre::SceneNode* m_renderNode = nullptr;
182#endif
183};
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:164
double m_mass
The mass [kg], with WeightModel::Controlled.
Definition TrawlDoorControlledLift.h:151
double m_massMax
The largest mass [kg], with WeightModel::Mass.
Definition TrawlDoorControlledLift.h:153
double m_massMin
The smallest mass [kg], with WeightModel::Mass.
Definition TrawlDoorControlledLift.h:152
PidWithExternalState m_weightController
Weight from the bottom force error.
Definition TrawlDoorControlledLift.h:173
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:170
ISignalPort * m_inBottomForceGoal
With WeightModel::Controlled.
Definition TrawlDoorControlledLift.h:163
double m_liftDragRatio
Lift divided by drag.
Definition TrawlDoorControlledLift.h:154
bool m_isPort
Is this the port door?
Definition TrawlDoorControlledLift.h:149
double m_size
The diameter of the contact sphere [m].
Definition TrawlDoorControlledLift.h:155
PidWithExternalState m_distanceController
Lift from the spread error.
Definition TrawlDoorControlledLift.h:172
Loads ComputeLoads(const double T, const double *const X) const
The loads at (T, X).
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:169
bool m_useWidthMeasurement
Is Distance a measured width, rather than a reference position?
Definition TrawlDoorControlledLift.h:150
WeightModel m_weightModel
What sets the weight.
Definition TrawlDoorControlledLift.h:148
The forces and controller errors at one time and state.
Definition TrawlDoorControlledLift.h:128