Implementing the Command to Line of Sight (CLOS) guidance method in World in Conflict (also can be ported to other game environments).
Link - Youtube.com
def GCFLINT_Command_to_LOS( msl_pos, launcher_pos, tgt_pos, latax, cre_data, beam_motion_data ): """ Command to Line of Sight (CLOS) Guidance msl_pos = (Vector3) missile's current position launcher_pos = (Vector3) launcher's current position tgt_pos = (Vector3) target's current position latax = (Mutable Vector3) mutable object for providing guidance command cre_data = (Mutable dict) dict object for Kalman estimation states on CRE beam_motion_data = (Mutable Vector3) mutable object for recording previous beam motion Command to LOS (CLOS) Guidance or "three point guidance" is probably the oldest and the first rudimentary form of missile guidance methods. Tracing its roots back to the Nazi Germany's Wasserfall experimental SAM and early forms of anti-shipping guided PGMs, it was originally conceived as Manual Command to LOS (MaCLOS or MCLOS), where a human operator remotely steered the missile along his visible line of sight toward the target. After the World War, MCLOS was further modified with improvements in sensors and analog computing technology, spawning new derivatives such as Semi-Automatic Command to LOS (SACLOS), Automatic Command to LOS (ACLOS or simply CLOS) and Beamriding Guidance. In case of SACLOS, the operator has to maintain his sight on the target and the guidance computer will automatically generate the necessary steering commands to the outgoing missile -- a good example of this is BGM-71 TOW missile. Fully automatic CLOS (ACLOS) was used on first generation SAMs (i.e. Talos, Nike Zeus, etc). Even to this day, ACLOS is widely popular for cheap short-range AA uses (i.e. SA-22 Pantsir/SA-19 Tunguska, Crotale, RBS-70, Roland, etc), because the missile is very cheap to manufacture (there is no need for seeker and complex embedded electronics). CLOS works on the premise that the target, outgoing missile and the launcher are all on the same Line of Sight (LOS) line. As missile is outgoing, the guidance computer on the launcher will steer the missile to snap it on its sightline/LOS toward the target. The outgoing missile's distance normal to the launcher-to-target LOS (that is, how far the missile is off from the LOS line) is known as the 'Cross Range Error' or 'CRE'. It is this 'CRE' that the guidance computer will have to reduce to zero in order to get the outgoing missile to snap back on the LOS line toward the target. CRE is to be calculated as follows: CRE = |radar_to_missile| x<cross product> |radar_to_target| ----------------------------------------------------- |radar_to_target| The guidance computer will calculate the required lateral acceleration to bring CRE to zero, where: required acceleration = K * CRE + Beam_Motion_Term K = optional Guidance Gain Because CLOS relies on the launcher-target LOS as its principal tracking reference, it is quite vulnerable to high velocity situations, especially in situations where the target is crossing; in such cases, it can behave as bad as pure-pursuit/tail-chase homing guidance. To help mitigate the increased acceleration requirements against crossing targets, a "Beam motion" term is added after the guidance command. Beam motion is the target's acceleration normal to the launcher-target LOS. Addition of beam motion term allows CLOS missile to more quickly react to changing LOS rate, but ultimately, CLOS is at best, good for producing lot of cheap anti-aircraft and anti-slow-moving (i.e. tank) missiles. For intercepting high performance targets with good accuracy, or to achieve sophisticated "hit to kill" type of interception, you would want to use one of the modern derivatives of Proportional Navigation (PN) family of guidance methods. """ import wic.common.math as math from predictorFCS_flint__includes__ import EXFLINT_Kalman_Filter launcher_to_msl = math.Vector3( msl_pos ) - launcher_pos msl_heading_direction = ( math.Vector3( tgt_pos ) - msl_pos ).NormalizeSafe() command_los = math.Vector3( tgt_pos ) - launcher_pos # Cross Range Error (CRE) - # radar_to_msl <X cross product> radar_to_tgt * ( 1.0 / radar_to_target ) CRE = EXFLINT_Kalman_Filter( cre_data, ( launcher_to_msl.Cross(command_los) * ( 1.0 / command_los.Length() ) ).Length() ) # Beam motion term -- perceived target's inertial acceleration normal # to Line of Sight Bmp = math.Vector3( tgt_pos ) - beam_motion_data beam_motion_data = math.Vector3( tgt_pos ) # Now, calculate the final Lateral Acceleration required for our missile # to home into our target. latax = msl_heading_direction * CRE + Bmp # my job is done, it's now up to EXFLINT.Integrate() to steer the missile. return True