Add paremter to allow weathervaning

Weapons usually tend toward the velocity vector due to aerodynamics - calculate side slip and use calculation to do this
This commit is contained in:
Brandon Danyluk 2021-05-01 20:19:22 -06:00
parent 73b059859c
commit f5b316176c
3 changed files with 21 additions and 4 deletions

View File

@ -10,6 +10,7 @@ class CfgAmmo {
yawRate = 5;
bangBangGuidance = 1;
stabilityCoefficient = 0.4; // how much this projectile likes to "weathervane" (keep direction toward velocity)
canVanillaLock = 0; // Can this default vanilla lock? Only applicable to non-cadet mode

View File

@ -32,7 +32,7 @@ if (!alive _projectile || isNull _projectile || isNull _shooter) exitWith {
private _timestep = diag_deltaTime * accTime;
_flightParams params ["_pitchRate", "_yawRate", "_isBangBangGuidance"];
_flightParams params ["_pitchRate", "_yawRate", "_isBangBangGuidance", "_stabilityCoefficient"];
// Run seeker function:
private _seekerTargetPos = [[0,0,0], _args, _seekerStateParams, _lastKnownPosState, _timestep] call FUNC(doSeekerSearch);
@ -110,8 +110,18 @@ if ((_pitchRate != 0 || {_yawRate != 0}) && {_profileAdjustedTargetPos isNotEqua
};
TRACE_9("pitch/yaw/roll",_pitch,_yaw,_roll,_yawChange,_pitchChange,_pitchRate,_yawRate,_clampedPitch,_clampedYaw);
_pitch = _pitch + _clampedPitch * _timestep;
_yaw = _yaw + _clampedYaw * _timestep;
// directional stability
private _localVelocity = _projectile vectorWorldToModelVisual (velocity _projectile);
private _velocityAngleYaw = (_localVelocity#0) atan2 (_localVelocity#1);
private _velocityAnglePitch = (_localVelocity#2) atan2 (_localVelocity#1);
// bastardized version of direction stability https://en.wikipedia.org/wiki/Directional_stability#Steering_forces
private _forceYaw = _stabilityCoefficient * _velocityAngleYaw + _clampedYaw;
private _forcePitch = _stabilityCoefficient * _velocityAnglePitch + _clampedPitch;
_pitch = _pitch + _forcePitch * _timestep;
_yaw = _yaw + _forceYaw * _timestep;
TRACE_3("new pitch/yaw/roll",_pitch,_yaw,_roll);
@ -184,6 +194,8 @@ if (GVAR(debug_drawGuidanceInfo)) then {
_PS setParticleParams [["\A3\Data_f\cl_basic", 8, 3, 1], "", "Billboard", 1, 3.0141, [0, 0, 2], [0, 0, 0], 1, 1.275, 1, 0, [1, 1], [[1, 0, 0, 1], [1, 0, 0, 1], [1, 0, 0, 1]], [1], 1, 0, "", "", nil];
_PS setDropInterval 1.0;
};
drawLine3D [ASLtoAGL _projectilePos, (ASLtoAGL _projectilePos) vectorAdd velocity _projectile, [1, 1, 1, 1]];
};
_stateParams set [0, diag_tickTime];

View File

@ -116,6 +116,9 @@ if (isNumber (_config >> "pitchRate")) then {
_bangBang = 1 == getNumber (_config >> "bangBangGuidance");
};
// How much this projectile likes to stay toward current velocity
private _stabilityCoefficient = getNumber (_config >> "stabilityCoefficient");
private _navigationStateSubclass = _config >> "navigationStates";
private _states = getArray (_navigationStateSubclass >> "states");
@ -148,7 +151,8 @@ private _args = [_this,
[
_pitchRate,
_yawRate,
_bangBang
_bangBang,
_stabilityCoefficient
],
[
getNumber ( _config >> "seekerAngle" ),