diff --git a/addons/missileguidance/ACE_GuidanceConfig.hpp b/addons/missileguidance/ACE_GuidanceConfig.hpp index 4b22e639fb..c2baf1eac4 100644 --- a/addons/missileguidance/ACE_GuidanceConfig.hpp +++ b/addons/missileguidance/ACE_GuidanceConfig.hpp @@ -93,9 +93,11 @@ class GVAR(SeekerTypes) { }; class GVAR(NavigationTypes) { - class ProportionalNavigation { - name = "Proportional Navigation"; - + class LineOfSight { + functionName = QFUNC(navigationType_lineOfSight); + onFired = QFUNC(lineOfSight_onFired); + }; + class ProportionalNavigation { functionName = QFUNC(navigationType_proNav); onFired = QFUNC(proNav_onFired); }; diff --git a/addons/missileguidance/CfgAmmo.hpp b/addons/missileguidance/CfgAmmo.hpp index 5fa6d4b61f..a2f0724bf3 100644 --- a/addons/missileguidance/CfgAmmo.hpp +++ b/addons/missileguidance/CfgAmmo.hpp @@ -72,6 +72,8 @@ class CfgAmmo { pitchRate = 40; // degrees per second yawRate = 40; + bangBangGuidance = 0; + canVanillaLock = 0; // Guidance type for munitions diff --git a/addons/missileguidance/XEH_PREP.hpp b/addons/missileguidance/XEH_PREP.hpp index 484929e541..c87932bbe5 100644 --- a/addons/missileguidance/XEH_PREP.hpp +++ b/addons/missileguidance/XEH_PREP.hpp @@ -31,6 +31,7 @@ PREP(attackProfile_JAV_TOP); // Navigation Profiles PREP(navigationType_proNav); +PREP(navigationType_lineOfSight) // Seeker search functions PREP(seekerType_SALH); @@ -47,3 +48,4 @@ PREP(ahr_onFired); // Navigation OnFired PREP(proNav_onFired); +PREP(lineOfSight_onFired); diff --git a/addons/missileguidance/functions/fnc_guidancePFH.sqf b/addons/missileguidance/functions/fnc_guidancePFH.sqf index cdd6546e68..54df4e6946 100644 --- a/addons/missileguidance/functions/fnc_guidancePFH.sqf +++ b/addons/missileguidance/functions/fnc_guidancePFH.sqf @@ -66,8 +66,16 @@ if ((_pitchRate != 0 || {_yawRate != 0}) && {_profileAdjustedTargetPos isNotEqua // controls are either on or off, no proportional if (_isBangBangGuidance) then { - private _pitchSign = _clampedPitch / abs _clampedPitch; - private _yawSign = _clampedYaw / abs _clampedYaw; + private _pitchSign = if (_clampedPitch == 0) then { + 0 + } else { + _clampedPitch / abs _clampedPitch + }; + private _yawSign = if (_clampedYaw == 0) then { + 0 + } else { + _clampedYaw / abs _clampedYaw + }; _clampedPitch = _pitchSign * _pitchRate; _clampedYaw = _yawSign * _clampedYaw; }; diff --git a/addons/missileguidance/functions/fnc_lineOfSight_onFired.sqf b/addons/missileguidance/functions/fnc_lineOfSight_onFired.sqf new file mode 100644 index 0000000000..66a03d7c30 --- /dev/null +++ b/addons/missileguidance/functions/fnc_lineOfSight_onFired.sqf @@ -0,0 +1,24 @@ +#include "script_component.hpp" +/* + * Author: Brandon (TCVM) + * Sets up LOS navigation state arrays (called from missileGuidance's onFired). + * + * Arguments: + * Guidance Arg Array + * + * Return Value: + * None + * + * Example: + * [] call ace_missileguidance_fnc_proNav_onFired + * + * Public: No + */ +params ["_firedEH", "", "", "", "_stateParams"]; +_firedEH params ["_shooter","","","","_ammo","","_projectile"]; +_launchParams params ["_shooter","_targetLaunchParams","_seekerType","_attackProfile","_lockMode","_laserInfo","_navigationType"]; +_targetLaunchParams params ["_target", "_targetPos", "_launchPos"]; +_stateParams params ["_lastRunTime", "_seekerStateParams", "_attackProfileStateParams", "_lastKnownPosState","_navigationParams"]; +_seekerParams params ["_seekerAngle", "_seekerAccuracy", "_seekerMaxRange", "_seekerMinRange"]; + +_stateParams set [4, [[0, 0, 0]]]; diff --git a/addons/missileguidance/functions/fnc_navigationType_lineOfSight.sqf b/addons/missileguidance/functions/fnc_navigationType_lineOfSight.sqf new file mode 100644 index 0000000000..2b621dae97 --- /dev/null +++ b/addons/missileguidance/functions/fnc_navigationType_lineOfSight.sqf @@ -0,0 +1,43 @@ +#include "script_component.hpp" +/* + * Author: Brandon (TCVM) + * Projectile will take the direct LOS path to target + * + * Arguments: + * Guidance Arg Array + * + * Return Value: + * Commanded acceleration normal to LOS in world space + * + * Example: + * [] call ace_missileguidance_fnc_navigationType_lineOfSight + * + * Public: No + */ +params ["_args", "_timestep", "_seekerTargetPos", "_profileAdjustedTargetPos"]; +_args params ["_firedEH", "", "", "", "_stateParams"]; +_firedEH params ["","","","","","","_projectile"]; +_stateParams params ["", "", "", "","_navigationParams"]; +_navigationParams params ["_lastLineOfSight"]; + +// LOS navigation implemented via https://apps.dtic.mil/sti/pdfs/ADA481330.pdf (called bang-bang) + +private _closingVelocity = vectorMagnitude velocity _projectile; +private _lineOfSight = vectorNormalized (_profileAdjustedTargetPos vectorDiff getPosASLVisual _projectile); + +// the los rate is tiny, so we multiply by a constant of a power of ten to get more aggressive acceleration +// this is just due to how we measure our LOS delta, the vectors involved are _tiny_ +private _losDelta = _lineOfSight vectorDiff _lastLineOfSight; +private _losRate = 1000 * (vectorMagnitude _losDelta) / _timestep; + +private _commandedAcceleration = _closingVelocity vectorMultiply _losRate; + +// we need acceleration normal to our LOS +private _commandedAccelerationProjected = _lineOfSight vectorMultiply (_commandedAcceleration vectorDotProduct _lineOfSight); +_commandedAcceleration = _commandedAcceleration vectorDiff _commandedAccelerationProjected; + +if (accTime > 0) then { + _navigationParams set [0, _lineOfSight]; +}; + +_commandedAcceleration diff --git a/addons/missileguidance/todo.txt b/addons/missileguidance/todo.txt new file mode 100644 index 0000000000..896c891634 --- /dev/null +++ b/addons/missileguidance/todo.txt @@ -0,0 +1,29 @@ +Weapon Configs: + Hellfire - Laser + AGM-65 - Laser + DAGR - Laser + GBU-12 - Laser + + Dragon - SACLOS + Metis - SACLOS + HOT - SACLOS + + Javelin - Optical + NLAW - PLOS + +Seeker Types: + Laser - causes lots of weapon noise, causing bad guidance + +Navigation Types: + GBU-12 - LOS Guidance + NLAW - LOS Guidance + Dragon - LOS Guidance + Metis - LOS Guidance + HOT - LOS Guidance + + Javelin - Pro Nav + Hellfire - Pro Nav + AGM-65 - Pro Nav + DAGR - Pro Nav + +