初次提交,只有想定基本结构
This commit is contained in:
992
processors/aa_intercept.txt
Normal file
992
processors/aa_intercept.txt
Normal file
@@ -0,0 +1,992 @@
|
||||
#processor aa_intercept WSF_TASK_PROCESSOR
|
||||
#
|
||||
# update_interval 5 sec
|
||||
#
|
||||
# script_variables
|
||||
# double launchRange = 20 * MATH.M_PER_NM();
|
||||
# double salvoSize = 2;
|
||||
# string weaponName = "aa_mrm";
|
||||
# WsfWeapon aa_mrm = PLATFORM.Weapon(weaponName);
|
||||
# bool canPursue = false;
|
||||
# Map<string, int> aa_mrmUseful = Map<string, int>();
|
||||
# WsfTrack currentTarget;
|
||||
# end_script_variables
|
||||
#
|
||||
# //
|
||||
# //@ pursueCondition
|
||||
# //
|
||||
# script bool pursueCondition()
|
||||
# return (
|
||||
# aa_mrm.QuantityRemaining() > 0 &&
|
||||
# TRACK.Target().IsValid()
|
||||
# );
|
||||
# end_script
|
||||
#
|
||||
# //
|
||||
# //@ Pursue
|
||||
# //
|
||||
# script bool Pursue()
|
||||
# if (pursueCondition())
|
||||
# {
|
||||
# if(PLATFORM.GroundRangeTo(TRACK.CurrentLocation()) >= launchRange)
|
||||
# {
|
||||
# PLATFORM.GoToLocation(TRACK.CurrentLocation());
|
||||
# }
|
||||
# canPursue = true;
|
||||
# return canPursue;
|
||||
# }
|
||||
# canPursue = false;
|
||||
# return canPursue;
|
||||
# end_script
|
||||
#
|
||||
# //
|
||||
# //@ CanEngage
|
||||
# //
|
||||
# script bool CanEngage()
|
||||
# bool canEngage = false;
|
||||
# if (aa_mrm.IsValid() &&
|
||||
# aa_mrm.QuantityRemaining() >= salvoSize &&
|
||||
# TRACK.Target().IsValid() &&
|
||||
# PLATFORM.GroundRangeTo(TRACK) < launchRange &&
|
||||
# WeaponsActiveFor(TRACK.TrackId()) < 1
|
||||
# )
|
||||
# {
|
||||
# aa_mrmUseful[weaponName] = 1;
|
||||
# canEngage = true;
|
||||
# }
|
||||
# return canEngage;
|
||||
# end_script
|
||||
#
|
||||
# //
|
||||
# //@ Engage
|
||||
# //
|
||||
# script void Engage()
|
||||
# if (CanEngage())
|
||||
# {
|
||||
# if(aa_mrmUseful.Exists(weaponName))
|
||||
# {
|
||||
# if(aa_mrmUseful[weaponName] == 1)
|
||||
# {
|
||||
# Fire(TRACK,"FIRE",weaponName,salvoSize,PLATFORM);
|
||||
# aa_mrmUseful[weaponName] == 0;
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# else
|
||||
# {
|
||||
# writeln_d("Cannot engage: Conditions not met.");
|
||||
# }
|
||||
# end_script
|
||||
#
|
||||
# //
|
||||
# //@ TrackAndEngage
|
||||
# //
|
||||
# script void TrackAndEngage()
|
||||
# if (TRACK.Target().IsValid())
|
||||
# {
|
||||
# if (CanEngage())
|
||||
# {
|
||||
# Engage();
|
||||
# }
|
||||
# else
|
||||
# {
|
||||
# Pursue();
|
||||
# }
|
||||
# }
|
||||
# else
|
||||
# {
|
||||
# writeln_d("No valid target to track.");
|
||||
# }
|
||||
# end_script
|
||||
#
|
||||
# //
|
||||
# //@ WeaponReplenishment
|
||||
# //
|
||||
## script void ReplenishWeapons()
|
||||
## if (aa_mrm.QuantityRemaining() < salvoSize)
|
||||
## {
|
||||
## writeln_d("Replenishing weapons: ", weaponName);
|
||||
## PLATFORM.ReplenishWeapon(weaponName); //
|
||||
## }
|
||||
## end_script
|
||||
#
|
||||
#/////////////////////state////////////////////////
|
||||
#evaluation_interval IDLE 1 sec
|
||||
#
|
||||
# state IDLE
|
||||
# on_entry
|
||||
# writeln_d("Entering IDLE state.");
|
||||
# end_on_entry
|
||||
#
|
||||
# next_state TRACKING
|
||||
# return TRACK.Target().IsValid();
|
||||
# end_next_state
|
||||
#
|
||||
# on_exit
|
||||
# writeln_d("Exiting IDLE state.");
|
||||
# end_on_exit
|
||||
# end_state
|
||||
#evaluation_interval TRACKING 1 sec
|
||||
# state TRACKING
|
||||
# on_entry
|
||||
# writeln_d("Entering TRACKING state.");
|
||||
# end_on_entry
|
||||
#
|
||||
# next_state ENGAGING
|
||||
# return CanEngage();
|
||||
# end_next_state
|
||||
#
|
||||
# next_state PURSUING
|
||||
# return pursueCondition() && !CanEngage();
|
||||
# end_next_state
|
||||
#
|
||||
# on_exit
|
||||
# writeln_d("Exiting TRACKING state.");
|
||||
# end_on_exit
|
||||
# end_state
|
||||
#evaluation_interval ENGAGING 1 sec
|
||||
# state ENGAGING
|
||||
# on_entry
|
||||
# writeln_d("Entering ENGAGING state.");
|
||||
# Engage();
|
||||
# end_on_entry
|
||||
#
|
||||
# next_state IDLE
|
||||
# return !TRACK.Target().IsValid() || aa_mrm.QuantityRemaining() < salvoSize;
|
||||
# end_next_state
|
||||
#
|
||||
# next_state TRACKING
|
||||
# return TRACK.Target().IsValid() && !CanEngage();
|
||||
# end_next_state
|
||||
#
|
||||
# on_exit
|
||||
# writeln_d("Exiting ENGAGING state.");
|
||||
# end_on_exit
|
||||
# end_state
|
||||
#evaluation_interval PURSUING 1 sec
|
||||
# state PURSUING
|
||||
# on_entry
|
||||
# writeln_d("Entering PURSUING state.");
|
||||
# Pursue();
|
||||
# end_on_entry
|
||||
#
|
||||
# next_state TRACKING
|
||||
# return TRACK.Target().IsValid() && PLATFORM.GroundRangeTo(TRACK) < launchRange;
|
||||
# end_next_state
|
||||
#
|
||||
# next_state IDLE
|
||||
# return !pursueCondition();
|
||||
# end_next_state
|
||||
#
|
||||
# on_exit
|
||||
# writeln_d("Exiting PURSUING state.");
|
||||
# end_on_exit
|
||||
# end_state
|
||||
#
|
||||
#end_processor
|
||||
|
||||
|
||||
|
||||
#processor aa_intercept WSF_TASK_PROCESSOR
|
||||
#
|
||||
# update_interval 5 sec
|
||||
#
|
||||
# script_variables
|
||||
# double launchRange = 20 * MATH.M_PER_NM(); //
|
||||
# double salvoSize = 2; //
|
||||
# string weaponName = "aa_mrm"; //
|
||||
# WsfWeapon aa_mrm = PLATFORM.Weapon(weaponName); //
|
||||
# bool canPursue = false; //
|
||||
# Map<string, int> aa_mrmUseful = Map<string, int>(); //
|
||||
# WsfTrack currentTarget; //
|
||||
# end_script_variables
|
||||
#
|
||||
# //
|
||||
# //@ SelectClosestTrack
|
||||
# //
|
||||
# script WsfTrack SelectClosestTrack()
|
||||
# WsfTrack closestTarget;
|
||||
# double closestDistance = 100000000000000000000000; //
|
||||
# foreach (WsfTrack track in PLATFORM.MasterTrackList())
|
||||
# {
|
||||
# if (track.IsValid() && PLATFORM.GroundRangeTo(track) < closestDistance)
|
||||
# {
|
||||
# closestTarget = track;
|
||||
# closestDistance = PLATFORM.GroundRangeTo(track);
|
||||
# }
|
||||
# }
|
||||
# return closestTarget;
|
||||
# end_script
|
||||
#
|
||||
# //
|
||||
# //@ pursueCondition
|
||||
# //
|
||||
# script bool pursueCondition()
|
||||
# return (
|
||||
# aa_mrm.QuantityRemaining() > 0 &&
|
||||
# currentTarget.IsValid()
|
||||
# );
|
||||
# end_script
|
||||
#
|
||||
# //
|
||||
# //@ Pursue
|
||||
# //
|
||||
# script bool Pursue()
|
||||
# if (pursueCondition())
|
||||
# {
|
||||
# double distanceToTarget = PLATFORM.GroundRangeTo(currentTarget);
|
||||
# if (distanceToTarget >= launchRange)
|
||||
# {
|
||||
# PLATFORM.GoToLocation(currentTarget.CurrentLocation());
|
||||
# }
|
||||
# canPursue = true;
|
||||
# return canPursue;
|
||||
# }
|
||||
# canPursue = false;
|
||||
# return canPursue;
|
||||
# end_script
|
||||
#
|
||||
# //
|
||||
# //@ CanEngage
|
||||
# //
|
||||
# script bool CanEngage()
|
||||
# bool canEngage = false;
|
||||
# if (aa_mrm.IsValid() &&
|
||||
# aa_mrm.QuantityRemaining() >= salvoSize &&
|
||||
# currentTarget.IsValid() &&
|
||||
# PLATFORM.GroundRangeTo(currentTarget) < launchRange &&
|
||||
# WeaponsActiveFor(currentTarget.TrackId()) < 1
|
||||
# )
|
||||
# {
|
||||
# aa_mrmUseful[weaponName] = 1;
|
||||
# canEngage = true;
|
||||
# }
|
||||
# return canEngage;
|
||||
# end_script
|
||||
#
|
||||
# //
|
||||
# //@ Engage
|
||||
# //
|
||||
# script void Engage()
|
||||
# if (CanEngage())
|
||||
# {
|
||||
# if (aa_mrmUseful.Exists(weaponName))
|
||||
# {
|
||||
# if (aa_mrmUseful[weaponName] == 1)
|
||||
# {
|
||||
# Fire(currentTarget, "FIRE", weaponName, salvoSize, PLATFORM);
|
||||
# aa_mrmUseful[weaponName] = 0; //
|
||||
## EvadeAfterEngage(); //
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# else
|
||||
# {
|
||||
# writeln_d("Cannot engage: Conditions not met.");
|
||||
# }
|
||||
# end_script
|
||||
#
|
||||
# //
|
||||
# //@ EvadeAfterEngage
|
||||
# //
|
||||
## script void EvadeAfterEngage()
|
||||
## writeln_d("Executing evade maneuver after engage.");
|
||||
## double evadeDistance = launchRange * 0.3; // 30%
|
||||
## Location evadeLocation = PLATFORM.CurrentLocation().OffsetBy(evadeDistance, MATH.RandomAngle());
|
||||
## PLATFORM.GoToLocation(RANDOM.loevadeLocation); //
|
||||
## end_script
|
||||
#
|
||||
# //
|
||||
# //@ TrackAndEngage
|
||||
# //
|
||||
# script void TrackAndEngage()
|
||||
# currentTarget = SelectClosestTrack();
|
||||
# if (currentTarget.IsValid())
|
||||
# {
|
||||
# writeln_d("Selected target ID: ", currentTarget.TrackId());
|
||||
# if (CanEngage())
|
||||
# {
|
||||
# Engage();
|
||||
# }
|
||||
# else
|
||||
# {
|
||||
# Pursue();
|
||||
# }
|
||||
# }
|
||||
# else
|
||||
# {
|
||||
# writeln_d("No valid targets available.");
|
||||
# }
|
||||
# end_script
|
||||
#
|
||||
#/////////////////////state////////////////////////
|
||||
#evaluation_interval IDLE 1 sec
|
||||
#
|
||||
# state IDLE
|
||||
# on_entry
|
||||
# writeln_d("Entering IDLE state.");
|
||||
# currentTarget = SelectClosestTrack();
|
||||
# end_on_entry
|
||||
#
|
||||
# next_state TRACKING
|
||||
# return currentTarget.IsValid();
|
||||
# end_next_state
|
||||
#
|
||||
# on_exit
|
||||
# writeln_d("Exiting IDLE state.");
|
||||
# end_on_exit
|
||||
# end_state
|
||||
#
|
||||
#evaluation_interval TRACKING 1 sec
|
||||
#
|
||||
# state TRACKING
|
||||
# on_entry
|
||||
# writeln_d("Entering TRACKING state.");
|
||||
# currentTarget = SelectClosestTrack();
|
||||
# end_on_entry
|
||||
#
|
||||
# next_state ENGAGING
|
||||
# return CanEngage();
|
||||
# end_next_state
|
||||
#
|
||||
# next_state PURSUING
|
||||
# return pursueCondition() && !CanEngage();
|
||||
# end_next_state
|
||||
#
|
||||
# on_exit
|
||||
# writeln_d("Exiting TRACKING state.");
|
||||
# end_on_exit
|
||||
# end_state
|
||||
#
|
||||
#evaluation_interval ENGAGING 1 sec
|
||||
#
|
||||
# state ENGAGING
|
||||
# on_entry
|
||||
# writeln_d("Entering ENGAGING state.");
|
||||
# Engage();
|
||||
# end_on_entry
|
||||
#
|
||||
# next_state IDLE
|
||||
# return !currentTarget.IsValid() || aa_mrm.QuantityRemaining() < salvoSize;
|
||||
# end_next_state
|
||||
#
|
||||
# next_state TRACKING
|
||||
# return currentTarget.IsValid() && !CanEngage();
|
||||
# end_next_state
|
||||
#
|
||||
# on_exit
|
||||
# writeln_d("Exiting ENGAGING state.");
|
||||
# end_on_exit
|
||||
# end_state
|
||||
#
|
||||
#evaluation_interval PURSUING 1 sec
|
||||
#
|
||||
# state PURSUING
|
||||
# on_entry
|
||||
# writeln_d("Entering PURSUING state.");
|
||||
# Pursue();
|
||||
# end_on_entry
|
||||
#
|
||||
# next_state TRACKING
|
||||
# return currentTarget.IsValid() && PLATFORM.GroundRangeTo(currentTarget) < launchRange;
|
||||
# end_next_state
|
||||
#
|
||||
# next_state IDLE
|
||||
# return !pursueCondition();
|
||||
# end_next_state
|
||||
#
|
||||
# on_exit
|
||||
# writeln_d("Exiting PURSUING state.");
|
||||
# end_on_exit
|
||||
# end_state
|
||||
#
|
||||
#end_processor
|
||||
|
||||
|
||||
#processor aa_intercept WSF_TASK_PROCESSOR
|
||||
#
|
||||
## Update interval
|
||||
#update_interval 5 sec
|
||||
#
|
||||
## Script variables
|
||||
#script_variables
|
||||
# double launchRange = 20 * MATH.M_PER_NM(); //
|
||||
# double salvoSize = 2; //
|
||||
# string weaponName = "aa_mrm"; //
|
||||
# WsfWeapon aa_mrm = PLATFORM.Weapon(weaponName); //
|
||||
# Map<string, int> aa_mrmUseful = Map<string, int>(); //
|
||||
# WsfTrack currentTarget; //
|
||||
#end_script_variables
|
||||
#
|
||||
## SelectClosestTrack
|
||||
#script WsfTrack SelectClosestTrack()
|
||||
# WsfTrack closestTarget;
|
||||
# double closestDistance = 1000000000; //
|
||||
# foreach (WsfTrack track in PLATFORM.MasterTrackList())
|
||||
# {
|
||||
# if (track.IsValid() && PLATFORM.GroundRangeTo(track) < closestDistance)
|
||||
# {
|
||||
# closestTarget = track;
|
||||
# closestDistance = PLATFORM.GroundRangeTo(track);
|
||||
# }
|
||||
# }
|
||||
# return closestTarget;
|
||||
#end_script
|
||||
#
|
||||
## CanEngage
|
||||
#script bool CanEngage()
|
||||
# bool canEngage = false;
|
||||
# if (aa_mrm.IsValid() &&
|
||||
# aa_mrm.QuantityRemaining() >= salvoSize &&
|
||||
# currentTarget.IsValid() &&
|
||||
# PLATFORM.GroundRangeTo(currentTarget) < launchRange &&
|
||||
# WeaponsActiveFor(currentTarget.TrackId()) < 1
|
||||
# )
|
||||
# {
|
||||
# aa_mrmUseful[weaponName] = 1;
|
||||
# canEngage = true;
|
||||
# }
|
||||
# return canEngage;
|
||||
#end_script
|
||||
#
|
||||
## Engage
|
||||
#script void Engage()
|
||||
# if (CanEngage())
|
||||
# {
|
||||
# if (aa_mrmUseful.Exists(weaponName))
|
||||
# {
|
||||
# if (aa_mrmUseful[weaponName] == 1)
|
||||
# {
|
||||
# Fire(currentTarget, "FIRE", weaponName, salvoSize, PLATFORM);
|
||||
# aa_mrmUseful[weaponName] = 0; //
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# else
|
||||
# {
|
||||
# writeln_d("Cannot engage: Conditions not met.");
|
||||
# }
|
||||
#end_script
|
||||
#
|
||||
## Pursue
|
||||
#script bool Pursue()
|
||||
# if (currentTarget.IsValid() && aa_mrm.QuantityRemaining() > 0)
|
||||
# {
|
||||
# double distanceToTarget = PLATFORM.GroundRangeTo(currentTarget);
|
||||
# if (distanceToTarget >= launchRange)
|
||||
# {
|
||||
# writeln_d("Target is out of range. Moving closer...");
|
||||
# PLATFORM.GoToLocation(currentTarget.CurrentLocation());
|
||||
# return true;
|
||||
# }
|
||||
# }
|
||||
# return false;
|
||||
#end_script
|
||||
#
|
||||
## TrackAndEngage
|
||||
#script void TrackAndEngage()
|
||||
# currentTarget = SelectClosestTrack();
|
||||
# if (currentTarget.IsValid())
|
||||
# {
|
||||
# writeln_d("Selected target ID: ", currentTarget.TrackId());
|
||||
# if (CanEngage())
|
||||
# {
|
||||
# Engage();
|
||||
# }
|
||||
# else
|
||||
# {
|
||||
# Pursue();
|
||||
# }
|
||||
# }
|
||||
# else
|
||||
# {
|
||||
# writeln_d("No valid targets available.");
|
||||
# }
|
||||
#end_script
|
||||
#
|
||||
## States
|
||||
#
|
||||
#evaluation_interval IDLE 1 sec
|
||||
#state IDLE
|
||||
# on_entry
|
||||
# writeln_d("Entering IDLE state.");
|
||||
# currentTarget = SelectClosestTrack();
|
||||
# end_on_entry
|
||||
#
|
||||
# next_state TRACKING
|
||||
# return currentTarget.IsValid();
|
||||
# end_next_state
|
||||
#
|
||||
# on_exit
|
||||
# writeln_d("Exiting IDLE state.");
|
||||
# end_on_exit
|
||||
#end_state
|
||||
#
|
||||
#evaluation_interval TRACKING 1 sec
|
||||
#state TRACKING
|
||||
# on_entry
|
||||
# writeln_d("Entering TRACKING state.");
|
||||
# currentTarget = SelectClosestTrack();
|
||||
# end_on_entry
|
||||
#
|
||||
# next_state ENGAGING
|
||||
# return CanEngage();
|
||||
# end_next_state
|
||||
#
|
||||
# next_state PURSUING
|
||||
# return Pursue() && !CanEngage();
|
||||
# end_next_state
|
||||
#
|
||||
# on_exit
|
||||
# writeln_d("Exiting TRACKING state.");
|
||||
# end_on_exit
|
||||
#end_state
|
||||
#
|
||||
#evaluation_interval ENGAGING 1 sec
|
||||
#state ENGAGING
|
||||
# on_entry
|
||||
# writeln_d("Entering ENGAGING state.");
|
||||
# Engage();
|
||||
# end_on_entry
|
||||
#
|
||||
# next_state IDLE
|
||||
# return !currentTarget.IsValid() || aa_mrm.QuantityRemaining() < salvoSize;
|
||||
# end_next_state
|
||||
#
|
||||
# next_state TRACKING
|
||||
# return currentTarget.IsValid() && !CanEngage();
|
||||
# end_next_state
|
||||
#
|
||||
# on_exit
|
||||
# writeln_d("Exiting ENGAGING state.");
|
||||
# end_on_exit
|
||||
#end_state
|
||||
#
|
||||
#evaluation_interval PURSUING 1 sec
|
||||
#state PURSUING
|
||||
# on_entry
|
||||
# writeln_d("Entering PURSUING state.");
|
||||
# end_on_entry
|
||||
#
|
||||
# next_state MOVE_TO_TARGET
|
||||
# return PLATFORM.GroundRangeTo(currentTarget) >= launchRange;
|
||||
# end_next_state
|
||||
#
|
||||
# next_state TRACKING
|
||||
# return PLATFORM.GroundRangeTo(currentTarget) < launchRange;
|
||||
# end_next_state
|
||||
#
|
||||
# next_state IDLE
|
||||
# return !currentTarget.IsValid();
|
||||
# end_next_state
|
||||
#
|
||||
# on_exit
|
||||
# writeln_d("Exiting PURSUING state.");
|
||||
# end_on_exit
|
||||
#end_state
|
||||
#
|
||||
#evaluation_interval MOVE_TO_TARGET 1 sec
|
||||
#state MOVE_TO_TARGET
|
||||
# on_entry
|
||||
# writeln_d("Entering MOVE_TO_TARGET state.");
|
||||
# WsfGeoPoint targetLocation = currentTarget.CurrentLocation();
|
||||
# PLATFORM.GoToLocation(targetLocation);
|
||||
# end_on_entry
|
||||
#
|
||||
# next_state PURSUING
|
||||
# return PLATFORM.GroundRangeTo(currentTarget) < launchRange;
|
||||
# end_next_state
|
||||
#
|
||||
# next_state IDLE
|
||||
# return !currentTarget.IsValid();
|
||||
# end_next_state
|
||||
#
|
||||
# on_exit
|
||||
# writeln_d("Exiting MOVE_TO_TARGET state.");
|
||||
# end_on_exit
|
||||
#end_state
|
||||
#
|
||||
#end_processor
|
||||
|
||||
|
||||
|
||||
|
||||
#processor aa_intercept WSF_TASK_PROCESSOR
|
||||
#
|
||||
## Update interval
|
||||
#update_interval 5 sec
|
||||
#
|
||||
## Script variables
|
||||
#script_variables
|
||||
# double launchRange = 20 * MATH.M_PER_NM(); //
|
||||
# double minRange = launchRange * 0.3; // 30%
|
||||
# double speedFactor = 1.2; // 20%
|
||||
# string weaponName = "aa_mrm"; //
|
||||
# WsfWeapon aa_mrm = PLATFORM.Weapon(weaponName); //
|
||||
# WsfTrack currentTarget; //
|
||||
#end_script_variables
|
||||
#
|
||||
## SelectClosestTrack
|
||||
#script WsfTrack SelectClosestTrack()
|
||||
# WsfTrack closestTarget;
|
||||
# double closestDistance = 1000000000; //
|
||||
# foreach (WsfTrack track in PLATFORM.MasterTrackList())
|
||||
# {
|
||||
# if (track.IsValid() && PLATFORM.GroundRangeTo(track) < closestDistance)
|
||||
# {
|
||||
# closestTarget = track;
|
||||
# closestDistance = PLATFORM.GroundRangeTo(track);
|
||||
# }
|
||||
# }
|
||||
# return closestTarget;
|
||||
#end_script
|
||||
#
|
||||
## AdjustSpeedTowardsTarget
|
||||
#script void AdjustSpeedTowardsTarget()
|
||||
# if (currentTarget.IsValid())
|
||||
# {
|
||||
# double targetSpeed = currentTarget.Speed();
|
||||
# double platformSpeed = PLATFORM.Speed();
|
||||
# double adjustedSpeed = targetSpeed * speedFactor;
|
||||
#
|
||||
# if (platformSpeed != adjustedSpeed)
|
||||
# {
|
||||
# writeln_d("Adjusting speed to match target...");
|
||||
# PLATFORM.GoToSpeed(adjustedSpeed); //
|
||||
# }
|
||||
# }
|
||||
#end_script
|
||||
#
|
||||
## MaintainOptimalDistance
|
||||
#script void MaintainOptimalDistance()
|
||||
# if (currentTarget.IsValid())
|
||||
# {
|
||||
# double distanceToTarget = PLATFORM.GroundRangeTo(currentTarget);
|
||||
# WsfGeoPoint targetLocation = currentTarget.CurrentLocation();
|
||||
#
|
||||
# if (distanceToTarget > launchRange) //
|
||||
# {
|
||||
# writeln_d("Target out of range, moving closer...");
|
||||
# PLATFORM.GoToLocation(targetLocation);
|
||||
# }
|
||||
# else if (distanceToTarget < minRange) //
|
||||
# {
|
||||
# writeln_d("Too close to target, increasing distance...");
|
||||
## WsfGeoPoint evadeLocation = PLATFORM.Location().OffsetBy(minRange, MATH.OppositeAngle(PLATFORM.BearingTo(targetLocation)));
|
||||
## PLATFORM.GoToLocation(evadeLocation);
|
||||
# }
|
||||
# else
|
||||
# {
|
||||
# writeln_d("Optimal distance maintained.");
|
||||
# }
|
||||
# }
|
||||
#end_script
|
||||
#
|
||||
## CanEngage
|
||||
#script bool CanEngage()
|
||||
# bool canEngage = false;
|
||||
# if (aa_mrm.IsValid() &&
|
||||
# aa_mrm.QuantityRemaining() >= 2 &&
|
||||
# currentTarget.IsValid() &&
|
||||
# PLATFORM.GroundRangeTo(currentTarget) < launchRange &&
|
||||
# WeaponsActiveFor(currentTarget.TrackId()) < 1
|
||||
# )
|
||||
# {
|
||||
# canEngage = true;
|
||||
# }
|
||||
# return canEngage;
|
||||
#end_script
|
||||
#
|
||||
## Engage
|
||||
#script void Engage()
|
||||
# if (CanEngage())
|
||||
# {
|
||||
# Fire(currentTarget, "FIRE", weaponName, 2, PLATFORM);
|
||||
# }
|
||||
# else
|
||||
# {
|
||||
# writeln_d("Cannot engage: Conditions not met.");
|
||||
# }
|
||||
#end_script
|
||||
#
|
||||
## States
|
||||
#
|
||||
#evaluation_interval IDLE 1 sec
|
||||
#state IDLE
|
||||
# on_entry
|
||||
# writeln_d("Entering IDLE state.");
|
||||
# currentTarget = SelectClosestTrack();
|
||||
# end_on_entry
|
||||
#
|
||||
# next_state TRACKING
|
||||
# return currentTarget.IsValid();
|
||||
# end_next_state
|
||||
#
|
||||
# on_exit
|
||||
# writeln_d("Exiting IDLE state.");
|
||||
# end_on_exit
|
||||
#end_state
|
||||
#
|
||||
#evaluation_interval TRACKING 1 sec
|
||||
#state TRACKING
|
||||
# on_entry
|
||||
# writeln_d("Entering TRACKING state.");
|
||||
# currentTarget = SelectClosestTrack();
|
||||
# end_on_entry
|
||||
#
|
||||
# next_state ENGAGING
|
||||
# return CanEngage();
|
||||
# end_next_state
|
||||
#
|
||||
# next_state PURSUING
|
||||
# return currentTarget.IsValid() && !CanEngage();
|
||||
# end_next_state
|
||||
#
|
||||
# on_exit
|
||||
# writeln_d("Exiting TRACKING state.");
|
||||
# end_on_exit
|
||||
#end_state
|
||||
#
|
||||
#evaluation_interval ENGAGING 1 sec
|
||||
#state ENGAGING
|
||||
# on_entry
|
||||
# writeln_d("Entering ENGAGING state.");
|
||||
# Engage();
|
||||
# end_on_entry
|
||||
#
|
||||
# next_state IDLE
|
||||
# return !currentTarget.IsValid() || aa_mrm.QuantityRemaining() < 2;
|
||||
# end_next_state
|
||||
#
|
||||
# next_state TRACKING
|
||||
# return currentTarget.IsValid() && !CanEngage();
|
||||
# end_next_state
|
||||
#
|
||||
# on_exit
|
||||
# writeln_d("Exiting ENGAGING state.");
|
||||
# end_on_exit
|
||||
#end_state
|
||||
#
|
||||
#evaluation_interval PURSUING 1 sec
|
||||
#state PURSUING
|
||||
# on_entry
|
||||
# writeln_d("Entering PURSUING state.");
|
||||
# end_on_entry
|
||||
#
|
||||
# next_state ADJUSTING_SPEED
|
||||
# return currentTarget.IsValid();
|
||||
# end_next_state
|
||||
#
|
||||
# next_state IDLE
|
||||
# return !currentTarget.IsValid();
|
||||
# end_next_state
|
||||
#
|
||||
# on_exit
|
||||
# writeln_d("Exiting PURSUING state.");
|
||||
# end_on_exit
|
||||
#end_state
|
||||
#
|
||||
#evaluation_interval ADJUSTING_SPEED 1 sec
|
||||
#state ADJUSTING_SPEED
|
||||
# on_entry
|
||||
# writeln_d("Entering ADJUSTING_SPEED state.");
|
||||
# AdjustSpeedTowardsTarget();
|
||||
# MaintainOptimalDistance();
|
||||
# end_on_entry
|
||||
#
|
||||
# next_state PURSUING
|
||||
# return true; // PURSUING
|
||||
# end_next_state
|
||||
#
|
||||
# on_exit
|
||||
# writeln_d("Exiting ADJUSTING_SPEED state.");
|
||||
# end_on_exit
|
||||
#end_state
|
||||
#
|
||||
#end_processor
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
processor aa_intercept WSF_TASK_PROCESSOR
|
||||
|
||||
# Update interval
|
||||
update_interval 5 sec
|
||||
|
||||
# Script variables
|
||||
script_variables
|
||||
double launchRange = 20 * MATH.M_PER_NM(); //
|
||||
double minRange = launchRange * 0.3; //
|
||||
double speedFactor = 1.2; // 20%
|
||||
string weaponName = "aa_mrm"; //
|
||||
WsfWeapon aa_mrm = PLATFORM.Weapon(weaponName); //
|
||||
WsfTrack currentTarget; //
|
||||
end_script_variables
|
||||
|
||||
# SelectClosestTrack
|
||||
script WsfTrack SelectClosestTrack()
|
||||
WsfTrack closestTarget;
|
||||
double closestDistance = 1000000000; //
|
||||
foreach (WsfTrack track in PLATFORM.MasterTrackList())
|
||||
{
|
||||
if (track.IsValid() && PLATFORM.GroundRangeTo(track) < closestDistance)
|
||||
{
|
||||
closestTarget = track;
|
||||
closestDistance = PLATFORM.GroundRangeTo(track);
|
||||
}
|
||||
}
|
||||
return closestTarget;
|
||||
end_script
|
||||
|
||||
# PursueLogic
|
||||
script void PursueLogic()
|
||||
if (currentTarget.IsValid())
|
||||
{
|
||||
double distanceToTarget = PLATFORM.GroundRangeTo(currentTarget);
|
||||
double targetSpeed = currentTarget.Speed();
|
||||
double platformSpeed = PLATFORM.Speed();
|
||||
double adjustedSpeed = targetSpeed * speedFactor;
|
||||
|
||||
//
|
||||
if (platformSpeed != adjustedSpeed)
|
||||
{
|
||||
PLATFORM.GoToSpeed(adjustedSpeed);
|
||||
}
|
||||
|
||||
//
|
||||
if (distanceToTarget > launchRange)
|
||||
{
|
||||
PLATFORM.GoToLocation(currentTarget.CurrentLocation());
|
||||
writeln("Moving closer to target...");
|
||||
}
|
||||
}
|
||||
end_script
|
||||
|
||||
# CanEngage
|
||||
script bool CanEngage()
|
||||
bool canEngage = false;
|
||||
if (aa_mrm.IsValid() &&
|
||||
aa_mrm.QuantityRemaining() >= 1 &&
|
||||
currentTarget.IsValid() &&
|
||||
PLATFORM.GroundRangeTo(currentTarget) < launchRange &&
|
||||
WeaponsActiveFor(currentTarget.TrackId()) < 1
|
||||
)
|
||||
{
|
||||
canEngage = true;
|
||||
}
|
||||
return canEngage;
|
||||
end_script
|
||||
|
||||
# Engage
|
||||
script void Engage()
|
||||
if (CanEngage())
|
||||
{
|
||||
Fire(currentTarget, "FIRE", weaponName, 1, PLATFORM);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeln("Cannot engage: Conditions not met.");
|
||||
}
|
||||
end_script
|
||||
|
||||
# States
|
||||
|
||||
evaluation_interval IDLE 10 sec
|
||||
state IDLE
|
||||
on_entry
|
||||
writeln("Entering IDLE state.");
|
||||
currentTarget = SelectClosestTrack();
|
||||
end_on_entry
|
||||
|
||||
next_state TRACKING
|
||||
return currentTarget.IsValid();
|
||||
end_next_state
|
||||
|
||||
on_exit
|
||||
writeln("Exiting IDLE state.");
|
||||
end_on_exit
|
||||
end_state
|
||||
|
||||
evaluation_interval TRACKING 10 sec
|
||||
time_to_evaluate TRACKING 30 s
|
||||
state TRACKING
|
||||
on_entry
|
||||
writeln("Entering TRACKING state.");
|
||||
currentTarget = SelectClosestTrack();
|
||||
end_on_entry
|
||||
|
||||
next_state ENGAGING
|
||||
return CanEngage();
|
||||
end_next_state
|
||||
|
||||
next_state PURSUING
|
||||
return currentTarget.IsValid() && !CanEngage();
|
||||
end_next_state
|
||||
|
||||
on_exit
|
||||
writeln("Exiting TRACKING state.");
|
||||
end_on_exit
|
||||
end_state
|
||||
|
||||
evaluation_interval ENGAGING 10 sec
|
||||
state ENGAGING
|
||||
on_entry
|
||||
writeln("Entering ENGAGING state.");
|
||||
Engage();
|
||||
end_on_entry
|
||||
|
||||
next_state IDLE
|
||||
return !currentTarget.IsValid() || aa_mrm.QuantityRemaining() == 0;
|
||||
end_next_state
|
||||
|
||||
next_state TRACKING
|
||||
return currentTarget.IsValid() && !CanEngage();
|
||||
end_next_state
|
||||
|
||||
on_exit
|
||||
writeln("Exiting ENGAGING state.");
|
||||
end_on_exit
|
||||
end_state
|
||||
|
||||
evaluation_interval PURSUING 10 sec
|
||||
state PURSUING
|
||||
on_entry
|
||||
writeln("Entering PURSUING state.");
|
||||
end_on_entry
|
||||
|
||||
next_state ENGAGING
|
||||
return CanEngage(); //
|
||||
end_next_state
|
||||
|
||||
next_state TRACKING
|
||||
return !currentTarget.IsValid();
|
||||
end_next_state
|
||||
|
||||
|
||||
|
||||
on_exit
|
||||
writeln("Exiting PURSUING state.");
|
||||
end_on_exit
|
||||
end_state
|
||||
|
||||
|
||||
script bool pursueCondition()
|
||||
return (
|
||||
aa_mrm.QuantityRemaining() > 0 &&
|
||||
currentTarget.IsValid()
|
||||
);
|
||||
end_script
|
||||
update_interval 100 sec
|
||||
on_update
|
||||
if(pursueCondition())
|
||||
{
|
||||
PursueLogic();
|
||||
}
|
||||
if(aa_mrm.QuantityRemaining() < 0 &&
|
||||
!currentTarget.IsValid() )
|
||||
{
|
||||
PROCESSOR.TurnOff();
|
||||
}
|
||||
end_on_update
|
||||
end_processor
|
||||
298
processors/airControl.txt
Normal file
298
processors/airControl.txt
Normal file
@@ -0,0 +1,298 @@
|
||||
# File generated by Wizard 2.9.0 on Dec 22, 2024.
|
||||
processor airControl WSF_SCRIPT_PROCESSOR
|
||||
|
||||
update_interval 10 sec
|
||||
|
||||
script_variables
|
||||
string zNameOrPoint = "tw";
|
||||
string zType = "polygon";
|
||||
WsfTrackList tl = PLATFORM.MasterRawTrackList();
|
||||
double Radius = 50000;
|
||||
bool isOver = false;
|
||||
double LLR = 175000;
|
||||
double LR = 100000;
|
||||
double MR = 50000;
|
||||
double SR = 30000;
|
||||
double a = 10000000;
|
||||
bool laststate = false;
|
||||
bool finish = false;
|
||||
double startaTime = 0;
|
||||
double lastTime = 30;
|
||||
WsfWeapon aa_mrm = PLATFORM.Weapon("aa_mrm"); //
|
||||
WsfTrack currentTarget; //
|
||||
end_script_variables
|
||||
|
||||
//
|
||||
//@ flyPolygonalZone
|
||||
//
|
||||
script void flyPolygonalZone(string zName)
|
||||
WsfZone zone = zone.FindZone(zName);
|
||||
PLATFORM.GoToSpeed(1000,999);
|
||||
PLATFORM.GoToLocation(zone.Location());
|
||||
end_script
|
||||
|
||||
//
|
||||
//@ flyCircleZone
|
||||
//
|
||||
script void flyCircleZone(string zPoint)
|
||||
WsfGeoPoint p = p.Construct(zPoint);
|
||||
PLATFORM.GoToSpeed(1000,999);
|
||||
PLATFORM.GoToLocation(p);
|
||||
end_script
|
||||
|
||||
//
|
||||
//@ fly the zone
|
||||
//
|
||||
script void flyZone(string zNameOrPoint,string zType)
|
||||
if(zType == "polygon")
|
||||
{
|
||||
flyPolygonalZone(zNameOrPoint);
|
||||
}
|
||||
else if(zType == "circle")
|
||||
{
|
||||
flyCircleZone(zNameOrPoint);
|
||||
}
|
||||
end_script
|
||||
|
||||
//
|
||||
//@ isInZone
|
||||
//
|
||||
script bool isInZone(string zNameOrPoint,string zType)
|
||||
if(zType == "polygon")
|
||||
{
|
||||
WsfZone zone = zone.FindZone(zNameOrPoint);
|
||||
return (PLATFORM.GroundRangeTo(zone.Location())<=100);
|
||||
}
|
||||
else if(zType == "circle")
|
||||
{
|
||||
WsfGeoPoint p = p.Construct(zNameOrPoint);
|
||||
return (PLATFORM.GroundRangeTo(p) < 1000);
|
||||
}
|
||||
return false;
|
||||
end_script
|
||||
|
||||
|
||||
// Calculate the distance to the nearest enemy target and return that target's Track
|
||||
script WsfTrack GetClosestEnemy()
|
||||
PLATFORM->closestTrack = WsfTrack();
|
||||
// Initialize an empty WsfTrack object
|
||||
double minDistance = 9999999.0; // Set an extremely large initial distance
|
||||
|
||||
// Iterate through all targets to find the nearest enemy
|
||||
for (int i = 0; i < PLATFORM.MasterTrackList().Count(); i = i + 1)
|
||||
{
|
||||
WsfTrack tempTrack = PLATFORM.MasterTrackList().TrackEntry(i); // Get the target
|
||||
|
||||
if (tempTrack.IsValid() && tempTrack.BelievedAlive()) // If the target is valid
|
||||
{
|
||||
double distanceToTarget = PLATFORM.GroundRangeTo(tempTrack); // Calculate the ground distance from the current platform to the target
|
||||
|
||||
if (distanceToTarget < minDistance) // If this target is closer
|
||||
{
|
||||
minDistance = distanceToTarget; // Update the minimum distance
|
||||
PLATFORM->closestTrack = tempTrack; // Update the nearest target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return PLATFORM->closestTrack; // Return the nearest target
|
||||
end_script
|
||||
|
||||
# script bool isHaveTarget()
|
||||
# return(PLATFORM.MasterTrackList().Count() > 0);
|
||||
# end_script
|
||||
|
||||
//
|
||||
//@ bounds Patrol
|
||||
//
|
||||
script void airPolygonPatrol(string zNameOrPoint)
|
||||
WsfZone zone = zone.FindZone(zNameOrPoint);
|
||||
Array<WsfGeoPoint> boundsPoints = zone.PolyPoints();
|
||||
WsfRoute route;
|
||||
WsfRoute r1 = route.Create("lx");
|
||||
foreach(WsfGeoPoint vertex in boundsPoints)
|
||||
{
|
||||
vertex.SetAltitudeHAE(10000);
|
||||
r1.Append(vertex,1500);
|
||||
}
|
||||
r1.Waypoint(0).SetLabel("start");
|
||||
r1.Waypoint(r1.Size() - 1).SetGoToLabel("start");
|
||||
PLATFORM.FollowRoute(r1);
|
||||
isOver =true;
|
||||
end_script
|
||||
|
||||
//
|
||||
//@ generateCirclePoints
|
||||
//
|
||||
script Array<WsfGeoPoint> generateCirclePoints(string Center , double radius)
|
||||
WsfGeoPoint center= WsfGeoPoint.Construct(Center);
|
||||
Array<WsfGeoPoint>circlePoints={};
|
||||
double earthRadius =6371000.0;
|
||||
double angularDistance =radius /earthRadius;
|
||||
Array<double>angles ={0.0,120,240};
|
||||
foreach(double angle in angles)
|
||||
{
|
||||
double latCenter=center.Latitude()* MATH.PI()/ 180.0;
|
||||
double loncenter= center.Longitude()* MATH.PI()/ 180.0;
|
||||
double lat= MATH.ASin(MATH.Sin(latCenter)
|
||||
* MATH.Cos(angularDistance)
|
||||
+ MATH.Cos(latCenter)
|
||||
* MATH.Sin(angularDistance)
|
||||
* MATH.Cos(angle));
|
||||
|
||||
double lon = loncenter +MATH.ATan2(MATH.Sin(angle)
|
||||
* MATH.Sin(angularDistance)
|
||||
* MATH.Cos(latCenter)
|
||||
, MATH.Cos(angularDistance)
|
||||
- MATH.Sin(latCenter)
|
||||
* MATH.Sin(lat));
|
||||
circlePoints.PushBack(WsfGeoPoint.Construct(lat*180.0/MATH.PI() , lon *180.0 / MATH.PI(),5000));
|
||||
}
|
||||
return circlePoints;
|
||||
end_script
|
||||
|
||||
//
|
||||
//@ circle execute
|
||||
//
|
||||
script void executeCircularPatrol(string zNameOrPoint)
|
||||
Array<WsfGeoPoint> circlePoints = generateCirclePoints(zNameOrPoint,Radius);
|
||||
WsfRoute route;
|
||||
WsfRoute r1= route.Create("lx");
|
||||
foreach(WsfGeoPoint vertex in circlePoints)
|
||||
{
|
||||
vertex.SetAltitudeHAE(10000);
|
||||
r1.Append(vertex,1500);
|
||||
}
|
||||
|
||||
r1.Waypoint(0).SetLabel("start");
|
||||
r1 .Waypoint(r1.Size()-1).SetGoToLabel("start");
|
||||
PLATFORM.FollowRoute(r1);
|
||||
# r1.Print();
|
||||
isOver =true;
|
||||
end_script
|
||||
|
||||
//
|
||||
//@ execute patrol
|
||||
//
|
||||
script void executePatrol(string zNameOrPoint,string zType)
|
||||
if(zType == "polygon")
|
||||
{
|
||||
airPolygonPatrol(zNameOrPoint);
|
||||
}
|
||||
else if(zType == "circle" )
|
||||
{
|
||||
executeCircularPatrol(zNameOrPoint);
|
||||
}
|
||||
end_script
|
||||
|
||||
//
|
||||
//@ isDecectedTarget
|
||||
//
|
||||
script bool isDecectedTarget()
|
||||
return(PLATFORM.MasterTrackList().Count() > 0 &&
|
||||
aa_mrm.QuantityRemaining() > 0
|
||||
# PLATFORM->closestTrack.IsValid()
|
||||
);
|
||||
end_script
|
||||
|
||||
//
|
||||
//
|
||||
//@ finishIntercept
|
||||
//
|
||||
script bool finishIntercept()
|
||||
bool finished = false;
|
||||
WsfTrack closestTarget = GetClosestEnemy();
|
||||
if (closestTarget.IsNull() || closestTarget.BelievedDead())
|
||||
{
|
||||
writeln("Target is destroyed or not valid.");
|
||||
finished = true;
|
||||
}
|
||||
|
||||
double currentTime = TIME_NOW;
|
||||
if (currentTime - startaTime >= lastTime)
|
||||
{
|
||||
writeln("Task timeout.");
|
||||
finished = true;
|
||||
}
|
||||
|
||||
return finished;
|
||||
end_script
|
||||
|
||||
|
||||
//
|
||||
//@ ON aa_intercept
|
||||
//
|
||||
script void trunOnIntercept()
|
||||
WsfProcessor launchComputer = PLATFORM.Processor("intercept");
|
||||
if (! launchComputer.IsTurnedOn())
|
||||
{
|
||||
writeln("Starting attack at T=", TIME_NOW);
|
||||
launchComputer.TurnOn();
|
||||
}
|
||||
end_script
|
||||
|
||||
//
|
||||
//@ OFF aa_intercept
|
||||
//
|
||||
script void trunOffIntercept()
|
||||
WsfProcessor launchComputer = PLATFORM.Processor("intercept");
|
||||
if (! launchComputer.IsTurnedOff())
|
||||
{
|
||||
writeln("Stoping attack at T=", TIME_NOW);
|
||||
launchComputer.TurnOff();
|
||||
}
|
||||
end_script
|
||||
|
||||
/////////////////////execute//////////////////////////
|
||||
execute at_time 2 sec relative
|
||||
writeln("start before PROCESSOR.SetState(MOVER)");
|
||||
PROCESSOR.SetState("MOVER");
|
||||
end_execute
|
||||
/////////////////////state////////////////////////
|
||||
state MOVER
|
||||
on_entry
|
||||
flyZone(zNameOrPoint,zType);
|
||||
end_on_entry
|
||||
|
||||
next_state PATROL
|
||||
return isInZone(zNameOrPoint,zType);
|
||||
end_next_state
|
||||
|
||||
next_state HIT
|
||||
return isDecectedTarget();
|
||||
end_next_state
|
||||
|
||||
on_exit
|
||||
GetClosestEnemy();
|
||||
end_on_exit
|
||||
end_state
|
||||
|
||||
state PATROL
|
||||
on_entry
|
||||
executePatrol(zNameOrPoint,zType);
|
||||
end_on_entry
|
||||
|
||||
next_state HIT
|
||||
return isDecectedTarget();
|
||||
end_next_state
|
||||
|
||||
on_exit
|
||||
GetClosestEnemy();
|
||||
end_on_exit
|
||||
end_state
|
||||
|
||||
state HIT
|
||||
on_entry
|
||||
trunOnIntercept();
|
||||
end_on_entry
|
||||
|
||||
next_state PATROL
|
||||
return (!isDecectedTarget());
|
||||
end_next_state
|
||||
|
||||
on_exit
|
||||
trunOffIntercept();
|
||||
end_on_exit
|
||||
end_state
|
||||
|
||||
end_processor
|
||||
18
processors/boundsAreaPatrol.txt
Normal file
18
processors/boundsAreaPatrol.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
# File generated by Wizard 2.9.0 on Dec 22, 2024.
|
||||
|
||||
processor boundsAreaPatrol WSF_SCRIPT_PROCESSOR
|
||||
execute at_time 50 sec relative
|
||||
WsfZone zone = zone.FindZone("tw");
|
||||
Array<WsfGeoPoint> boundsPoints = zone.PolyPoints();
|
||||
WsfRoute route;
|
||||
WsfRoute r1 = route.Create("lx");
|
||||
foreach(WsfGeoPoint vertex in boundsPoints)
|
||||
{
|
||||
vertex.SetAltitudeHAE(10000);
|
||||
r1.Append(vertex,1500);
|
||||
}
|
||||
r1.Waypoint(0).SetLabel("start");
|
||||
r1.Waypoint(r1.Size() - 1).SetGoToLabel("start");
|
||||
PLATFORM.FollowRoute(r1);
|
||||
end_execute
|
||||
end_processor
|
||||
43
processors/flyZone.txt
Normal file
43
processors/flyZone.txt
Normal file
@@ -0,0 +1,43 @@
|
||||
# File generated by Wizard 2.9.0 on Dec 22, 2024.
|
||||
processor flyZone WSF_SCRIPT_PROCESSOR
|
||||
script_variables
|
||||
string zNameOrPoint = "tw";
|
||||
string zType = "polygon";
|
||||
end_script_variables
|
||||
|
||||
//
|
||||
//@ flyPolygonalZone
|
||||
//
|
||||
script void flyPolygonalZone(string zName)
|
||||
WsfZone zone = zone.FindZone(zName);
|
||||
PLATFORM.GoToSpeed(1000,999);
|
||||
PLATFORM.GoToLocation(zone.Location());
|
||||
end_script
|
||||
|
||||
//
|
||||
//@ flyCircleZone
|
||||
//
|
||||
script void flyCircleZone(string zPoint)
|
||||
WsfGeoPoint p = p.Construct(zPoint);
|
||||
PLATFORM.GoToSpeed(1000,999);
|
||||
PLATFORM.GoToLocation(p);
|
||||
end_script
|
||||
|
||||
//
|
||||
//@ fly the zone
|
||||
//
|
||||
script void flyZone(string zNameOrPoint,string zType)
|
||||
if(zType == "polygon")
|
||||
{
|
||||
flyPolygonalZone(zNameOrPoint);
|
||||
}
|
||||
else if(zType == "circle")
|
||||
{
|
||||
flyCircleZone(zNameOrPoint);
|
||||
}
|
||||
end_script
|
||||
|
||||
execute at_time 50 sec relative
|
||||
flyZone(zNameOrPoint,zType);
|
||||
end_execute
|
||||
end_processor
|
||||
80
processors/pathPatrol.txt
Normal file
80
processors/pathPatrol.txt
Normal file
@@ -0,0 +1,80 @@
|
||||
# File generated by Wizard 2.9.0 on Dec 16, 2024.
|
||||
|
||||
processor pathPatrol WSF_TASK_PROCESSOR
|
||||
script_variables
|
||||
double launchRange = 20.0 * MATH.M_PER_NM();
|
||||
double salvoSize = 2;
|
||||
string weaponName = "aa_mrm";
|
||||
WsfWeapon aa_mrm = PLATFORM.Weapon(weaponName);
|
||||
bool canPursue = false;
|
||||
end_script_variables
|
||||
|
||||
script bool pursueCondition()
|
||||
return (
|
||||
aa_mrm.QuantityRemaining() > 0 &&
|
||||
TRACK.Target().IsValid()
|
||||
);
|
||||
end_script
|
||||
|
||||
|
||||
script bool Pursue()
|
||||
if(pursueCondition())
|
||||
{
|
||||
PLATFORM.GoToLocation(TRACK.CurrentLocation());
|
||||
return canPursue;
|
||||
}
|
||||
return canPursue;
|
||||
end_script
|
||||
|
||||
script bool runAround()
|
||||
if(PLATFORM.Side() == "red")
|
||||
{
|
||||
PLATFORM.FollowRoute(PLATFORM.Name());
|
||||
}
|
||||
return (TRACK.Target().IsValid());
|
||||
end_script
|
||||
|
||||
on_initialize2
|
||||
PLATFORM.FollowRoute(PLATFORM.Name());
|
||||
end_on_initialize2
|
||||
//////////////////////////////////////////STATE MACHINE///////////////////////////////////////
|
||||
evaluation_interval DETECTED 1 sec
|
||||
state DETECTED
|
||||
next_state RUNAROUND
|
||||
return (!pursueCondition()
|
||||
|| PLATFORM.MasterTrackList().Count() <= 0
|
||||
);
|
||||
end_next_state
|
||||
|
||||
next_state PURSUE
|
||||
return (pursueCondition());
|
||||
end_next_state
|
||||
end_state
|
||||
|
||||
evaluation_interval PURSUE 1 sec
|
||||
state PURSUE
|
||||
next_state WAIT
|
||||
return Pursue();
|
||||
end_next_state
|
||||
end_state
|
||||
|
||||
evaluation_interval WAIT 1 sec
|
||||
state WAIT
|
||||
next_state DETECTED
|
||||
return pursueCondition();
|
||||
end_next_state
|
||||
|
||||
next_state RUNAROUND
|
||||
return (!pursueCondition()
|
||||
|| PLATFORM.MasterTrackList().Count() <= 0
|
||||
);
|
||||
end_next_state
|
||||
end_state
|
||||
|
||||
evaluation_interval RUNAROUND 1 sec
|
||||
state RUNAROUND
|
||||
next_state DETECTED
|
||||
return runAround();
|
||||
end_next_state
|
||||
end_state
|
||||
end_processor
|
||||
62
processors/randomCirclePatrol.txt
Normal file
62
processors/randomCirclePatrol.txt
Normal file
@@ -0,0 +1,62 @@
|
||||
# File generated by Wizard 2.9.0 on Dec 22, 2024.
|
||||
processor randomCirclePoint WSF_SCRIPT_PROCESSOR
|
||||
|
||||
script_variables
|
||||
string centerPoint = "";
|
||||
double Radius = 50000;
|
||||
bool isOver = false;
|
||||
end_script_variables
|
||||
|
||||
script Array<WsfGeoPoint> generateCirclePoints(string Center , double radius)
|
||||
WsfGeoPoint center= WsfGeoPoint.Construct(Center);
|
||||
Array<WsfGeoPoint>circlePoints={};
|
||||
double earthRadius =6371000.0;
|
||||
double angularDistance =radius /earthRadius;
|
||||
Array<double>angles ={0.0,120,240};
|
||||
foreach(double angle in angles)
|
||||
{
|
||||
double latCenter=center.Latitude()* MATH.PI()/ 180.0;
|
||||
double loncenter= center.Longitude()* MATH.PI()/ 180.0;
|
||||
double lat= MATH.ASin(MATH.Sin(latCenter)
|
||||
* MATH.Cos(angularDistance)
|
||||
+ MATH.Cos(latCenter)
|
||||
* MATH.Sin(angularDistance)
|
||||
* MATH.Cos(angle));
|
||||
|
||||
double lon = loncenter +MATH.ATan2(MATH.Sin(angle)
|
||||
* MATH.Sin(angularDistance)
|
||||
* MATH.Cos(latCenter)
|
||||
, MATH.Cos(angularDistance)
|
||||
- MATH.Sin(latCenter)
|
||||
* MATH.Sin(lat));
|
||||
circlePoints.PushBack(WsfGeoPoint.Construct(lat*180.0/MATH.PI() , lon *180.0 / MATH.PI(),5000));
|
||||
}
|
||||
return circlePoints;
|
||||
end_script
|
||||
|
||||
script void executecircularPatrol()
|
||||
Array<WsfGeoPoint> circlePoints = generateCirclePoints(centerPoint,Radius);
|
||||
WsfRoute route;
|
||||
WsfRoute r1= route.Create("lx");
|
||||
foreach(WsfGeoPoint vertex in circlePoints)
|
||||
{
|
||||
vertex.SetAltitudeHAE(10000);
|
||||
r1.Append(vertex,1500);
|
||||
}
|
||||
|
||||
r1.Waypoint(0).SetLabel("start");
|
||||
r1 .Waypoint(r1.Size()-1).SetGoToLabel("start");
|
||||
PLATFORM.FollowRoute(r1);
|
||||
# r1.Print();
|
||||
isOver =true;
|
||||
end_script
|
||||
|
||||
|
||||
update_interval 1 sec
|
||||
on_update
|
||||
if(isOver != true)
|
||||
{
|
||||
executecircularPatrol();
|
||||
}
|
||||
end_on_update
|
||||
end_processor
|
||||
61
processors/scripts/randomPatrol.txt
Normal file
61
processors/scripts/randomPatrol.txt
Normal file
@@ -0,0 +1,61 @@
|
||||
# File generated by Wizard 2.9.0 on Dec 16, 2024.
|
||||
zone tw
|
||||
polygonal lat_lon
|
||||
maximum_altitude 20 km
|
||||
|
||||
point 25:39:39.36n 120:30:25.18e
|
||||
point 25:06:17.31n 122:29:29.13e
|
||||
point 21:32:49.50n 121:05:56.86e
|
||||
point 22:19:43.20n 119:36:49.51e
|
||||
|
||||
fill_color red
|
||||
line_color red
|
||||
end_zone
|
||||
|
||||
processor randomPatrol WSF_SCRIPT_PROCESSOR
|
||||
|
||||
script Array<WsfGeoPoint> GenerateRandomPoints(int numPoints)
|
||||
WsfZone zone = zone.FindZone("tw");
|
||||
WsfGeoPoint pMax = zone.MaxPoint();
|
||||
WsfGeoPoint pMin = zone.MinPoint();
|
||||
Array<WsfGeoPoint> randomPoints = {};
|
||||
|
||||
double minLatitude = pMin.Latitude();
|
||||
double maxLatitude = pMax.Latitude();
|
||||
|
||||
double minLongitude = pMin.Longitude();
|
||||
double maxLongitude = pMax.Longitude();
|
||||
|
||||
while(randomPoints.Size() < numPoints)
|
||||
{
|
||||
double randomLatitude = RANDOM.Uniform(minLatitude,maxLatitude);
|
||||
double randomLongitude = RANDOM.Uniform(minLongitude,maxLongitude);
|
||||
WsfGeoPoint candidatePoint = candidatePoint.Construct(randomLatitude,randomLongitude,5000);
|
||||
if( zone.PointIsInside(candidatePoint))
|
||||
{
|
||||
randomPoints.PushBack(candidatePoint);
|
||||
}
|
||||
}
|
||||
return randomPoints;
|
||||
end_script
|
||||
execute at_time 20 sec relative
|
||||
Array<WsfGeoPoint> randomPoints = GenerateRandomPoints(10);
|
||||
WsfRoute route;
|
||||
WsfRoute r1 = route.Create("lx");
|
||||
# WsfWaypoint wwp1;
|
||||
# wwp1.SetLabel("start");
|
||||
# r1.Insert(0,wwp1);
|
||||
foreach(WsfGeoPoint vertex in randomPoints)
|
||||
{
|
||||
r1.Append(vertex,190);
|
||||
}
|
||||
# WsfWaypoint wwp2;
|
||||
# wwp2.SetLabel("start");
|
||||
# r1.Insert(r1.Size()-1,wwp2);
|
||||
# r1.Print();
|
||||
PLATFORM.FollowRoute(r1);
|
||||
end_execute
|
||||
|
||||
|
||||
|
||||
end_processor
|
||||
Reference in New Issue
Block a user