WSF
WsfTSPI_Mover.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2003-2015 The Boeing Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11// ****************************************************************************
12// Updated by Infoscitex, a DCS Company.
13// ****************************************************************************
14
15#ifndef WSFTSPI_MOVER_HPP
16#define WSFTSPI_MOVER_HPP
17
18#include "wsf_export.h"
19
20#include <iosfwd>
21#include <string>
22
23class UtInput;
24#include "UtOptional.hpp"
25#include "UtVec3dX.hpp"
26
27class WsfDraw;
28#include "WsfEvent.hpp"
29#include "WsfMover.hpp"
30#include "WsfTSPI.hpp"
31
34
36{
37public:
45
46 WsfTSPI_Mover() = delete;
47 WsfTSPI_Mover(WsfScenario& aScenario);
48 ~WsfTSPI_Mover() override;
49
50 WsfMover* Clone() const override;
51 bool Initialize(double aSimTime) override;
52 bool ProcessInput(UtInput& aInput) override;
53 void Update(double aSimTime) override;
54
56
57 bool IsStopped() const override;
58 bool IsPaused() const override;
59 bool IsExtrapolating() const override;
60
62 {
63 };
64
65 bool InitializeMover(double aSimTime);
66 void CloseFile();
67 void OpenFile(const std::string& aFileName);
68
69 double SimStartTime() const { return mStartTime; }
70 double TSPI_StartTime() const { return mTSPI_StartTime; }
71 std::string FileName() const { return mFileName; }
72
73 bool SetFileName(const std::string& aName);
74 void SetStartAtInitialTime(bool aValue) { mStartAtInitialTime = aValue; }
75 void SetDeleteOnDestruct(bool aValue) { mDeleteOnDestruct = aValue; }
76
77 void TriggerExtrapolation() override;
78
79 struct Point
80 {
81 Point(const WsfTSPI& aPoint);
82
84 UtVec3dX mOrigLocWCS_SL; // at sea level, no alt
85 UtVec3dX mOrigFRDinXYZ; // Original Body Pointing Angles
86
88 UtVec3dX mMovedLocWCS_SL; // at sea level, no alt
89 UtVec3dX mMovedFRDinXYZ; // Translated Body Pointing Angles
90 };
91
93 {
94 bool mTransformIsNeeded = false;
95 bool mTranslateIsNeeded = false;
96 bool mStartPointIsAnchor = true; // else Anchor is End Point.
97
98 ut::optional<double> mGC_AnchorHeadingRad; // may be input or calculated from user inputs
99 ut::optional<double> mGreatCircleLat; // if both mGreatCircleLat and mGreatCircleLon
100 ut::optional<double> mGreatCircleLon; // are zero, then use the mNewHeadingRad value.
101 };
102
103 // Modified to return true if successful, false if EOF.
104 // Modified to return true if successful, false if EOF.
105 bool Fetch_TSPI();
106
108
109 void NormalizeLatLonDeg(double& aLatitudeDeg, double& aLongitudeDeg);
110
112 {
113 public:
115 InitializeMoverEvent(double aSimTime, WsfTSPI_Mover* aMoverPtr);
116
117 EventDisposition Execute() override;
118
119 private:
120 WsfTSPI_Mover* mMoverPtr;
121 };
122
123
127 {
128 public:
129 TSPI_Model(double aSimTime,
130 double aStartTime,
131 double aTSPI_StartTime,
132 WsfStringId aModelTypeId,
133 const WsfTSPI_Mover* aTSPI_MoverPtr,
134 WsfDraw* aDrawPtr = nullptr); // If we want to draw the trajectory.
135
136 bool GetLocationXYZ(double aTime, double aLocXYZ[3]) const override;
137
138 bool GetVelocityXYZ(double aTime, double aVelXYZ[3]) const override;
139
140 protected:
141 struct Point
142 {
143 Point(double aTimeStamp, const double aLocXYZ[3]);
145 double mLocXYZ[3]; // Spherical
146 double mVelXYZ[3]; // Spherical
147 };
148
149 void Add(const Point& aPoint);
150
152 std::vector<Point> mPoints;
153 };
154
156 WsfStringId aModelTypeId,
157 const double aLocationWCS[3],
158 const double aVelocityWCS[3],
159 WsfMover* aMoverPtr,
160 WsfDraw* aDrawPtr) const override;
161
162protected:
163 void UpdateMover(double aSimTime);
164
165private:
166 void ReadTSPI();
167 void TranslateLocation();
168
169 bool ProcessInputRelocateAndRotate(UtInput& aInput);
171 static UtDCM ComputeTranslationTransform(const UtVec3dX& aAnchor, double aTargetLat, double aTargetLon);
173 static UtDCM ComputeRotationTransform(const UtVec3dX& aAnchor, const UtVec3dX& aNonAnchor, const PathMovement& aMovement);
175 static void TransformPoints(std::vector<Point>& aPoints, const UtDCM& aTransform);
176
177 std::ifstream* mInputStreamPtr;
178 std::string mFileName;
179 bool mIsOpen;
180 bool mEOF;
181 bool mIsInitialized;
182 bool mTranslate;
183 bool mStartAtInitialTime;
184 bool mDeleteOnDestruct;
185 bool mIsExtrapolating;
186 EndPath mAtEndOfPath;
187 double mStartTime;
188 double mTSPI_StartTime;
189 double mCurrentUpdateTime;
190 double mDeltaLat;
191 double mDeltaLon;
192 double mRefLat = 0;
193 double mRefLon = 0;
194
195 WsfTSPI mLastTSPI;
196 WsfTSPI mCurrentTSPI;
197 WsfTSPI mReadTSPI;
198
199 PathMovement mMovement;
200};
201
202#endif
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
WsfSpatialDomain
A collection of enumerations and type definitions that are used across a number of components.
Definition WsfTypes.hpp:32
@ WSF_SPATIAL_DOMAIN_AIR
Cars, trucks, buildings, etc.
Definition WsfTypes.hpp:35
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
Provides the capability to draw shapes into the WSF replay file.
Definition WsfDraw.hpp:35
WsfEvent()=default
EventDisposition
Definition WsfEvent.hpp:37
Definition WsfMover.hpp:286
bool ProcessInput(UtInput &aInput) override
Definition WsfMover.cpp:138
bool Initialize(double aSimTime) override
Definition WsfMover.cpp:108
virtual void TriggerExtrapolation()
Definition WsfMover.cpp:623
virtual bool IsStopped() const
Return whether the mover (and its attached platform) is stopped.
Definition WsfMover.cpp:551
WsfMover * Clone() const override=0
virtual KinematicModel * CreateKinematicModel(double aSimTime, WsfStringId aPlatformTypeId, const double aLocationWCS[3], const double aVelocityWCS[3], WsfMover *aMoverPtr, WsfDraw *aDrawPtr) const
Definition WsfMover.hpp:335
WsfMover()=delete
virtual bool IsExtrapolating() const
Definition WsfMover.cpp:576
virtual bool IsPaused() const
Definition WsfMover.cpp:561
void Update(double aSimTime) override
Definition WsfMover.cpp:310
Contains the data required to create a simulation, and acts as the entry point for input file process...
Definition WsfScenario.hpp:111
EventDisposition Execute() override
Definition WsfTSPI_Mover.cpp:477
InitializeMoverEvent()
Definition WsfTSPI_Mover.cpp:463
Definition WsfTSPI_Mover.hpp:62
std::vector< Point > mPoints
Definition WsfTSPI_Mover.hpp:152
TSPI_Model(double aSimTime, double aStartTime, double aTSPI_StartTime, WsfStringId aModelTypeId, const WsfTSPI_Mover *aTSPI_MoverPtr, WsfDraw *aDrawPtr=nullptr)
Definition WsfTSPI_Mover.cpp:824
bool GetVelocityXYZ(double aTime, double aVelXYZ[3]) const override
Definition WsfTSPI_Mover.cpp:920
bool GetLocationXYZ(double aTime, double aLocXYZ[3]) const override
Definition WsfTSPI_Mover.cpp:891
void Add(const Point &aPoint)
Definition WsfTSPI_Mover.cpp:958
double mTSPI_StartTime
Definition WsfTSPI_Mover.hpp:151
WsfTSPI_Mover()=delete
void TranslateAndRotateToNewFile()
Definition WsfTSPI_Mover.cpp:264
EndPath
End of-path option.
Definition WsfTSPI_Mover.hpp:40
@ cEP_EXTRAPOLATE
Extrapolate at end-of-path.
Definition WsfTSPI_Mover.hpp:41
@ cEP_STOP
Stop at end-of-path.
Definition WsfTSPI_Mover.hpp:42
@ cEP_REMOVE
Remove the platform at end-of-path.
Definition WsfTSPI_Mover.hpp:43
void CloseFile()
Close the TSPI input file.
Definition WsfTSPI_Mover.cpp:759
void OpenFile(const std::string &aFileName)
Definition WsfTSPI_Mover.cpp:775
bool InitializeMover(double aSimTime)
Definition WsfTSPI_Mover.cpp:489
void SetStartAtInitialTime(bool aValue)
Definition WsfTSPI_Mover.hpp:74
std::string FileName() const
Definition WsfTSPI_Mover.hpp:71
void UpdateMover(double aSimTime)
Definition WsfTSPI_Mover.cpp:697
double TSPI_StartTime() const
Definition WsfTSPI_Mover.hpp:70
void SetDeleteOnDestruct(bool aValue)
Definition WsfTSPI_Mover.hpp:75
void NormalizeLatLonDeg(double &aLatitudeDeg, double &aLongitudeDeg)
Fix Latitude and Longitude within conventional limits.
Definition WsfTSPI_Mover.cpp:499
WsfSpatialDomain GetSpatialDomain() const override
Definition WsfTSPI_Mover.hpp:55
bool Fetch_TSPI()
Definition WsfTSPI_Mover.cpp:574
double SimStartTime() const
Definition WsfTSPI_Mover.hpp:69
A Time-Space-Position-Information (TSPI) class.
Definition WsfTSPI.hpp:34
Definition WsfTSPI_Mover.hpp:93
bool mTranslateIsNeeded
Definition WsfTSPI_Mover.hpp:95
ut::optional< double > mGC_AnchorHeadingRad
Definition WsfTSPI_Mover.hpp:98
ut::optional< double > mGreatCircleLat
Definition WsfTSPI_Mover.hpp:99
bool mTransformIsNeeded
Definition WsfTSPI_Mover.hpp:94
ut::optional< double > mGreatCircleLon
Definition WsfTSPI_Mover.hpp:100
bool mStartPointIsAnchor
Definition WsfTSPI_Mover.hpp:96
UtVec3dX mMovedFRDinXYZ
Definition WsfTSPI_Mover.hpp:89
UtVec3dX mOrigFRDinXYZ
Definition WsfTSPI_Mover.hpp:85
WsfTSPI mOrigTSPI
Definition WsfTSPI_Mover.hpp:83
WsfTSPI mMovedTSPI
Definition WsfTSPI_Mover.hpp:87
UtVec3dX mOrigLocWCS_SL
Definition WsfTSPI_Mover.hpp:84
Point(const WsfTSPI &aPoint)
Definition WsfTSPI_Mover.cpp:800
UtVec3dX mMovedLocWCS_SL
Definition WsfTSPI_Mover.hpp:88
Definition WsfTSPI_Mover.hpp:142
double mLocXYZ[3]
Definition WsfTSPI_Mover.hpp:145
double mVelXYZ[3]
Definition WsfTSPI_Mover.hpp:146
double mTimeStamp
Definition WsfTSPI_Mover.hpp:144
Point(double aTimeStamp, const double aLocXYZ[3])
Definition WsfTSPI_Mover.cpp:949
Copyrights Multiple, All Rights Reserved