WSF
WsfSpaceOrientation.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 2017 Infoscitex, a DCS 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#ifndef WSFSPACEORIENTATION_HPP
13#define WSFSPACEORIENTATION_HPP
14
15#include "wsf_space_export.h"
16
17#include <memory>
18#include <string>
19
20#include "UtException.hpp"
21class UtInput;
22#include "UtVec3.hpp"
23
25#include "WsfGeoPoint.hpp"
26#include "WsfObject.hpp"
27#include "WsfTrackId.hpp"
28
29namespace wsf
30{
31
32namespace space
33{
79class WSF_SPACE_EXPORT Orientation : public WsfObject
80{
81public:
82 explicit Orientation(bool aIsDefaultX_Aligned)
83 : mDefaultX_Aligned(aIsDefaultX_Aligned)
84 {
85 }
86
87 Orientation(const Orientation& aSrc) = default;
88 ~Orientation() override = default;
89
90 static std::unique_ptr<Orientation> Factory(const std::string& aOrientation);
91
92 Orientation* Clone() const override = 0;
93
94 const char* GetScriptClassName() const override;
95
97 void SetAttitudeController(const WsfAttitudeController& aController) { mControllerPtr = &aController; }
98
99 bool ProcessInput(UtInput& aInput) override { return false; }
100
104 virtual bool IsValid() const { return true; }
105
110 virtual bool Calculate(double& aPsi, double& aTheta, double& aPhi) const = 0;
111
112 void CalculateAligned(const UtVec3d& aPointingAxisOrientationECI,
113 const UtVec3d& aConstraintAxisOrientationECI,
114 double& aPsi,
115 double& aTheta,
116 double& aPhi) const;
117
118 static void CalculateGeneral(double aYawECS,
119 double aPitchECS,
120 double aRollECS,
121 const UtVec3d& aX_AxisOrientationECI,
122 const UtVec3d& aZ_AxisConstraintECI,
123 double& aPsi,
124 double& aTheta,
125 double& aPhi);
126
127 static void CalculateX_Aligned(const UtVec3d& aX_AxisOrientationECI,
128 const UtVec3d& aZ_AxisConstraintECI,
129 double& aPsi,
130 double& aTheta,
131 double& aPhi);
132
133 static void CalculateZ_Aligned(const UtVec3d& aZ_AxisOrientationECI,
134 const UtVec3d& aX_AxisConstraintECI,
135 double& aPsi,
136 double& aTheta,
137 double& aPhi);
138
139 static void CalculatePCS_DirectionCosines(const UtVec3d& aX_AxisOrientationECI,
140 const UtVec3d& aZ_AxisConstraintECI,
141 UtVec3d& aX_DC,
142 UtVec3d& aY_DC,
143 UtVec3d& aZ_DC);
144
145 void SetDefaultX_Aligned(bool aIsDefaultX_Aligned) { mDefaultX_Aligned = aIsDefaultX_Aligned; }
146 bool GetDefaultX_Aligned() const { return mDefaultX_Aligned; }
147
148protected:
149 UtVec3d Nadir() const;
150 UtVec3d Solar() const;
151 UtVec3d VelocityECI() const;
152 UtVec3d VelocityECEF() const;
153 UtVec3d OrbitPlaneConstraint(const UtVec3d& aAlignVector) const;
154
155 void HandleException(const UtException& aException) const;
156
157 mutable bool mIssueErrorMessage{true};
160};
161
163{
164public:
165 static constexpr const char* GetTypeName() { return "none"; }
167 Orientation* Clone() const override { return new OrientationNone(*this); }
168
169protected:
170 bool Calculate(double& aPsi, double& aTheta, double& aPhi) const override { return false; }
171};
172
174{
175public:
176 static constexpr const char* GetTypeName() { return "nadir_with_eci_velocity_constraint"; }
178 Orientation* Clone() const override { return new OrientationNadirECI_Velocity(*this); }
179
180protected:
181 bool Calculate(double& aPsi, double& aTheta, double& aPhi) const override
182 {
183 CalculateAligned(Nadir(), VelocityECI(), aPsi, aTheta, aPhi);
184 return true;
185 }
186};
187
189{
190public:
191 static constexpr const char* GetTypeName() { return "solar_with_nadir_constraint"; }
193 Orientation* Clone() const override { return new OrientationSolarNadir(*this); }
194
195protected:
196 bool Calculate(double& aPsi, double& aTheta, double& aPhi) const override
197 {
198 CalculateAligned(Solar(), Nadir(), aPsi, aTheta, aPhi);
199 return true;
200 }
201};
202
204{
205public:
206 static constexpr const char* GetTypeName() { return "nadir_with_solar_constraint"; }
208 Orientation* Clone() const override { return new OrientationNadirSolar(*this); }
209
210protected:
211 bool Calculate(double& aPsi, double& aTheta, double& aPhi) const override
212 {
213 CalculateAligned(Nadir(), Solar(), aPsi, aTheta, aPhi);
214 return true;
215 }
216};
217
219{
220public:
221 static constexpr const char* GetTypeName() { return "nadir_with_ecef_velocity_constraint"; }
223 Orientation* Clone() const override { return new OrientationNadirECEF_Velocity(*this); }
224
225protected:
226 bool Calculate(double& aPsi, double& aTheta, double& aPhi) const override
227 {
228 CalculateAligned(Nadir(), VelocityECEF(), aPsi, aTheta, aPhi);
229 return true;
230 }
231};
232
234{
235public:
236 static constexpr const char* GetTypeName() { return "eci_velocity_with_nadir_constraint"; }
238 Orientation* Clone() const override { return new OrientationECI_VelocityNadir(*this); }
239
240protected:
241 bool Calculate(double& aPsi, double& aTheta, double& aPhi) const override
242 {
243 CalculateAligned(VelocityECI(), Nadir(), aPsi, aTheta, aPhi);
244 return true;
245 }
246};
247
249{
250public:
251 static constexpr const char* GetTypeName() { return "eci_velocity_with_solar_constraint"; }
253 Orientation* Clone() const override { return new OrientationECI_VelocitySolar(*this); }
254
255protected:
256 bool Calculate(double& aPsi, double& aTheta, double& aPhi) const override
257 {
258 CalculateAligned(VelocityECI(), Solar(), aPsi, aTheta, aPhi);
259 return true;
260 }
261};
262
263class WSF_SPACE_EXPORT OrientationEntity : public Orientation
264{
265public:
267 bool ProcessInput(UtInput& aInput) override;
268
269 void SetEntityName(const std::string& aEntityName);
270 const std::string& GetEntityName() const { return mEntityName; }
271
272 void SetTrackId(const WsfTrackId& aTrackId);
273 const WsfTrackId& GetLocalTrackId() const { return mTrackId; }
274
275 bool IsValid() const override;
276 class EntityNotFoundException : public UtException
277 {
278 public:
279 explicit EntityNotFoundException(const std::string& aEntityName)
280 : UtException("Could not find platform (Entity) " + aEntityName)
281 {
282 }
283 };
284 class TrackNotFoundException : public UtException
285 {
286 public:
287 explicit TrackNotFoundException(const std::string& aTrackId)
288 : UtException("Could not find track with track id " + aTrackId)
289 {
290 }
291 };
292 class TrackLocationInvalidException : public UtException
293 {
294 public:
295 explicit TrackLocationInvalidException(const std::string& aTrackId)
296 : UtException("Track location invalid for track id " + aTrackId)
297 {
298 }
299 };
300
301protected:
302 UtVec3d TargetVector() const;
303
304 std::string mEntityName;
306 bool mOrientToTrack = false;
307
308private:
309 WsfPlatform* GetTargetEntity() const;
310};
311
313{
314public:
315 static constexpr const char* GetTypeName() { return "entity_with_solar_constraint"; }
317 Orientation* Clone() const override { return new OrientationEntitySolar(*this); }
318
319protected:
320 bool Calculate(double& aPsi, double& aTheta, double& aPhi) const override;
321};
322
324{
325public:
326 static constexpr const char* GetTypeName() { return "entity_with_nadir_constraint"; }
328 Orientation* Clone() const override { return new OrientationEntityNadir(*this); }
329
330protected:
331 bool Calculate(double& aPsi, double& aTheta, double& aPhi) const override;
332};
333
335{
336public:
337 static constexpr const char* GetTypeName() { return "entity_with_orbit_plane_constraint"; }
339 Orientation* Clone() const override { return new OrientationEntityOrbitPlane(*this); }
340
341protected:
342 bool Calculate(double& aPsi, double& aTheta, double& aPhi) const override;
343};
344
345class WSF_SPACE_EXPORT OrientationGeoPoint : public Orientation
346{
347public:
350
351 bool ProcessInput(UtInput& aInput) override;
352 bool IsValid() const override;
353 void SetGeoPoint(const WsfGeoPoint& aGeoPoint);
354 void SetGeoPointName(const std::string& aName) { mGeoPointName = aName; }
355 const std::string& GetGeoPointName() const { return mGeoPointName; }
356 class GeoPointNotFoundException : public UtException
357 {
358 public:
359 explicit GeoPointNotFoundException(const std::string& aGeoPointName)
360 : UtException("Geo Point reference " + aGeoPointName + " not found ")
361 {
362 }
363 };
364
365protected:
366 UtVec3d TargetVector() const;
367 std::string mGeoPointName;
368 mutable std::unique_ptr<WsfGeoPoint> mGeoPointPtr = nullptr;
369};
370
371class WSF_SPACE_EXPORT OrientationPointOrbitPlane : public OrientationGeoPoint
372{
373public:
374 static constexpr const char* GetTypeName() { return "point_with_orbit_plane_constraint"; }
377 Orientation* Clone() const override { return new OrientationPointOrbitPlane(*this); }
378
379private:
380 bool Calculate(double& aPsi, double& aTheta, double& aPhi) const override;
381};
382
383}; // namespace space
384
385}; // namespace wsf
386
387#endif // WSFSPACEORIENTATION_HPP
Definition WsfAttitudeController.hpp:31
Definition WsfGeoPoint.hpp:29
WsfObject()
This is the constructor for the WsfObject class.
Definition WsfObject.cpp:88
Platforms represent a entity within the simulation.
Definition WsfPlatform.hpp:115
Definition WsfTrackId.hpp:33
static constexpr const char * GetTypeName()
Definition WsfSpaceOrientation.hpp:236
bool Calculate(double &aPsi, double &aTheta, double &aPhi) const override
Definition WsfSpaceOrientation.hpp:241
OrientationECI_VelocityNadir()
Definition WsfSpaceOrientation.cpp:567
Orientation * Clone() const override
Definition WsfSpaceOrientation.hpp:238
OrientationECI_VelocitySolar()
Definition WsfSpaceOrientation.cpp:494
static constexpr const char * GetTypeName()
Definition WsfSpaceOrientation.hpp:251
Orientation * Clone() const override
Definition WsfSpaceOrientation.hpp:253
bool Calculate(double &aPsi, double &aTheta, double &aPhi) const override
Definition WsfSpaceOrientation.hpp:256
Orientation * Clone() const override
Definition WsfSpaceOrientation.hpp:328
OrientationEntityNadir()
Definition WsfSpaceOrientation.cpp:576
bool Calculate(double &aPsi, double &aTheta, double &aPhi) const override
Definition WsfSpaceOrientation.cpp:582
static constexpr const char * GetTypeName()
Definition WsfSpaceOrientation.hpp:326
Orientation * Clone() const override
Definition WsfSpaceOrientation.hpp:339
static constexpr const char * GetTypeName()
Definition WsfSpaceOrientation.hpp:337
bool Calculate(double &aPsi, double &aTheta, double &aPhi) const override
Definition WsfSpaceOrientation.cpp:615
OrientationEntityOrbitPlane()
Definition WsfSpaceOrientation.cpp:609
OrientationEntitySolar()
Definition WsfSpaceOrientation.cpp:600
bool Calculate(double &aPsi, double &aTheta, double &aPhi) const override
Definition WsfSpaceOrientation.cpp:462
Orientation * Clone() const override
Definition WsfSpaceOrientation.hpp:317
static constexpr const char * GetTypeName()
Definition WsfSpaceOrientation.hpp:315
EntityNotFoundException(const std::string &aEntityName)
Definition WsfSpaceOrientation.hpp:279
TrackLocationInvalidException(const std::string &aTrackId)
Definition WsfSpaceOrientation.hpp:295
TrackNotFoundException(const std::string &aTrackId)
Definition WsfSpaceOrientation.hpp:287
WsfTrackId mTrackId
Definition WsfSpaceOrientation.hpp:305
std::string mEntityName
Definition WsfSpaceOrientation.hpp:304
void SetEntityName(const std::string &aEntityName)
Definition WsfSpaceOrientation.cpp:335
OrientationEntity()
Definition WsfSpaceOrientation.cpp:324
bool ProcessInput(UtInput &aInput) override
Definition WsfSpaceOrientation.cpp:329
bool mOrientToTrack
Definition WsfSpaceOrientation.hpp:306
const WsfTrackId & GetLocalTrackId() const
Definition WsfSpaceOrientation.hpp:273
const std::string & GetEntityName() const
Definition WsfSpaceOrientation.hpp:270
GeoPointNotFoundException(const std::string &aGeoPointName)
Definition WsfSpaceOrientation.hpp:359
bool ProcessInput(UtInput &aInput) override
Read the name of the GeoPoint to access on the platform.
Definition WsfSpaceOrientation.cpp:407
bool IsValid() const override
Definition WsfSpaceOrientation.cpp:413
std::unique_ptr< WsfGeoPoint > mGeoPointPtr
Definition WsfSpaceOrientation.hpp:368
std::string mGeoPointName
Definition WsfSpaceOrientation.hpp:367
void SetGeoPointName(const std::string &aName)
Definition WsfSpaceOrientation.hpp:354
OrientationGeoPoint()
Definition WsfSpaceOrientation.cpp:503
void SetGeoPoint(const WsfGeoPoint &aGeoPoint)
Definition WsfSpaceOrientation.cpp:425
const std::string & GetGeoPointName() const
Definition WsfSpaceOrientation.hpp:355
Orientation * Clone() const override
Definition WsfSpaceOrientation.hpp:223
static constexpr const char * GetTypeName()
Definition WsfSpaceOrientation.hpp:221
OrientationNadirECEF_Velocity()
Definition WsfSpaceOrientation.cpp:549
bool Calculate(double &aPsi, double &aTheta, double &aPhi) const override
Definition WsfSpaceOrientation.hpp:226
OrientationNadirECI_Velocity()
Definition WsfSpaceOrientation.cpp:558
Orientation * Clone() const override
Definition WsfSpaceOrientation.hpp:178
static constexpr const char * GetTypeName()
Definition WsfSpaceOrientation.hpp:176
bool Calculate(double &aPsi, double &aTheta, double &aPhi) const override
Definition WsfSpaceOrientation.hpp:181
OrientationNadirSolar()
Definition WsfSpaceOrientation.cpp:531
Orientation * Clone() const override
Definition WsfSpaceOrientation.hpp:208
static constexpr const char * GetTypeName()
Definition WsfSpaceOrientation.hpp:206
bool Calculate(double &aPsi, double &aTheta, double &aPhi) const override
Definition WsfSpaceOrientation.hpp:211
bool Calculate(double &aPsi, double &aTheta, double &aPhi) const override
Definition WsfSpaceOrientation.hpp:170
OrientationNone()
Definition WsfSpaceOrientation.cpp:540
Orientation * Clone() const override
Definition WsfSpaceOrientation.hpp:167
static constexpr const char * GetTypeName()
Definition WsfSpaceOrientation.hpp:165
Definition WsfSpaceOrientation.hpp:372
OrientationPointOrbitPlane()
Definition WsfSpaceOrientation.cpp:634
OrientationPointOrbitPlane(const OrientationPointOrbitPlane &aSrc)=default
static constexpr const char * GetTypeName()
Definition WsfSpaceOrientation.hpp:374
Orientation * Clone() const override
Definition WsfSpaceOrientation.hpp:377
Orientation * Clone() const override
Definition WsfSpaceOrientation.hpp:193
bool Calculate(double &aPsi, double &aTheta, double &aPhi) const override
Definition WsfSpaceOrientation.hpp:196
OrientationSolarNadir()
Definition WsfSpaceOrientation.cpp:522
static constexpr const char * GetTypeName()
Definition WsfSpaceOrientation.hpp:191
Definition WsfSpaceOrientation.hpp:80
bool GetDefaultX_Aligned() const
Definition WsfSpaceOrientation.hpp:146
UtVec3d Solar() const
Definition WsfSpaceOrientation.cpp:193
Orientation * Clone() const override=0
static void CalculateX_Aligned(const UtVec3d &aX_AxisOrientationECI, const UtVec3d &aZ_AxisConstraintECI, double &aPsi, double &aTheta, double &aPhi)
Definition WsfSpaceOrientation.cpp:90
static void CalculateZ_Aligned(const UtVec3d &aZ_AxisOrientationECI, const UtVec3d &aX_AxisConstraintECI, double &aPsi, double &aTheta, double &aPhi)
Definition WsfSpaceOrientation.cpp:109
Orientation(const Orientation &aSrc)=default
~Orientation() override=default
bool mIssueErrorMessage
Definition WsfSpaceOrientation.hpp:157
virtual bool Calculate(double &aPsi, double &aTheta, double &aPhi) const =0
static void CalculatePCS_DirectionCosines(const UtVec3d &aX_AxisOrientationECI, const UtVec3d &aZ_AxisConstraintECI, UtVec3d &aX_DC, UtVec3d &aY_DC, UtVec3d &aZ_DC)
Definition WsfSpaceOrientation.cpp:62
void CalculateAligned(const UtVec3d &aPointingAxisOrientationECI, const UtVec3d &aConstraintAxisOrientationECI, double &aPsi, double &aTheta, double &aPhi) const
Definition WsfSpaceOrientation.cpp:176
static void CalculateGeneral(double aYawECS, double aPitchECS, double aRollECS, const UtVec3d &aX_AxisOrientationECI, const UtVec3d &aZ_AxisConstraintECI, double &aPsi, double &aTheta, double &aPhi)
Definition WsfSpaceOrientation.cpp:139
const WsfAttitudeController * mControllerPtr
Definition WsfSpaceOrientation.hpp:159
bool mDefaultX_Aligned
Definition WsfSpaceOrientation.hpp:158
static std::unique_ptr< Orientation > Factory(const std::string &aOrientation)
Definition WsfSpaceOrientation.cpp:239
Orientation(bool aIsDefaultX_Aligned)
Definition WsfSpaceOrientation.hpp:82
virtual bool IsValid() const
Definition WsfSpaceOrientation.hpp:104
void SetAttitudeController(const WsfAttitudeController &aController)
Set the automatic orientation to be used with the propagator.
Definition WsfSpaceOrientation.hpp:97
bool ProcessInput(UtInput &aInput) override
Definition WsfSpaceOrientation.hpp:99
UtVec3d VelocityECEF() const
Definition WsfSpaceOrientation.cpp:209
void SetDefaultX_Aligned(bool aIsDefaultX_Aligned)
Definition WsfSpaceOrientation.hpp:145
UtVec3d VelocityECI() const
Definition WsfSpaceOrientation.cpp:201
const char * GetScriptClassName() const override
Definition WsfSpaceOrientation.cpp:46
UtVec3d Nadir() const
Definition WsfSpaceOrientation.cpp:227
Definition WsfAtmosphere.cpp:23
Function definitions for those who need run-time access to the version.
Definition WsfComm.cpp:32
Copyrights Multiple, All Rights Reserved