WSF
WsfExtEntityDeadReckon.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
13#ifndef WSFEXTENTITYDEADRECKON_HPP
14#define WSFEXTENTITYDEADRECKON_HPP
15
16#include "wsf_export.h"
17
18#include <map>
19
20#include "UtCallback.hpp"
21#include "UtCallbackHolder.hpp"
22#include "WsfEvent.hpp"
23
24class UtInput;
25class WsfMover;
26class WsfPlatform;
27class WsfExtInterface;
28
29
41
46{
47public:
48 WsfExtEntityDeadReckon(WsfExtInterface* aExtInterfacePtr);
49
50 void Initialize();
51
52 bool ProcessInput(UtInput& aInput);
53
54 void RequestService(bool aHeartbeatRequired);
55
56 void ForceUpdate(double aSimTime, WsfPlatform* aPlatformPtr, bool aForceSend = false);
57
58 void RequireExternalEntities(bool aExternalEntitiesRequired);
59
61 void UseInitialDistributionInterval() { mUseInitialDistrubutionInterval = true; }
62
64 double GetHeartbeatTimer() const { return mHeartbeatTimer; }
65
67 void SetHeartbeatTimerOverride(double aTime) { mHeartbeatTimerOverride = aTime; }
68
71
74
76
79
80 double GetMoverUpdateTimer() const { return mMoverUpdateTimer; }
81 void SetMoverUpdateTimer(double aMoverUpdateTimer) { mMoverUpdateTimer = aMoverUpdateTimer; }
82
84 struct DR_State
85 {
86 DR_State();
87 void LoadFromPlatform(double aSimTime, WsfPlatform& aPlatform);
88 void Extrapolate(double aDeltaTime, WsfPlatform& aPlatform, DR_State& aExtrapState);
89
90 double mLocationWCS[3];
91 double mVelocityWCS[3];
93 double mOrientationWCS[3];
95 double mAngularRateWCS[3];
97 };
98
100 {
104 };
105
108 {
109 public:
110 PlatformDR(double aSimTime, WsfPlatform* aPlatformPtr);
111 PlatformDR();
112
120 // State before MoverUpdated was last called with 'true'
122 // State before MoverUpdated was last called
124 };
125
128 UtCallbackListN<void(double, PlatformDR&)> DeadReckonChanged;
129
132 UtCallbackListN<void(double, PlatformDR&)> MoverUpdated;
133
134private:
135 void UpdateDeadReckon(double aSimTime, WsfPlatform* aPlatformPtr, bool aForceUpdate);
136
137 bool IsStateAccurate(double aSimTime, PlatformDR& aState, bool aForceUpdate);
138
139 void HandlePlatformDeleted(double aSimTime, WsfPlatform* aPlatformPtr);
140 void HandlePlatformAdded(double aSimTime, WsfPlatform* aPlatformPtr);
141 void HandleMoverUpdated(double aSimTime, WsfMover* aMoverPtr);
142
143 double HandleHeartbeat(double aSimTime, size_t aPlatformIndex);
144
145 double CalculateHeartbeatTimer(double aAverageHeartbeatTimer, double aMultiplier) const;
146
149 class HeartbeatEvent : public WsfEvent
150 {
151 public:
152 HeartbeatEvent() = delete;
153 HeartbeatEvent(double aSimTime, WsfExtEntityDeadReckon* aExtPtr, size_t aPlatformIndex)
154 : WsfEvent(aSimTime)
155 , mExtPtr(aExtPtr)
156 , mPlatformIndex(aPlatformIndex)
157 {
158 }
159 EventDisposition Execute() override;
160
161 WsfExtEntityDeadReckon* mExtPtr;
162 size_t mPlatformIndex;
163 };
164
165 UtCallbackHolder mCallbacks;
166
167 std::map<size_t, PlatformDR> mDeadReckonData;
168 bool mExternalEntitiesRequired;
171 bool mHeartbeatRequired;
172
173 bool mInitialized;
174 bool mUseSimpleExtrapolations;
175 bool mUseInitialDistrubutionInterval;
176 double mHeartbeatTimerOverride;
177 double mInitialDistributionStart;
178
179 WsfExtInterface* mExtInterfacePtr;
180};
181
182#endif
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
Definition WsfEvent.hpp:29
Maintains a platform's dead reckon state.
Definition WsfExtEntityDeadReckon.hpp:108
double mHeartbeatTimer
Definition WsfExtEntityDeadReckon.hpp:118
double mLastSendTime
Definition WsfExtEntityDeadReckon.hpp:116
DR_State mSentState
Definition WsfExtEntityDeadReckon.hpp:121
bool mIsUpdated
Definition WsfExtEntityDeadReckon.hpp:114
bool mInitialized
Definition WsfExtEntityDeadReckon.hpp:113
PlatformDR(double aSimTime, WsfPlatform *aPlatformPtr)
Definition WsfExtEntityDeadReckon.cpp:329
WsfPlatform * mPlatformPtr
Definition WsfExtEntityDeadReckon.hpp:119
UpdateType mLastUpdateType
Definition WsfExtEntityDeadReckon.hpp:115
DR_State mUpdatedState
Definition WsfExtEntityDeadReckon.hpp:123
double mLastTimeMoverUpdate
Definition WsfExtEntityDeadReckon.hpp:117
Definition WsfExtEntityDeadReckon.hpp:46
UpdateType
Definition WsfExtEntityDeadReckon.hpp:100
@ cHEARTBEAT
Definition WsfExtEntityDeadReckon.hpp:103
@ cDR_CHANGE
Definition WsfExtEntityDeadReckon.hpp:102
@ cNO_CHANGE
Definition WsfExtEntityDeadReckon.hpp:101
double GetInitialDistributionInterval() const
Definition WsfExtEntityDeadReckon.hpp:75
void UseInitialDistributionInterval()
Requests that the initial distribution interval is to be used.
Definition WsfExtEntityDeadReckon.hpp:61
void SetHeartbeatTimerOverride(double aTime)
Set the current heartbeat timer for this individual platform.
Definition WsfExtEntityDeadReckon.hpp:67
double GetHeartbeatTimer() const
Return the heartbeat timer (seconds).
Definition WsfExtEntityDeadReckon.hpp:64
UtCallbackListN< void(double, PlatformDR &)> MoverUpdated
Definition WsfExtEntityDeadReckon.hpp:132
double GetMoverUpdateTimer() const
Definition WsfExtEntityDeadReckon.hpp:80
void SetInitialDistributionInterval(double aValue)
Allow the initial distribution interval to be set.
Definition WsfExtEntityDeadReckon.hpp:78
WsfExtEntityDeadReckon(WsfExtInterface *aExtInterfacePtr)
Definition WsfExtEntityDeadReckon.cpp:24
void RequireExternalEntities(bool aExternalEntitiesRequired)
Definition WsfExtEntityDeadReckon.cpp:299
double GetEntityPositionThreshold() const
Return the position threshold (meters).
Definition WsfExtEntityDeadReckon.hpp:73
void RequestService(bool aHeartbeatRequired)
Definition WsfExtEntityDeadReckon.cpp:71
void SetMoverUpdateTimer(double aMoverUpdateTimer)
Definition WsfExtEntityDeadReckon.hpp:81
bool ProcessInput(UtInput &aInput)
Definition WsfExtEntityDeadReckon.cpp:87
UtCallbackListN< void(double, PlatformDR &)> DeadReckonChanged
Definition WsfExtEntityDeadReckon.hpp:128
double GetEntityOrientationThreshold() const
Return the orientation threshold (radians).
Definition WsfExtEntityDeadReckon.hpp:70
void Initialize()
Definition WsfExtEntityDeadReckon.cpp:37
void ForceUpdate(double aSimTime, WsfPlatform *aPlatformPtr, bool aForceSend=false)
Definition WsfExtEntityDeadReckon.cpp:94
The WSF Ext is code which is shared between common external interfaces like DIS and HLA.
Definition WsfExtInterface.hpp:183
Definition WsfMover.hpp:37
Platforms represent a entity within the simulation.
Definition WsfPlatform.hpp:115
double mEntityOrientationThreshold
Definition WsfExtEntityDeadReckon.hpp:39
double mMoverUpdateTimer
Definition WsfExtEntityDeadReckon.hpp:35
double mHeartbeatTimer
Definition WsfExtEntityDeadReckon.hpp:34
bool mDR_ServiceRequested
Definition WsfExtEntityDeadReckon.hpp:33
double mEntityPositionThreshold
Definition WsfExtEntityDeadReckon.hpp:38
double mInitialDistributionInterval
Definition WsfExtEntityDeadReckon.hpp:36
WsfExtEntityDeadReckonSetup()
Definition WsfExtEntityDeadReckon.cpp:428
Stores the state of an entity.
Definition WsfExtEntityDeadReckon.hpp:85
double mAccelerationWCS[3]
Definition WsfExtEntityDeadReckon.hpp:92
double mOrientationWCS[3]
Definition WsfExtEntityDeadReckon.hpp:93
void LoadFromPlatform(double aSimTime, WsfPlatform &aPlatform)
Definition WsfExtEntityDeadReckon.cpp:380
double mPastOrientationWCS[3]
Definition WsfExtEntityDeadReckon.hpp:94
DR_State()
Definition WsfExtEntityDeadReckon.cpp:366
void Extrapolate(double aDeltaTime, WsfPlatform &aPlatform, DR_State &aExtrapState)
Definition WsfExtEntityDeadReckon.cpp:316
double mVelocityWCS[3]
Definition WsfExtEntityDeadReckon.hpp:91
double mPastAngularRateWCS[3]
Definition WsfExtEntityDeadReckon.hpp:96
double mLocationWCS[3]
Definition WsfExtEntityDeadReckon.hpp:90
double mAngularRateWCS[3]
Definition WsfExtEntityDeadReckon.hpp:95
Copyrights Multiple, All Rights Reserved