From a93eb6433d68362f9e9fb670f644ba283a529186 Mon Sep 17 00:00:00 2001 From: Brandon Danyluk Date: Tue, 13 Apr 2021 14:09:36 -0600 Subject: [PATCH] implement augmented proportional navigation --- addons/aim120/CfgAmmo.hpp | 8 +-- addons/hellfire/CfgAmmo.hpp | 4 ++ addons/missileguidance/ACE_GuidanceConfig.hpp | 4 ++ addons/missileguidance/XEH_PREP.hpp | 1 + .../functions/fnc_attackProfile_LOFT.sqf | 3 +- .../fnc_navigationType_augmentedProNav.sqf | 63 +++++++++++++++++++ addons/missileguidance/todo.txt | 26 ++++---- 7 files changed, 93 insertions(+), 16 deletions(-) create mode 100644 addons/missileguidance/functions/fnc_navigationType_augmentedProNav.sqf diff --git a/addons/aim120/CfgAmmo.hpp b/addons/aim120/CfgAmmo.hpp index b2008d625e..27a044143c 100644 --- a/addons/aim120/CfgAmmo.hpp +++ b/addons/aim120/CfgAmmo.hpp @@ -22,8 +22,8 @@ class CfgAmmo { defaultSeekerLockMode = "LOAL"; seekerLockModes[] = { "LOAL", "LOBL" }; - defaultNavigationType = "ProportionalNavigation"; - navigationTypes[] = { "ProportionalNavigation" }; + defaultNavigationType = "AugmentedProportionalNavigation"; + navigationTypes[] = { "AugmentedProportionalNavigation" }; seekLastTargetPos = 0; // seek last target position [if seeker loses LOS of target, continue to last known pos] seekerAngle = 50; // Angle from the shooter's view that can track the missile @@ -62,8 +62,8 @@ class CfgAmmo { defaultSeekerLockMode = "LOAL"; seekerLockModes[] = { "LOAL", "LOBL" }; - defaultNavigationType = "ProportionalNavigation"; - navigationTypes[] = { "ProportionalNavigation" }; + defaultNavigationType = "AugmentedProportionalNavigation"; + navigationTypes[] = { "AugmentedProportionalNavigation" }; seekLastTargetPos = 0; // seek last target position [if seeker loses LOS of target, continue to last known pos] seekerAngle = 50; // Angle from the shooter's view that can track the missile diff --git a/addons/hellfire/CfgAmmo.hpp b/addons/hellfire/CfgAmmo.hpp index a5e2a54429..f8cfa68587 100644 --- a/addons/hellfire/CfgAmmo.hpp +++ b/addons/hellfire/CfgAmmo.hpp @@ -83,6 +83,10 @@ class CfgAmmo { activeRadarEngageDistance = 1000; seekerMaxRange = 2000; // distance that the hellfire internal radar can scan + + // we can get target acceleration data from radar + defaultNavigationType = "AugmentedProportionalNavigation"; + navigationTypes[] = { "AugmentedProportionalNavigation" }; }; // Vanilla lock system vars diff --git a/addons/missileguidance/ACE_GuidanceConfig.hpp b/addons/missileguidance/ACE_GuidanceConfig.hpp index d815641bea..36f48ffe8e 100644 --- a/addons/missileguidance/ACE_GuidanceConfig.hpp +++ b/addons/missileguidance/ACE_GuidanceConfig.hpp @@ -98,4 +98,8 @@ class GVAR(NavigationTypes) { functionName = QFUNC(navigationType_proNav); onFired = QFUNC(proNav_onFired); }; + class AugmentedProportionalNavigation { + functionName = QFUNC(navigationType_augmentedProNav); + onFired = QFUNC(proNav_onFired); + }; }; diff --git a/addons/missileguidance/XEH_PREP.hpp b/addons/missileguidance/XEH_PREP.hpp index 75b891da12..6632d64d41 100644 --- a/addons/missileguidance/XEH_PREP.hpp +++ b/addons/missileguidance/XEH_PREP.hpp @@ -29,6 +29,7 @@ PREP(attackProfile_JAV_DIR); PREP(attackProfile_JAV_TOP); // Navigation Profiles +PREP(navigationType_augmentedProNav); PREP(navigationType_proNav); PREP(navigationType_lineOfSight); diff --git a/addons/missileguidance/functions/fnc_attackProfile_LOFT.sqf b/addons/missileguidance/functions/fnc_attackProfile_LOFT.sqf index eb3a9583ee..3c8a7f289a 100644 --- a/addons/missileguidance/functions/fnc_attackProfile_LOFT.sqf +++ b/addons/missileguidance/functions/fnc_attackProfile_LOFT.sqf @@ -32,6 +32,7 @@ if (_seekerTargetPos isEqualTo [0, 0, 0]) exitWith { }; private _projectilePos = getPosASLVisual _projectile; +private _distanceToTarget2d = _projectilePos distance2d _seekerTargetPos; private _closingRate = vectorMagnitude velocity _projectile; private _timeToGo = (_projectilePos distance _seekerTargetPos) / _closingRate; @@ -44,7 +45,7 @@ private _atMinRotationAngle = _angleToTarget >= (0.5 * _pitchRate * _timeToGo); private _returnTargetPos = _seekerTargetPos; -if !(_atMinRotationAngle) then { +if (!_atMinRotationAngle && _distanceToTarget2d >= 500 && _timeToGo >= 10) then { // 10 degree pitch up _returnTargetPos = _seekerTargetPos vectorAdd [0, 0, (_projectilePos distance _seekerTargetPos) * sin 10]; }; diff --git a/addons/missileguidance/functions/fnc_navigationType_augmentedProNav.sqf b/addons/missileguidance/functions/fnc_navigationType_augmentedProNav.sqf new file mode 100644 index 0000000000..b6a8c19cde --- /dev/null +++ b/addons/missileguidance/functions/fnc_navigationType_augmentedProNav.sqf @@ -0,0 +1,63 @@ +#include "script_component.hpp" +/* + * Author: Brandon (TCVM) + * Determine path for projectile to take in accordance to proportional navigation, takes target acceleration into account + * + * Arguments: + * Guidance Arg Array + * + * Return Value: + * Commanded acceleration normal to LOS in world space + * + * Example: + * [] call ace_missileguidance_fnc_navigationType_augmentedProNav + * + * Public: No + */ +params ["_args", "_timestep", "_seekerTargetPos", "_profileAdjustedTargetPos"]; +_args params ["_firedEH", "", "", "", "_stateParams"]; +_firedEH params ["","","","","","","_projectile"]; +_stateParams params ["", "", "", "","_navigationParams"]; +_navigationParams params ["_lastMissileFrame", "_navigationGain"]; +_lastMissileFrame params ["_lastTargetPosition", "_lastTargetVelocity", "_lastLineOfSight"]; + +// Proportional navigation implemented via "Fundamentals of proportional navigation" by Stephen Murtaugh and Harry Criel +private _projectileVelocity = velocity _projectile; + +// integrate target velocity for realistic inference of velocity +private _targetVelocity = _lastTargetVelocity; +private _targetAcceleration = [0, 0, 0]; +if (_timestep != 0) then { + _targetVelocity = (_seekerTargetPos vectorDiff _lastTargetPosition) vectorMultiply (1 / _timestep); + _targetAcceleration = (_targetVelocity vectorDiff _lastTargetVelocity) vectorMultiply (1 / _timestep); +}; + +private _closingVelocity = _targetVelocity vectorDiff _projectileVelocity; + +private _lineOfSight = vectorNormalized (_profileAdjustedTargetPos vectorDiff getPosASLVisual _projectile); + +private _targetAccelerationProjected = _lineOfSight vectorMultiply (_targetAcceleration vectorDotProduct _lineOfSight); +_targetAcceleration = _targetAcceleration vectorDiff _targetAccelerationProjected; +systemChat str vectorMagnitude _targetAcceleration; +// 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 = if (_timestep == 0) then { + 0 +} else { + 10 * (vectorMagnitude _losDelta) / _timestep; +}; + +private _lateralAcceleration = (_navigationGain * _losRate); +private _commandedAcceleration = _closingVelocity vectorMultiply _lateralAcceleration; +_commandedAcceleration = _commandedAcceleration vectorAdd (_losDelta vectorMultiply (0.5 * _navigationGain * vectorMagnitude _targetAcceleration)); + +// 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, [_seekerTargetPos, _targetVelocity, _lineOfSight]]; +}; + +_commandedAcceleration diff --git a/addons/missileguidance/todo.txt b/addons/missileguidance/todo.txt index 19c3424c96..66a97bc70c 100644 --- a/addons/missileguidance/todo.txt +++ b/addons/missileguidance/todo.txt @@ -1,24 +1,24 @@ Weapon Configs: - Hellfire - Laser - AGM-65 - Laser - DAGR - Laser - GBU-12 - Laser + X Hellfire - Laser + X AGM-65 - Laser + X DAGR - Laser + X GBU-12 - Laser - Dragon - SACLOS - Metis - SACLOS - HOT - SACLOS + X Dragon - SACLOS + X Metis - SACLOS + X HOT - SACLOS - Javelin - Optical - NLAW - PLOS + X Javelin - Optical + X NLAW - PLOS Vikhr - Beam Rider SACLOS R-73 - Infrared AIM-9 - Infrared + AIM-132 - Infrared R-77 - AHR - AIM-120 - AHR - AIM-132 - AHR + X AIM-120 - AHR KH-25 - Optical AGM-65 - Optical @@ -58,6 +58,10 @@ Navigation Types: Navigation States: Todo +Navigation Types: + X Augmented Pro-Nav + Zero Effort Miss + General To-Do: Add more weapons X Fix GBU drag