PropNav
A 3-DOF point mass kinematic model of an ideal proportional navigation guidance missile written entirely in Python 3. Capable of creating trajectory files compatible with the pyThreeD program provided herein and the threeD program available at https://www.github.com/gedeschaines/threeD
Install / Use
/learn @gedeschaines/PropNavREADME
propNav
<p align="center"> <img src="./img/img_anim_1243.gif" width="800" height="600" alt="Animated GIF from threeD rendering for TXYZ.OUT.1243"/><br> Animated GIF from threeD rendering for TXYZ.OUT.1243. </p>
A 3-DOF point mass kinematic model of an ideal proportional navigation guidance missile written entirely in Python 3; dependent upon only two readily available modules - NumPy and Matplotlib.
Overview
The propNav program was translated from a Mathcad variant developed in the mid to late 1990's as a tool to perform rudimentary evaluations of surface to air missile (SAM) engagement capabilities against likely targets. During that time, a high fidelity 6-DOF missile simulation was utilized to perform detailed engineering analysis of candidate SAM performance in specific target engagement scenarios. However, when evaluating performance envelopes for multiple engagement scenarios requiring hundreds of run cases, a 3-DOF was easier to setup, and used much less computing resources and time than the 6-DOF. Of course, there was a known and acceptable loss of realism and accuracy when employing a 3-DOF in this manner.
Also included in this repository are the components of pyThreeD, a Python 3 variant of the X11/C threeD program. As with propNav, this Python 3 program only requires the NumPy and Matplotlib modules.
The table presented on this web page provides links to MP4 videos for several missile/target engagement sample cases which show engagement animations with simple 3D line plots created by propNav, and with 3D faceted missile and target shapes rendered by pyThreeD and threeD from trajectory data files written by propNav.
Repository Structure
The repository main directory contains this README file, plain text disclaimer file, and following Python script files which comprise the propNav program.
- propNav.py - Python script for 3-DOF model
- RK4_solver.py - Python script for Runge-Kutta 4th order ODE solver class
- propNav.ipynb - Jupyter notebook implementation of propNav.py
The main directory also contains Python 3 script files which comprise pyThreeD, a Python 3 variant of the X11/C threeD program.
- pyThreeD.py - Python script for pyThreeD main routine translated from threeD.c source file
- pyThreeD.ipynb - Jupyter notebook implementation of pyThreeD.py
- draw3D.py - Faceted shape 3D rendering routines translated from draw3D.c source file
- pquelib.py - Priority queue routines translated from pquelib.c source file
- cliplib.py - Polygon clipping routines translated from cliplib.c source file
The contents of each subdirectory are as follows:
- dat - Polygon data files for threeD ground plane, missile and target faceted shapes.
- docs - Documentation HTML web pages and media files.
- img - Saved Figures 13 and 14 3D plot images from propNav SAM case 1234, animated GIF file created with threeD from ./out/TXYZ.OUT.1234 file.
- out - TXYZ.OUT trajectory data files written by propNav for sample missile/target engagement cases (see "Sample Cases" section below).
- util - Bash shell scripts and Windows Batch files to convert sequence of PNG images to animated GIF or MP4 video files.
- Ximg - Images captured during pyThreeD execution (Exists only in local repository workspace).
Execution Prerequisites
Latest development effort for propNav and pyThreeD programs has been with Anaconda 3 Python versions 3.7.4 and 3.9.18 on a Windows 10 Pro system using the following Conda packages.
<p align="center">Versions of requisite modules associated with Python version <table rows="6" cols="3"> <tr> <th colspan="1"> </th> <th colspan="2" align="center">Python Version</th> </tr> <tr> <th colspan="1" align="left">Modules</th> <th colspan="1" align="center">3.7.4</th> <th colspan="1" align="center">3.9.18</th> </tr> <tr> <td align="left">NumPy</td> <td align="center">1.16.5</td> <td align="center">1.24.4</td> </tr> <tr> <td align="left">Matplotlib</td> <td align="center">3.1.1</td> <td align="center">3.8.0</td> </tr> </table> </p>Both propNav and pyThreeD have been successfully run with platform OS Python distributions using Python, Matplotlib and NumPy versions presented in the following table.
<p align="center"> Platform OS and Python versions supporting propNav and pyThreeD <table rows="10" cols="5"> <tr> <th colspan="2" align="left"> </th> <th colspan="3" align="Center">Versions</th> </tr> <tr> <th colspan="1" align="left">Platform OS</th> <th colspan="1" align="left">Python Distribution</th> <th colspan="1" align="center">Python</th> <th colspan="1" align="center">NumPy</th> <th colspan="1" align="center">Matplotlib</th> </tr> <tr> <td align="left">Windows 10.0.19045 Pro</td> <td align="left">Anaconda 3 2019.10</td> <td align="center">3.6.12</th> <td align="center">1.19.5</td> <td align="center">3.3.4</td> </tr> <tr> <td align="left">Windows 10.0.19045 Pro</td> <td align="left">Anaconda 3 2019.10</td> <td align="center">3.7.4</th> <td align="center">1.16.5</td> <td align="center">3.1.1</td> </tr> <tr> <td align="left">Windows 10.0.19045 Pro</td> <td align="left">Anaconda 3 2023.09-0</td> <td align="center">3.9.18</th> <td align="center">1.24.4</td> <td align="center">3.8.0</td> </tr> <tr> <td align="left">Windows 10.0.19045 Pro</td> <td align="left">Anaconda 3 2023.09-0</td> <td align="center">3.11.5</th> <td align="center">1.24.3</td> <td align="center">3.7.2</td> </tr> <tr> <td align="left">Windows 10.0.19045 Pro</td> <td align="left">Python Org PSF 3.9.3568.0</td> <td align="center">3.9.13</th> <td align="center">1.20.1</td> <td align="center">3.8.2</td> </tr> <tr> <td align="left">Windows 10.0.19045 Pro</td> <td align="left">MinGW64 3.4.9</td> <td align="center">3.8.7</th> <td align="center">1.20.1</td> <td align="center">3.3.4</td> </tr> <tr> <td align="left">Windows 10.0.19045 Pro</td> <td align="left">Cygwin64 3.4.10 (Only Jupyter notebook worked)</td> <td align="center">3.9.16</th> <td align="center">1.26.1</td> <td align="center">3.5.1</td> </tr> <tr> <td align="left">Windows 10.0.19045 Pro</td> <td align="left">WSL2 Ubuntu 20.04</td> <td align="center">3.8.10</th> <td align="center">1.17.4</td> <td align="center">3.1.2</td> </tr> </table> </p>Execution Overview
If utilizing propNav from a command terminal, then from within the ./propNav directory, invoke python propNav.py to execute propNav.py. There are four primary processing option control flags -- SHOW_ANIM, SAVE_ANIM, PLOT_DATA and PRINT_TXYZ; the purpose of each described below.
If the "SHOW_ANIM" flag in the propNav.py file is set to true, then during missile flyout a 3D engagement animation plot depicting motion of the missile along its trajectory and target along its flight path up to the time of intercept, or miss, will be displayed as Matplotlib Figure 14. Upon flyout completion and while Figure 14 is active, the user can interactively replay the animation forward and backward in time using key presses as documented in instructions printed to the terminal when flyout completes. An important feature of the 3D engagement animation is the inclusion of XY plan and XZ profile views for projected locations of missile and target at time-to-go (tgo) assuming constant velocity and heading. An example is shown in the following sequence of saved images of Figure 14 for case 1243 engagement animation at time-of-flight (tof) equal to 0.00, 2.20 and 4.4132 seconds.
<p align="center"> <img src="./img/Figure_14_1243_0_0000.png" width="600" height="600" alt="Figure 14 for case 1243 engagement animation at tof=0.00 seconds"/><br> Figure 14 for case 1243 engagement animation at tof=0.00 seconds </p> <p align="center"> <img src="./img/Figure_14_1243_2_2000.png" width="600" height="600" alt="Figure 14 for case 1243 engagement animation at tof=2.20 seconds"/><br> Figure 14 for case 1243 engagement animation at tof=2.20 seconds </p> <p align="center"> <img src="./img/Figure_14_1243_4_4132.png" width="600" height="600" alt="Figure 14 for case 1243 engagement animation at tof=4.4132 seconds"/><br> Figure 14 for case 1243 engagement animation at tof=4.4132 seconds </p>At about half way into the final tof of 4.4132 seconds for this case of a SAM against a fixed-wing target performing a constant 3g inward level banked turning maneuver, the missile's projected location at tgo (blue 'x' at terminal end of blue&black dotted line segment) is aligning with the projected location at tgo of the target (red square at terminal end of red&black dotted line segment) with assumed constant velocity and heading as determined by the ideal application of pure proportional navigation guidance with navigation constant of 4.
If the "SAVE_ANIM" flag in the propNav.py file is set to true and ffmpeg or avconv is available, then the same 3D engagement animation plot described above for "SHOW_ANIM" will be created upon completion of missile flyout, saved to a video file and displayed on the desktop as Matplotlib Figure 14. Unlike for SHOW_ANIM, this displayed 3D engagement animation cannot be replayed. To interact with the 3D engagement animation, the user will be limited to playback speed and frame stepping options available wh
