Simulating differential games (specifically pursuit/evasion scenarios) using python.
Differential equations
source: Fundamentals of Aerospace Navigation and Guidance by Kabamba & Girard
Differential equation solver
Python/Scipy solv_ivp
or could implement as a discrete time system...
Player strategy ideas (for choosing heading angles)
- Minimize/maximize distance
- Move in tangential direction of attacker
- Knowing previous history of other player or not
- Neural network / machine learning for creating strategy using sklearn libraries (maybe...)
Pursuer strategies
phiSingleState
- calculates the requiredphi
to reach the evader using a single snapshot (issues witharctan2
range wrap)phiThetaHistory
- calculates the requiredphi
to reach the evader using previoustheta
history (solves thearctan2
wrap issue)phiPerturb
- simple method based onphiThetaHistory
but handles a detected loop by perturbing the pursuerphi
Evader strategies
psiRandom
- random direction changes every 20 stepspsiTurn90
- every 5 steps, calculates newpsi
that is 90 degrees from a line drawn from pursuer to evader. Left vs right turn is handled depending on pursuer heading.
Current winning strategy: phiPerturb
beats all pursuer methods
Caveat: this may be because of a flaw in the psiTurn90
algorithm
Algorithms
- Initialize with some set of parameters.
- Simulate first step using ODE solver.
- Choose heading angles using strategy.
- Repeat 2 and 3 until time runs our or collision occurs.
Notes
- wavy behavior exhibited when using
phiCalcSingleState
is solved usingnp.unwrap
with previous history inphiCalcThetaHistory
- not sure if this is a bug or not: whenever the pursuer misses, it makes a loop.
- Running instructions (overall run with
python3 main.py
):runAllSim
runs all methods against each other and outputs resultsrunSim
runs a specific methodanimate.animate
allows for animated python figure
- To-Do: rewrite using object oriented programming