VR-Engage  2.3
Loading...
Searching...
No Matches
droneControlLogic.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2024 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6#pragma once
7
13
14#include <vrfutil/rwLocationReference.h>
15
16#include <vlpi/appearance.h>
17#include <matrix/vlVector.h>
18
19#include <map>
20#include <string>
21
22class DtRwLocationReference;
23
24namespace makVrv
25{
26class DtIntersector;
27}
28
29namespace makVre
30{
31
33{
34//! \ingroup RoleConfigParams
35//! \defgroup DroneControlLogicRoleParams Drone Control Logic Role Parameters
36//! \roleInherits{EntityControlLogicRoleParams}
37//! Configuration options for drone control logic.
38//! @{
39
40//! \vreRoleParam{droneBatteryWarnings,table,{},droneControlLogic,Configuration table for drone battery warning thresholds.}
41constexpr const char* droneBatteryWarnings = "droneBatteryWarnings";
42
43//! \vreRoleParam{droneOverlaySections,vector<string>,{},droneControlLogic,Overlay section names to display when using a drone sensor view.}
44constexpr const char* droneOverlaySections = "droneOverlaySections";
45
46//! \vreRoleParam{droneSensorModes,vector<string>|table,{},droneControlLogic,Available sensor modes for drone cameras.}
47constexpr const char* droneSensorModes = "droneSensorModes";
48
49//! \vreRoleParam{droneStatusUpdateDisplayTime,double,2.0,droneControlLogic,Duration in seconds to display drone status update notifications.}
50constexpr const char* droneStatusUpdateDisplayTime = "droneStatusUpdateDisplayTime";
51
52//! \vreRoleParamRequired{maxDGain,double,droneControlLogic,1.0,Maximum derivative gain value for drone PID control.}
53constexpr const char* maxDGain = "maxDGain";
54
55//! \vreRoleParamRequired{maxFGain,double,droneControlLogic,1.0,Maximum feedforward gain value for drone control.}
56constexpr const char* maxFGain = "maxFGain";
57
58//! \vreRoleParamRequired{maxIGain,double,droneControlLogic,1.0,Maximum integral gain value for drone PID control.}
59constexpr const char* maxIGain = "maxIGain";
60
61//! \vreRoleParamRequired{maxPGain,double,droneControlLogic,1.0,Maximum proportional gain value for drone PID control.}
62constexpr const char* maxPGain = "maxPGain";
63
64//! \vreRoleParam{thirdPersonOnUseDrone,bool,true,droneControlLogic,Whether to switch to third-person view when using a drone.}
65constexpr const char* thirdPersonOnUseDrone = "thirdPersonOnUseDrone";
66
67//! \vreRoleParam{lookAtDroneOnUse,bool,true,droneControlLogic,Whether the ownship should look at the drone when it is used.}
68constexpr const char* lookAtDroneOnUse = "lookAtDroneOnUse";
69
70//! \vreRoleParam{loiterDefaults,table,{},droneControlLogic,Optional defaults for loiter mode, orbit direction, and relative loiter parameters.}
71constexpr const char* loiterDefaults = "loiterDefaults";
72
73//! \vreRoleParam{loiterDefaults.mode,string|int,Orbit,droneControlLogic,Initial drone loiter mode name or numeric mode index.}
74constexpr const char* loiterDefaultsMode = "mode";
75
76//! \vreRoleParam{loiterDefaults.relativeAltitudeFeet,double,none,droneControlLogic,Initial relative loiter altitude in feet.}
77constexpr const char* loiterDefaultsRelativeAltitudeFeet = "relativeAltitudeFeet";
78
79//! \vreRoleParam{loiterDefaults.relativeHorizontalDistanceMeters,double,none,droneControlLogic,Initial relative loiter horizontal distance in meters.}
80constexpr const char* loiterDefaultsRelativeHorizontalDistanceMeters = "relativeHorizontalDistanceMeters";
81
82//! \vreRoleParam{loiterDefaults.relativeBearingDeg,double,none,droneControlLogic,Initial relative loiter bearing in degrees.}
83constexpr const char* loiterDefaultsRelativeBearingDeg = "relativeBearingDeg";
84
85//! \vreRoleParam{loiterDefaults.orbitDirection,string,clockwise,droneControlLogic,Initial orbit direction for loiter mode.}
86constexpr const char* loiterDefaultsOrbitDirection = "orbitDirection";
87
88//! @}
89} // namespace DroneControlLogicConfig
90
92
93//! \brief Type identifier for DtDroneControlLogic component
94constexpr const char* DtDroneControlLogicType = "DtDroneControlLogic";
95
96//! \brief Component that manages drone deployment and remote view control
98{
99public:
101 virtual ~DtDroneControlLogic() override;
102
103 virtual bool initialize(DtPlayerStation* player, DtInitTable& config) override;
104 virtual bool postInitialize() override;
105 virtual void tick(double dt) override;
106 virtual void shutdown() override;
107
108 virtual const char* type() const override;
109
110 virtual void useDrone(const DtEntityIdentifier& id = DtEntityIdentifier::nullId(), const std::string& marking = "");
111
112 //! \brief Releases the drone currently in use, closing its remote view and releasing control.
113 //!
114 //! \param force When true, bypasses the normal control and airborne checks so cleanup still
115 //! happens on shutdown, on death, or while parachuting.
116 virtual void stopUsingDrone(bool force = false);
117
120
121 virtual void setDroneAutopilotMode(const std::string& mode);
123 virtual void toggleDronePIDMenu();
124 virtual void cycleDroneLoiterMode();
126 virtual void toggleDroneLoiter();
127 virtual void setDroneLoiterRelativeAltitudeFromDisplay(const std::string& value);
128 virtual void setDroneLoiterRelativeHorizontalDistanceFromDisplay(const std::string& value);
129 virtual void setDroneLoiterRelativeBearingFromDisplay(const std::string& value);
130 virtual void startDroneLoiter(const DtRwLocationReference& targetLocationReference);
133
134 virtual bool operatingDrone();
135
136 virtual void landDrone();
137 virtual void returnToHome();
138
139 virtual void setFocusOnEntity(bool val);
140 virtual void toggleFocusOnEntity();
141
142 virtual void setForwardControls(bool val);
143 virtual void toggleForwardControls();
144
145protected:
153 //virtual makVre::DtVreMessageResult handleMenuActionMessage(makVre::DtVreMessage* msg);
154
155 virtual void checkForDroneBatteryWarning(float amount);
156 virtual void setDroneDestroyed();
157
158 void onForwardControlsChanged(bool forwardControls);
159 void onUsingDroneChanged(bool usingDrone);
160 void onDamageStateChanged(DtDamageState val);
164 void requestDroneWeaponConfig(const DtEntityIdentifier& droneId);
165 void selectDroneWeapon(const DtEntityIdentifier& droneId, const std::string& weaponName);
166 bool isSupportedDroneWeaponTargetingMethod(const std::string& targetingMethod) const;
167
169
174
175 float myPGain;
176 float myIGain;
177 float myDGain;
178 float myFGain;
179
181
182 std::map<int, bool> myDroneBatteryWarnings;
184
187
191 std::map<enum SensorViews, std::string> mySensorModes;
192
193 DtRwLocationReference myDroneLoiterTargetRef; // target preserved across parameter re-issues
194
202
230};
231
232} // namespace makVre
Type-specific handle class for attributes.
Definition attributeHandle.h:229
virtual void toggleDronePIDMenu()
DtAttributeHandleType< std::string > myDroneLoiterRelativeBearingDisplayAttr
Definition droneControlLogic.h:220
virtual void setDroneAutopilotMode(const std::string &mode)
DtAttributeHandleType< DtEntityResolver * > myDroneEntityResolverAttr
Definition droneControlLogic.h:228
virtual void toggleFocusOnEntity()
double myDroneLoiterRelativeAltitudeFeet
Definition droneControlLogic.h:196
bool myDroneLoiterUseCurrentRelativeAltitudeFeet
Definition droneControlLogic.h:195
DtAttributeHandleType< ObserverAttachMode > myObserverAttachModeAttr
Definition droneControlLogic.h:223
virtual void fireSelectedDroneWeapon()
DtAttributeHandleType< makVrv::DtIntersector * > myIntersectorAttr
Definition droneControlLogic.h:229
virtual void startDroneLoiter(const DtRwLocationReference &targetLocationReference)
DtAttributeHandleType< DtEntityIdentifier > myForwardControlsToAttr
Definition droneControlLogic.h:214
DtAttributeHandleType< double > myDroneFullAmountAttr
Definition droneControlLogic.h:227
virtual void toggleDroneLoiter()
DtAttributeHandleType< bool > myDroneManualControlAttr
Definition droneControlLogic.h:215
virtual void cycleDroneLoiterOrbitDirection()
virtual void toggleDroneAutopilotMode()
virtual void checkForDroneBatteryWarning(float amount)
bool isSupportedDroneWeaponTargetingMethod(const std::string &targetingMethod) const
ObserverAttachMode myCachedAttachMode
Definition droneControlLogic.h:186
bool myDroneLoiterUseCurrentRelativeBearingDeg
Definition droneControlLogic.h:199
double myDroneStatusUpdateDisplayTime
Definition droneControlLogic.h:183
float myMaxDGain
Definition droneControlLogic.h:172
void onForwardControlsChanged(bool forwardControls)
bool myLookAtDroneOnUse
Definition droneControlLogic.h:188
virtual makVre::DtVreMessageResult handleResourceUpdate(makVre::DtVreMessage *msg)
SensorViews myLastSensorViewMode
Definition droneControlLogic.h:190
virtual makVre::DtVreMessageResult handleWeaponConfigResponse(makVre::DtVreMessage *msg)
std::map< int, bool > myDroneBatteryWarnings
Definition droneControlLogic.h:182
virtual void setFocusOnEntity(bool val)
virtual makVre::DtVreMessageResult handleEnterPlayerState(makVre::DtVreMessage *msg)
bool myDroneLoiterOrbitClockwise
Definition droneControlLogic.h:201
DtAttributeHandleType< bool > myUsingDroneAttr
Definition droneControlLogic.h:210
virtual void cycleDroneLoiterMode()
std::string mySelectedDroneWeaponName
Definition droneControlLogic.h:189
virtual const char * type() const override
Returns the component type identifier.
virtual bool initialize(DtPlayerStation *player, DtInitTable &config) override
Initializes the entity control logic.
DtAttributeHandleType< std::vector< std::string > > myDroneSensorModesAttr
Definition droneControlLogic.h:205
virtual void toggleRemoteViewViewport()
double myDroneLoiterRelativeHorizontalDistanceMeters
Definition droneControlLogic.h:198
DtAttributeHandleType< DtDamageState > myOwnshipDamageStateAttr
Definition droneControlLogic.h:222
DtAttributeHandleType< bool > myDroneStopUsingAvailableAttr
Definition droneControlLogic.h:209
virtual makVre::DtVreMessageResult handleExitPlayerState(makVre::DtVreMessage *msg)
bool myThirdPersonOnUseDrone
Definition droneControlLogic.h:185
virtual void setDroneLoiterRelativeAltitudeFromDisplay(const std::string &value)
DtAttributeHandleType< std::string > myDroneLoiterOrbitDirectionNameAttr
Definition droneControlLogic.h:221
bool myDroneLoiterUseCurrentRelativeHorizontalDistanceMeters
Definition droneControlLogic.h:197
DtAttributeHandleType< bool > myDroneSignalLostAttr
Definition droneControlLogic.h:207
float myPGain
Definition droneControlLogic.h:175
virtual void setDroneLoiterRelativeHorizontalDistanceFromDisplay(const std::string &value)
DtAttributeHandleType< std::string > myDroneLoiterModeNameAttr
Definition droneControlLogic.h:216
void onUsingDroneChanged(bool usingDrone)
DtAttributeHandleType< bool > myDroneLoiteringAttr
Definition droneControlLogic.h:226
DtAttributeHandleType< bool > myDroneSignalLostDismissedAttr
Definition droneControlLogic.h:208
DtAttributeHandleType< DeployableObjectStateMap > myDeployableObjectsAttr
Definition droneControlLogic.h:224
virtual void setForwardControls(bool val)
virtual void dismissDroneSignalLost()
virtual makVre::DtVreMessageResult handleEntityRemoved(makVre::DtVreMessage *msg)
virtual void stopUsingDroneOrDismissSignalLost()
virtual void useDrone(const DtEntityIdentifier &id=DtEntityIdentifier::nullId(), const std::string &marking="")
DtAttributeHandleType< int > myDroneCurrentSensorAttr
Definition droneControlLogic.h:204
virtual void shutdown() override
Shuts down the entity control logic.
std::map< enum SensorViews, std::string > mySensorModes
Definition droneControlLogic.h:191
void onDamageStateChanged(DtDamageState val)
double myDroneLoiterRelativeBearingDeg
Definition droneControlLogic.h:200
virtual void setDroneLoiterRelativeBearingFromDisplay(const std::string &value)
DtAttributeHandleType< bool > myFocusOnEntityAttr
Definition droneControlLogic.h:212
virtual makVre::DtVreMessageResult handleSimState(makVre::DtVreMessage *msg) override
Message handlers.
bool myShowPidMenu
Definition droneControlLogic.h:180
int myDroneLoiterModeIndex
Definition droneControlLogic.h:203
float myMaxPGain
Definition droneControlLogic.h:170
virtual makVre::DtVreMessageResult handleEntityRealized(makVre::DtVreMessage *msg)
float myFGain
Definition droneControlLogic.h:178
DtAttributeHandleType< std::string > myDroneLoiterRelativeHorizontalDistanceDisplayAttr
Definition droneControlLogic.h:219
float myMaxIGain
Definition droneControlLogic.h:171
virtual void stopUsingDrone(bool force=false)
Releases the drone currently in use, closing its remote view and releasing control.
virtual bool postInitialize() override
Performs post-initialization setup.
float myDGain
Definition droneControlLogic.h:177
DtAttributeHandleType< DtEntityIdentifier > myDroneEntityIdAttr
Definition droneControlLogic.h:211
DtAttributeHandleType< bool > myDroneLoiterModeIsOrbitAttr
Definition droneControlLogic.h:217
virtual bool operatingDrone()
void requestDroneWeaponConfig(const DtEntityIdentifier &droneId)
DtAttributeHandleType< std::string > myRemoteViewChannelNameAttr
Definition droneControlLogic.h:225
DtAttributeHandleType< std::string > myDroneCurrentSensorNameAttr
Definition droneControlLogic.h:206
virtual void toggleForwardControls()
virtual ~DtDroneControlLogic() override
float myIGain
Definition droneControlLogic.h:176
virtual void tick(double dt) override
Updates the entity control logic each frame.
virtual void setDroneDestroyed()
float myMaxFGain
Definition droneControlLogic.h:173
DtDroneInputLogic * myInputLogic
Definition droneControlLogic.h:168
DtRwLocationReference myDroneLoiterTargetRef
Definition droneControlLogic.h:193
DtAttributeHandleType< std::string > myDroneLoiterRelativeAltitudeDisplayAttr
Definition droneControlLogic.h:218
DtAttributeHandleType< bool > myForwardControlsAttr
Definition droneControlLogic.h:213
void selectDroneWeapon(const DtEntityIdentifier &droneId, const std::string &weaponName)
Input logic for drone control actions.
Definition droneInputLogic.h:28
DtEntityControlLogic()
Constructor.
Table-based access to Lua state for configuration data.
Definition initializer.h:38
virtual DtPlayerStation & player()
Gets the player station.
Class for managing the user interface for engaged roles.
Definition playerStation.h:51
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
Defines the logic for controlling entities in VR-Engage.
constexpr const char * thirdPersonOnUseDrone
Definition droneControlLogic.h:65
constexpr const char * droneSensorModes
Definition droneControlLogic.h:47
constexpr const char * loiterDefaultsRelativeHorizontalDistanceMeters
Definition droneControlLogic.h:80
constexpr const char * maxDGain
Definition droneControlLogic.h:53
constexpr const char * maxFGain
Definition droneControlLogic.h:56
constexpr const char * loiterDefaultsRelativeAltitudeFeet
Definition droneControlLogic.h:77
constexpr const char * loiterDefaults
\vreRoleParam{loiterDefaults,table,{},droneControlLogic,Optional defaults for loiter mode,...
Definition droneControlLogic.h:71
constexpr const char * maxPGain
Definition droneControlLogic.h:62
constexpr const char * droneStatusUpdateDisplayTime
Definition droneControlLogic.h:50
constexpr const char * maxIGain
Definition droneControlLogic.h:59
constexpr const char * loiterDefaultsMode
Definition droneControlLogic.h:74
constexpr const char * lookAtDroneOnUse
Definition droneControlLogic.h:68
constexpr const char * loiterDefaultsOrbitDirection
Definition droneControlLogic.h:86
constexpr const char * droneOverlaySections
Definition droneControlLogic.h:44
constexpr const char * loiterDefaultsRelativeBearingDeg
Definition droneControlLogic.h:83
constexpr const char * droneBatteryWarnings
Definition droneControlLogic.h:41
Defines export/import macros for the vreCommonComponents library.
#define VRECOMMONCOMPONENTS_DLL
DLL export/import macro for the vreCommonComponents library.
Definition export.h:28
Definition droneControlLogic.h:33
!
Definition glsVreMessageUtil.h:50
ObserverAttachMode
Enumeration of camera/observer attachment offsets.
Definition stateDefines.h:44
constexpr const char * DtDroneControlLogicType
Type identifier for DtDroneControlLogic component.
Definition droneControlLogic.h:94
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
SensorViews
Enumeration of available sensor view modes.
Definition stateDefines.h:18
Definition appLauncherComponent.h:28
Common enumeration definitions used throughout the VREngage system.
Defines the base class for all VREngage messages.