FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
WaypointRefGen.h
1#pragma once
2
45#include <Eigen/Eigen>
46#include <vector>
47#include <string>
48#include <fhsim/simobject/SimObject.h>
49#ifdef FH_VISUALIZATION
50#pragma warning(push)
51#pragma warning( disable : 4251 )
52 #include <Ogre.h>
53#pragma warning(pop)
54#endif
55#include "Waypoint.h"
56
57
58namespace Ship{
59 class WaypointRefGen : public SimObject
60 {
61 public:
62 EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
63 WaypointRefGen(const std::string& simObjectName, ISimObjectCreator* const creator);
65 const double* DesiredQuaternion(const double T, const double* const X);
66 const double* DesiredHeading(const double T, const double* const X);
67 const double* DesiredHeadingRate(const double T, const double* const X);
68 const double* CrossTrackError(const double T, const double* const X);
69 const double* DesiredPosition(const double T,const double* const X);
70 const double* DesiredSpeed(const double T,const double* const X);
71 void OdeFcn(const double T, const double *const X,double *const ) const{}
72 void FinalSetup(const double T,const double* const X, ISimObjectCreator* const creator);
73 void Compute(const double T,const double* const X) const;
74 void AcceptedStep(double T, const double* X) override;
75
76 #ifdef FH_VISUALIZATION
77 void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const creator);
78 void RenderUpdate(const double T, const double* const X);
79 #endif
80
81
82 private:
83 ISignalPort* m_adStatePositionPort;
84 ISignalPort* m_adStateVelocityPort;
85 ICommonComputation *m_Compute;
86
87 mutable std::vector<Waypoint> m_aWPList;
88
89 mutable Eigen::Vector3d m_adStatePosition;
90 Eigen::Vector3d m_adStateVelocity;
91 Eigen::Vector3d m_adStateVelocity_Desired;
92
93 std::string sideslipCompensation;
94
95 double initialPosition[3];
96 double* pK;
97 mutable double desiredHeading;
98 mutable double desiredHeadingRate;
99 mutable double crosstrackError;
100 double m_dLookaheadDistance;
101 double m_lookahead;
102 double m_dSideSlipAngle;
103 double alphaK;
104 double m_adStateTheta_Desired[4];
105 mutable double desiredPosition[3];
106 mutable double m_desiredSpeed;
107 int numberOfPoints;
108
109 int iCurrentWaypointNumber;
110
111 std::vector<double> waypoint_n;
112 std::vector<double> waypoint_e;
113 std::vector<double> waypoint_d;
114 std::vector<double> waypoint_r;
115 std::vector<double> waypoint_leg_speed;
116 double m_sectionType;
117
118 std::vector<Eigen::Vector3d> legstart;
119 std::vector<Eigen::Vector3d> legend;
120 std::vector<Eigen::Vector3d> circle_center;
121 std::vector<double> circle_radius;
122
123 #ifdef FH_VISUALIZATION
124 Ogre::SceneNode** m_wpNodes;
125 Ogre::SceneNode** m_legNodes;
126
127 Ogre::SceneNode** m_turnNodes;
128 Ogre::SceneNode** m_circNodes;
129
130 Ogre::SceneNode* m_LOSNode;
131 Ogre::SceneNode* m_TargetPointNode;
132
133 Ogre::ManualObject* sigth;
134 #endif
135 };
136}
Definition WaypointRefGen.h:60
void AcceptedStep(double T, const double *X) override
switches to the next waypoint when the vessel is inside the circle of acceptance of the target
WaypointRefGen(const std::string &simObjectName, ISimObjectCreator *const creator)
reads parameters, registers states, input/output ports and shared resources
Superclass of control algorithms for the control system.
Definition CableAttach.h:58