Skip to content

Commit

Permalink
fix semi-pro algorithm, update redeye
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCandianVendingMachine committed Sep 10, 2024
1 parent 3104600 commit 3cf111f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
5 changes: 3 additions & 2 deletions addons/missileguidance/CfgMissileTypesNato.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,8 @@ class GVAR(type_RBS70) {
class GVAR(type_Redeye) {
enabled = 0;

pitchRate = 27; // Minium flap deflection for guidance
yawRate = 27; // Maximum flap deflection for guidance
pitchRate = 40; // Minium flap deflection for guidance
yawRate = 40; // Maximum flap deflection for guidance

canVanillaLock = 1; // Can this default vanilla lock? Only applicable to non-cadet mode

Expand All @@ -596,6 +596,7 @@ class GVAR(type_Redeye) {

defaultNavigationType = "LineOfSight";
navigationTypes[] = { "LineOfSight" };
navigationGain = 3;

seekLastTargetPos = 0; // seek last target position [if seeker loses LOS of target, continue to last known pos]
seekerAngle = 45; // Angle from the shooter's view that can track the missile
Expand Down
1 change: 1 addition & 0 deletions addons/missileguidance/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ PREP(mwr_onFired);
PREP(IR_onFired);

// Navigation OnFired
PREP(los_onFired);
PREP(proNav_onFired);
PREP(line_onFired);

24 changes: 11 additions & 13 deletions addons/missileguidance/functions/fnc_navigationType_lineOfSight.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,29 @@ params ["_args", "_timestep", "_seekerTargetPos", "_profileAdjustedTargetPos"];
_args params ["_firedEH", "", "", "", "_stateParams", "_targetData"];
_firedEH params ["","","","","","","_projectile"];
_stateParams params ["", "", "", "","_navigationParams"];
_navigationParams params ["_onLaunch"];
_onLaunch params ["_lastLineOfSight"];
_targetData params ["_targetDirection", "_attackProfileDirection", "", "_targetVelocity", ""];
_navigationParams params ["_lastMissileFrame", "_navigationGain"];
_lastMissileFrame params ["_lastLineOfSight"];
_targetData params ["_targetDirection", "_attackProfileDirection"];

// Semi-proportional navigation implemented via "Fundamentals of proportional navigation" by Stephen Murtaugh and Harry Criel

// 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 = _attackProfileDirection vectorDiff _lastLineOfSight;
private _losDelta = (vectorNormalized _attackProfileDirection) vectorDiff (vectorNormalized _lastLineOfSight);
private _losRate = if (_timestep == 0) then {
0
} else {
10 * (vectorMagnitude _losDelta) / _timestep;
1 * (vectorMagnitude _losDelta) / _timestep;
};

private _closingVelocity = _targetVelocity vectorDiff (velocity _projectile);
private _lateralAcceleration = _navigationGain * _losRate;
private _commandedAcceleration = _attackProfileDirection vectorMultiply _lateralAcceleration;

private _commandedAcceleration = _closingVelocity vectorMultiply _losRate;
private _missileDirection = vectorNormalized velocity _projectile;

// we need acceleration normal to our LOS
private _commandedAccelerationProjected = _attackProfileDirection vectorMultiply (_commandedAcceleration vectorDotProduct _attackProfileDirection);
private _commandedAccelerationProjected = _missileDirection vectorMultiply (_commandedAcceleration vectorDotProduct _missileDirection);
_commandedAcceleration = _commandedAcceleration vectorDiff _commandedAccelerationProjected;

if (accTime > 0) then {
_navigationParams set [0, [_attackProfileDirection]];
_navigationParams set [0, [_seekerTargetPos]];
};

_targetDirection
_commandedAcceleration

0 comments on commit 3cf111f

Please sign in to comment.