start on new threat types & strategy abstraction
parent
07ad59a5f1
commit
9a7c51c907
|
@ -287,10 +287,10 @@ GameObject:
|
|||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 8462434346230391091}
|
||||
- component: {fileID: 4571646124809534626}
|
||||
- component: {fileID: 4451965530778273955}
|
||||
- component: {fileID: 4194966225731047199}
|
||||
m_Layer: 0
|
||||
m_Name: MissileThreat
|
||||
m_Name: FixedWingMissileThreat
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
|
@ -314,24 +314,6 @@ Transform:
|
|||
- {fileID: 9192475791974545516}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &4571646124809534626
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6438458936967544359}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f532f6ee629e87643b7b75a50e83083f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_flightPhase: 0
|
||||
_velocity: {x: 0, y: 0, z: 0}
|
||||
_acceleration: {x: 0, y: 0, z: 0}
|
||||
_dragAcceleration: {x: 0, y: 0, z: 0}
|
||||
_target: {fileID: 0}
|
||||
staticConfigFile: drone.json
|
||||
--- !u!54 &4451965530778273955
|
||||
Rigidbody:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -359,3 +341,21 @@ Rigidbody:
|
|||
m_Interpolate: 0
|
||||
m_Constraints: 0
|
||||
m_CollisionDetection: 0
|
||||
--- !u!114 &4194966225731047199
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6438458936967544359}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e6c2fbd1e492be448760f5045b13b2e, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_flightPhase: 3
|
||||
_velocity: {x: 0, y: 0, z: 0}
|
||||
_acceleration: {x: 0, y: 0, z: 0}
|
||||
_dragAcceleration: {x: 0, y: 0, z: 0}
|
||||
_target: {fileID: 0}
|
||||
staticConfigFile: generic_static_config.json
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9c1ccc1cc7ad8cb4aa0b59a0afd50568
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,361 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &295999596028346972
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 9192475791974545516}
|
||||
- component: {fileID: 3681380462727606042}
|
||||
- component: {fileID: 5038767565634652910}
|
||||
m_Layer: 0
|
||||
m_Name: Cone
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &9192475791974545516
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 295999596028346972}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
|
||||
m_LocalPosition: {x: 0, y: 0, z: -3.89}
|
||||
m_LocalScale: {x: 20, y: 20, z: 20}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 8462434346230391091}
|
||||
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
|
||||
--- !u!33 &3681380462727606042
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 295999596028346972}
|
||||
m_Mesh: {fileID: 4300000, guid: 36b72d5a34c22d94c88a068dfcbdf27a, type: 2}
|
||||
--- !u!23 &5038767565634652910
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 295999596028346972}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RayTraceProcedural: 0
|
||||
m_RayTracingAccelStructBuildFlagsOverride: 0
|
||||
m_RayTracingAccelStructBuildFlags: 1
|
||||
m_SmallMeshCulling: 1
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 061083197c659dc44983633a84d39cea, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!1 &4390675743535140416
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 585396986125101381}
|
||||
- component: {fileID: 4620404264009677289}
|
||||
m_Layer: 0
|
||||
m_Name: TrailRenderer
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &585396986125101381
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4390675743535140416}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 10, y: 10, z: 10}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 8462434346230391091}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!96 &4620404264009677289
|
||||
TrailRenderer:
|
||||
serializedVersion: 3
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4390675743535140416}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 0
|
||||
m_ReceiveShadows: 0
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 0
|
||||
m_LightProbeUsage: 0
|
||||
m_ReflectionProbeUsage: 0
|
||||
m_RayTracingMode: 0
|
||||
m_RayTraceProcedural: 0
|
||||
m_RayTracingAccelStructBuildFlagsOverride: 0
|
||||
m_RayTracingAccelStructBuildFlags: 1
|
||||
m_SmallMeshCulling: 1
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 0e42500808910f24cb6626a81760c995, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_Time: 5
|
||||
m_PreviewTimeScale: 1
|
||||
m_Parameters:
|
||||
serializedVersion: 3
|
||||
widthMultiplier: 5
|
||||
widthCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
colorGradient:
|
||||
serializedVersion: 2
|
||||
key0: {r: 1, g: 0, b: 0, a: 1}
|
||||
key1: {r: 1, g: 1, b: 1, a: 1}
|
||||
key2: {r: 0, g: 0, b: 0, a: 0}
|
||||
key3: {r: 0, g: 0, b: 0, a: 0}
|
||||
key4: {r: 0, g: 0, b: 0, a: 0}
|
||||
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 65535
|
||||
ctime2: 0
|
||||
ctime3: 0
|
||||
ctime4: 0
|
||||
ctime5: 0
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_ColorSpace: 0
|
||||
m_NumColorKeys: 2
|
||||
m_NumAlphaKeys: 2
|
||||
numCornerVertices: 0
|
||||
numCapVertices: 0
|
||||
alignment: 0
|
||||
textureMode: 0
|
||||
textureScale: {x: 1, y: 1}
|
||||
shadowBias: 0.5
|
||||
generateLightingData: 0
|
||||
m_MinVertexDistance: 0.1
|
||||
m_MaskInteraction: 0
|
||||
m_Autodestruct: 0
|
||||
m_Emitting: 1
|
||||
m_ApplyActiveColorSpace: 0
|
||||
--- !u!1 &4590233640347492898
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 8315564871113561163}
|
||||
- component: {fileID: 6203868598056538240}
|
||||
m_Layer: 0
|
||||
m_Name: Collider
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &8315564871113561163
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4590233640347492898}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 8462434346230391091}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!135 &6203868598056538240
|
||||
SphereCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4590233640347492898}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 1
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Radius: 10
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &6438458936967544359
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 8462434346230391091}
|
||||
- component: {fileID: -2759790757235477429}
|
||||
- component: {fileID: 4451965530778273955}
|
||||
m_Layer: 0
|
||||
m_Name: RollStabilizedMissileThreat
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &8462434346230391091
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6438458936967544359}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 585396986125101381}
|
||||
- {fileID: 8315564871113561163}
|
||||
- {fileID: 9192475791974545516}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &-2759790757235477429
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6438458936967544359}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 16e40584b2154ef4a95c84e85a321999, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_flightPhase: 3
|
||||
_velocity: {x: 0, y: 0, z: 0}
|
||||
_acceleration: {x: 0, y: 0, z: 0}
|
||||
_dragAcceleration: {x: 0, y: 0, z: 0}
|
||||
_target: {fileID: 0}
|
||||
staticConfigFile: base_roll_stabilized_missile.json
|
||||
--- !u!54 &4451965530778273955
|
||||
Rigidbody:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6438458936967544359}
|
||||
serializedVersion: 4
|
||||
m_Mass: 1
|
||||
m_Drag: 0
|
||||
m_AngularDrag: 0
|
||||
m_CenterOfMass: {x: 0, y: 0, z: 0}
|
||||
m_InertiaTensor: {x: 1, y: 1, z: 1}
|
||||
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ImplicitCom: 1
|
||||
m_ImplicitTensor: 1
|
||||
m_UseGravity: 0
|
||||
m_IsKinematic: 0
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 0
|
||||
m_CollisionDetection: 0
|
|
@ -128,6 +128,10 @@ public abstract class Agent : MonoBehaviour {
|
|||
return GetComponent<Rigidbody>().linearVelocity;
|
||||
}
|
||||
|
||||
public Vector3 GetAcceleration() {
|
||||
return _acceleration;
|
||||
}
|
||||
|
||||
public double GetDynamicPressure() {
|
||||
var airDensity = Constants.CalculateAirDensityAtAltitude(transform.position.y);
|
||||
var flowSpeed = GetSpeed();
|
||||
|
|
|
@ -4,12 +4,14 @@ using UnityEngine;
|
|||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
|
||||
[Serializable]
|
||||
public class SimulationConfig {
|
||||
[Header("Simulation Settings")]
|
||||
public float timeScale = 0.05f;
|
||||
|
||||
// [Header("Defense Points")]
|
||||
// public SwarmConfig defense_points_config;
|
||||
|
||||
[Header("Interceptor Swarm Configurations")]
|
||||
public List<SwarmConfig> interceptor_swarm_configs = new List<SwarmConfig>();
|
||||
|
||||
|
@ -112,7 +114,11 @@ public class TargetConfig {
|
|||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum InterceptorType { HYDRA_70, MICROMISSILE }
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum ThreatType { DRONE, MISSILE }
|
||||
public enum ThreatType {
|
||||
DRONE,
|
||||
FIXED_WING_MISSILE,
|
||||
ROLL_STABILIZED_MISSILE
|
||||
} // Add ballistic later -michael
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum ConfigColor { BLUE, GREEN, RED }
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Static targetable point to defend
|
||||
/// </summary>
|
||||
public class DefendPoint : Agent {
|
||||
// Currently just initializes to the origin
|
||||
public DefendPoint() {
|
||||
// Set the initial state
|
||||
this.transform.position = Vector3.zero;
|
||||
}
|
||||
|
||||
protected override void FixedUpdate() {
|
||||
return;
|
||||
}
|
||||
|
||||
protected override void UpdateBoost(double deltaTime) {
|
||||
return;
|
||||
}
|
||||
|
||||
protected override void UpdateMidCourse(double deltaTime) {
|
||||
return;
|
||||
}
|
||||
|
||||
protected override void UpdateReady(double deltaTime) {
|
||||
return;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7eed014a152a65043be19cd044faa5d2
|
|
@ -75,7 +75,6 @@ public class SimManager : MonoBehaviour {
|
|||
StartSimulation();
|
||||
ResumeSimulation();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void SetTimeScale(float timeScale) {
|
||||
|
@ -197,7 +196,8 @@ public class SimManager : MonoBehaviour {
|
|||
/// <param name="config">Configuration settings for the interceptor.</param>
|
||||
/// <returns>The created Interceptor instance, or null if creation failed.</returns>
|
||||
public Interceptor CreateInterceptor(AgentConfig config) {
|
||||
string prefabName = config.interceptor_type switch { InterceptorType.HYDRA_70 => "Hydra70",
|
||||
string prefabName =
|
||||
config.interceptor_type switch { InterceptorType.HYDRA_70 => "Hydra70",
|
||||
InterceptorType.MICROMISSILE => "Micromissile",
|
||||
_ => "Hydra70" };
|
||||
|
||||
|
@ -231,7 +231,8 @@ public class SimManager : MonoBehaviour {
|
|||
/// <returns>The created Threat instance, or null if creation failed.</returns>
|
||||
private Threat CreateThreat(AgentConfig config) {
|
||||
string prefabName = config.threat_type switch {
|
||||
ThreatType.DRONE => "Drone", ThreatType.MISSILE => "MissileThreat",
|
||||
ThreatType.DRONE => "Drone", ThreatType.FIXED_WING_MISSILE => "FixedWingMissileThreat",
|
||||
ThreatType.ROLL_STABILIZED_MISSILE => "RollStabilizedMissileThreat",
|
||||
_ => throw new System.ArgumentException($"Unsupported threat type: {config.threat_type}")
|
||||
};
|
||||
GameObject threatObject = CreateAgent(config, prefabName);
|
||||
|
|
|
@ -2,7 +2,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DroneTarget : Threat {
|
||||
public class DroneThreat : Threat {
|
||||
// Start is called before the first frame update
|
||||
protected override void Start() {
|
||||
base.Start();
|
|
@ -0,0 +1,41 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class FixedWingMissileThreat : Threat {
|
||||
protected override void UpdateBoost(double deltaTime) {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
protected override void UpdateMidCourse(double deltaTime) {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Strategy for moving the Threat in a straight path towards its target.
|
||||
/// </summary>
|
||||
public class DirectPathStrategy : NavigationStrategy {
|
||||
public override void Execute(Threat threat, List<Threat> swarmMates, FlightPhase flightPhase,
|
||||
List<Interceptor> interceptors, double deltaTime) {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Strategy for moving the Threat in an S-curve towards a predefined target.
|
||||
/// </summary>
|
||||
public class SlalomStrategy : NavigationStrategy {
|
||||
private float maxAmplitude;
|
||||
private float periodDistance;
|
||||
|
||||
public SlalomStrategy(float maxAmplitude, float periodDistance) {
|
||||
this.maxAmplitude = maxAmplitude;
|
||||
this.periodDistance = periodDistance;
|
||||
}
|
||||
|
||||
public override void Execute(Threat threat, List<Threat> swarmMates, FlightPhase flightPhase,
|
||||
List<Interceptor> interceptors, double deltaTime) {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4e6c2fbd1e492be448760f5045b13b2e
|
|
@ -1,107 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Base class for missile targets. Uses same set of flight phases as base Hydra-70.
|
||||
/// </summary>
|
||||
public class MissileThreat : Threat
|
||||
{
|
||||
protected float boostAcceleration = 20;
|
||||
protected float midcourseAcceleration = 5;
|
||||
|
||||
protected override void UpdateReady(double deltaTime)
|
||||
{
|
||||
// if in ready phase, just set to boost phase immediately
|
||||
SetFlightPhase(FlightPhase.BOOST);
|
||||
}
|
||||
|
||||
protected override void UpdateBoost(double deltaTime)
|
||||
{
|
||||
// The interceptor only accelerates along its roll axis (forward in Unity)
|
||||
Vector3 rollAxis = transform.forward;
|
||||
|
||||
// Calculate boost acceleration
|
||||
float boostAcceleration =
|
||||
(float)(_staticConfig.boostConfig.boostAcceleration * Constants.kGravity);
|
||||
Vector3 accelerationInput = boostAcceleration * rollAxis;
|
||||
|
||||
// Calculate the total acceleration
|
||||
Vector3 acceleration = CalculateAcceleration(accelerationInput);
|
||||
|
||||
// Apply the acceleration force
|
||||
GetComponent<Rigidbody>().AddForce(acceleration, ForceMode.Acceleration);
|
||||
}
|
||||
|
||||
protected override void UpdateMidCourse(double deltaTime)
|
||||
{
|
||||
Vector3 accelerationInput = Vector3.zero;
|
||||
// Calculate and set the total acceleration
|
||||
Vector3 acceleration = CalculateAcceleration(accelerationInput);
|
||||
GetComponent<Rigidbody>().AddForce(acceleration, ForceMode.Acceleration);
|
||||
}
|
||||
|
||||
protected Vector3 CalculateAcceleration(Vector3 accelerationInput,
|
||||
bool compensateForGravity = false)
|
||||
{
|
||||
Vector3 gravity = Physics.gravity;
|
||||
if (compensateForGravity)
|
||||
{
|
||||
Vector3 gravityProjection = CalculateGravityProjectionOnPitchAndYaw();
|
||||
accelerationInput -= gravityProjection;
|
||||
}
|
||||
|
||||
float airDrag = CalculateDrag();
|
||||
float liftInducedDrag = CalculateLiftInducedDrag(accelerationInput);
|
||||
float dragAcceleration = -(airDrag + liftInducedDrag);
|
||||
|
||||
// Project the drag acceleration onto the forward direction
|
||||
Vector3 dragAccelerationAlongRoll = dragAcceleration * transform.forward;
|
||||
_dragAcceleration = dragAccelerationAlongRoll;
|
||||
|
||||
return accelerationInput + gravity + dragAccelerationAlongRoll;
|
||||
}
|
||||
|
||||
protected float CalculateMaxAcceleration()
|
||||
{
|
||||
float maxReferenceAcceleration =
|
||||
(float)(_staticConfig.accelerationConfig.maxReferenceAcceleration * Constants.kGravity);
|
||||
float referenceSpeed = _staticConfig.accelerationConfig.referenceSpeed;
|
||||
return Mathf.Pow(GetComponent<Rigidbody>().linearVelocity.magnitude / referenceSpeed, 2) *
|
||||
maxReferenceAcceleration;
|
||||
}
|
||||
|
||||
protected Vector3 CalculateGravityProjectionOnPitchAndYaw()
|
||||
{
|
||||
Vector3 gravity = Physics.gravity;
|
||||
Vector3 pitchAxis = transform.right;
|
||||
Vector3 yawAxis = transform.up;
|
||||
|
||||
// Project the gravity onto the pitch and yaw axes
|
||||
float gravityProjectionPitchCoefficient = Vector3.Dot(gravity, pitchAxis);
|
||||
float gravityProjectionYawCoefficient = Vector3.Dot(gravity, yawAxis);
|
||||
|
||||
// Return the sum of the projections
|
||||
return gravityProjectionPitchCoefficient * pitchAxis +
|
||||
gravityProjectionYawCoefficient * yawAxis;
|
||||
}
|
||||
|
||||
private float CalculateDrag()
|
||||
{
|
||||
float dragCoefficient = _staticConfig.liftDragConfig.dragCoefficient;
|
||||
float crossSectionalArea = _staticConfig.bodyConfig.crossSectionalArea;
|
||||
float mass = _staticConfig.bodyConfig.mass;
|
||||
float dynamicPressure = (float)GetDynamicPressure();
|
||||
float dragForce = dragCoefficient * dynamicPressure * crossSectionalArea;
|
||||
return dragForce / mass;
|
||||
}
|
||||
|
||||
private float CalculateLiftInducedDrag(Vector3 accelerationInput)
|
||||
{
|
||||
float liftAcceleration =
|
||||
(accelerationInput - Vector3.Dot(accelerationInput, transform.up) * transform.up).magnitude;
|
||||
float liftDragRatio = _staticConfig.liftDragConfig.liftDragRatio;
|
||||
return Mathf.Abs(liftAcceleration / liftDragRatio);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,204 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Base class for missile targets. Uses same set of flight phases as base Hydra-70.
|
||||
/// </summary>
|
||||
public class RollStabilizedMissileThreat : Threat {
|
||||
protected float boostAcceleration = 20;
|
||||
protected float midcourseAcceleration = 0;
|
||||
protected float terminalAcceleration = 22;
|
||||
protected float maxAmplitude = 22;
|
||||
|
||||
public RollStabilizedMissileThreat() {
|
||||
strategy = new DirectPathStrategy();
|
||||
}
|
||||
|
||||
protected override void UpdateBoost(double deltaTime) {
|
||||
// The interceptor only accelerates along its roll axis (forward in Unity)
|
||||
Vector3 rollAxis = transform.forward;
|
||||
|
||||
// Calculate boost acceleration
|
||||
float boostAcceleration =
|
||||
(float)(_staticConfig.boostConfig.boostAcceleration * Constants.kGravity);
|
||||
Vector3 accelerationInput = boostAcceleration * rollAxis;
|
||||
|
||||
// Calculate the total acceleration
|
||||
Vector3 acceleration = CalculateAcceleration(accelerationInput);
|
||||
|
||||
// Apply the acceleration force
|
||||
GetComponent<Rigidbody>().AddForce(acceleration, ForceMode.Acceleration);
|
||||
}
|
||||
|
||||
protected override void UpdateMidCourse(double deltaTime) {
|
||||
Vector3 accelerationInput = Vector3.zero;
|
||||
// Calculate and set the total acceleration
|
||||
Vector3 acceleration = CalculateAcceleration(accelerationInput);
|
||||
GetComponent<Rigidbody>().AddForce(acceleration, ForceMode.Acceleration);
|
||||
}
|
||||
|
||||
protected Vector3 CalculateAcceleration(Vector3 accelerationInput,
|
||||
bool compensateForGravity = false) {
|
||||
Vector3 gravity = Physics.gravity;
|
||||
if (compensateForGravity) {
|
||||
Vector3 gravityProjection = CalculateGravityProjectionOnPitchAndYaw();
|
||||
accelerationInput -= gravityProjection;
|
||||
}
|
||||
|
||||
float airDrag = CalculateDrag();
|
||||
float liftInducedDrag = CalculateLiftInducedDrag(accelerationInput);
|
||||
float dragAcceleration = -(airDrag + liftInducedDrag);
|
||||
|
||||
// Project the drag acceleration onto the forward direction
|
||||
Vector3 dragAccelerationAlongRoll = dragAcceleration * transform.forward;
|
||||
_dragAcceleration = dragAccelerationAlongRoll;
|
||||
|
||||
return accelerationInput + gravity + dragAccelerationAlongRoll;
|
||||
}
|
||||
|
||||
protected float CalculateMaxAcceleration() {
|
||||
float maxReferenceAcceleration =
|
||||
(float)(_staticConfig.accelerationConfig.maxReferenceAcceleration * Constants.kGravity);
|
||||
float referenceSpeed = _staticConfig.accelerationConfig.referenceSpeed;
|
||||
return Mathf.Pow(GetComponent<Rigidbody>().linearVelocity.magnitude / referenceSpeed, 2) *
|
||||
maxReferenceAcceleration;
|
||||
}
|
||||
|
||||
protected Vector3 CalculateGravityProjectionOnPitchAndYaw() {
|
||||
Vector3 gravity = Physics.gravity;
|
||||
Vector3 pitchAxis = transform.right;
|
||||
Vector3 yawAxis = transform.up;
|
||||
|
||||
// Project the gravity onto the pitch and yaw axes
|
||||
float gravityProjectionPitchCoefficient = Vector3.Dot(gravity, pitchAxis);
|
||||
float gravityProjectionYawCoefficient = Vector3.Dot(gravity, yawAxis);
|
||||
|
||||
// Return the sum of the projections
|
||||
return gravityProjectionPitchCoefficient * pitchAxis +
|
||||
gravityProjectionYawCoefficient * yawAxis;
|
||||
}
|
||||
|
||||
private float CalculateDrag() {
|
||||
float dragCoefficient = _staticConfig.liftDragConfig.dragCoefficient;
|
||||
float crossSectionalArea = _staticConfig.bodyConfig.crossSectionalArea;
|
||||
float mass = _staticConfig.bodyConfig.mass;
|
||||
float dynamicPressure = (float)GetDynamicPressure();
|
||||
float dragForce = dragCoefficient * dynamicPressure * crossSectionalArea;
|
||||
return dragForce / mass;
|
||||
}
|
||||
|
||||
private float CalculateLiftInducedDrag(Vector3 accelerationInput) {
|
||||
float liftAcceleration =
|
||||
(accelerationInput - Vector3.Dot(accelerationInput, transform.up) * transform.up).magnitude;
|
||||
float liftDragRatio = _staticConfig.liftDragConfig.liftDragRatio;
|
||||
return Mathf.Abs(liftAcceleration / liftDragRatio);
|
||||
}
|
||||
|
||||
// ===========================================================
|
||||
// STRATEGIES
|
||||
// ===========================================================
|
||||
|
||||
/// <summary>
|
||||
/// Strategy for moving the Threat in a straight path towards its target.
|
||||
/// </summary>
|
||||
public class DirectPathStrategy : NavigationStrategy {
|
||||
DefendPoint target = new DefendPoint();
|
||||
|
||||
private float _navigationGain = 3f; // Typically 3-5
|
||||
private SensorOutput _sensorOutput;
|
||||
private Vector3 _accelerationCommand;
|
||||
private double _elapsedTime = 0;
|
||||
|
||||
public override void Execute(Threat threat, List<Threat> swarmMates, FlightPhase flightPhase,
|
||||
List<Interceptor> interceptors, double deltaTime) {
|
||||
RollStabilizedMissileThreat missileThreat = threat as RollStabilizedMissileThreat;
|
||||
if (missileThreat == null) {
|
||||
Debug.LogError("DirectPathStrategy can only be used with RollStabilizedMissileThreat");
|
||||
return;
|
||||
}
|
||||
|
||||
_elapsedTime += deltaTime;
|
||||
Vector3 accelerationInput = Vector3.zero;
|
||||
|
||||
if (target != null) {
|
||||
// Correct the state of the threat model at the sensor frequency
|
||||
float sensorUpdatePeriod =
|
||||
1f / missileThreat._agentConfig.dynamic_config.sensor_config.frequency;
|
||||
if (_elapsedTime >= sensorUpdatePeriod) {
|
||||
_sensorOutput = new SensorOutput();
|
||||
missileThreat.GetComponent<Sensor>().Sense(target);
|
||||
Debug.Log(_sensorOutput.velocity.range);
|
||||
_elapsedTime = 0;
|
||||
}
|
||||
|
||||
// Check whether the threat should be considered a miss
|
||||
SensorOutput sensorOutput = missileThreat.GetComponent<Sensor>().Sense(target);
|
||||
if (sensorOutput.velocity.range > 1000f) {
|
||||
missileThreat.MarkAsMiss();
|
||||
}
|
||||
|
||||
// Calculate the acceleration input
|
||||
accelerationInput = CalculateAccelerationCommand(missileThreat, _sensorOutput);
|
||||
} else {
|
||||
Debug.LogError("DirectPathStrategy requires a target to be set");
|
||||
}
|
||||
|
||||
// Calculate and set the total acceleration
|
||||
Vector3 acceleration =
|
||||
missileThreat.CalculateAcceleration(accelerationInput, compensateForGravity: true);
|
||||
missileThreat.GetComponent<Rigidbody>().AddForce(acceleration, ForceMode.Acceleration);
|
||||
}
|
||||
|
||||
private Vector3 CalculateAccelerationCommand(Threat threat, SensorOutput sensorOutput) {
|
||||
RollStabilizedMissileThreat missileThreat = threat as RollStabilizedMissileThreat;
|
||||
|
||||
// Implement Proportional Navigation guidance law
|
||||
Vector3 accelerationCommand;
|
||||
|
||||
// Extract relevant information from sensor output
|
||||
float los_rate_az = sensorOutput.velocity.azimuth;
|
||||
float los_rate_el = sensorOutput.velocity.elevation;
|
||||
float closing_velocity =
|
||||
-sensorOutput.velocity
|
||||
.range; // Negative because closing velocity is opposite to range rate
|
||||
|
||||
// Navigation gain (adjust as needed)
|
||||
float N = _navigationGain;
|
||||
|
||||
// Calculate acceleration commands in azimuth and elevation planes
|
||||
float acc_az = N * closing_velocity * los_rate_az;
|
||||
float acc_el = N * closing_velocity * los_rate_el;
|
||||
|
||||
// Convert acceleration commands to craft body frame
|
||||
accelerationCommand =
|
||||
missileThreat.transform.right * acc_az + missileThreat.transform.up * acc_el;
|
||||
|
||||
// Clamp the acceleration command to the maximum acceleration
|
||||
float maxAcceleration = missileThreat.CalculateMaxAcceleration();
|
||||
accelerationCommand = Vector3.ClampMagnitude(accelerationCommand, maxAcceleration);
|
||||
|
||||
// Update the stored acceleration command for debugging
|
||||
_accelerationCommand = accelerationCommand;
|
||||
return accelerationCommand;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Strategy for moving the Threat in a spiral towards a predefined target.
|
||||
/// </summary>
|
||||
public class SpiralStrategy : NavigationStrategy {
|
||||
private float spiralRadius;
|
||||
private float periodDistance;
|
||||
|
||||
public SpiralStrategy(float spiralRadius, float periodDistance) {
|
||||
this.spiralRadius = spiralRadius;
|
||||
this.periodDistance = periodDistance;
|
||||
}
|
||||
|
||||
public override void Execute(Threat threat, List<Threat> swarmMates, FlightPhase flightPhase,
|
||||
List<Interceptor> interceptors, double deltaTime) {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0d798867791c1444b985d8807b144572
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -3,6 +3,29 @@ using System.Collections.Generic;
|
|||
using UnityEngine;
|
||||
|
||||
public abstract class Threat : Agent {
|
||||
/// <summary>
|
||||
/// Strategy for moving the Threat towards a predefined target.
|
||||
/// </summary>
|
||||
public abstract class NavigationStrategy {
|
||||
/// <summary>
|
||||
/// Execute one timestep of the strategy for the given threat and flight phase. Should only
|
||||
/// apply normal forces to the threat. Can also change the threat's flight phase. Should NOT
|
||||
/// manage thrust.
|
||||
/// </summary>
|
||||
/// <param name="threat">Parent Threat object</param>
|
||||
/// <param name="swarmMates">List of other threats in the swarm</param>
|
||||
/// <param name="flightPhase">Current flight phase</param>
|
||||
/// <param name="interceptors">List of active interceptors</param>
|
||||
/// <param name="deltaTime">Timestep</param>
|
||||
public abstract void Execute(Threat threat, List<Threat> swarmMates, FlightPhase flightPhase,
|
||||
List<Interceptor> interceptors, double deltaTime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Navigation strategy that this threat will use to move towards its target.
|
||||
/// </summary>
|
||||
public NavigationStrategy strategy;
|
||||
|
||||
public override bool IsAssignable() {
|
||||
return false;
|
||||
}
|
||||
|
@ -13,5 +36,18 @@ public abstract class Threat : Agent {
|
|||
|
||||
protected override void FixedUpdate() {
|
||||
base.FixedUpdate();
|
||||
// NOTE: no swarm-mates for now
|
||||
strategy.Execute(this, new List<Threat>(), GetFlightPhase(),
|
||||
SimManager.Instance.GetActiveInterceptors(), Time.fixedDeltaTime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// OVERRIDE: THIS SHOULD NEVER BE CALLED; threats always start in midcourse or (at the very
|
||||
/// earliest) boost phase.
|
||||
/// </summary>
|
||||
/// <param name="deltaTime"></param>
|
||||
/// <exception cref="System.NotImplementedException"></exception>
|
||||
protected override void UpdateReady(double deltaTime) {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
"num_agents": 1,
|
||||
"agent_config": {
|
||||
"interceptor_type": "HYDRA_70",
|
||||
"threat_type": "DRONE",
|
||||
"threat_type": "ROLL_STABILIZED_MISSILE",
|
||||
"initial_state": {
|
||||
"position": {
|
||||
"x": 0,
|
||||
|
@ -98,8 +98,7 @@
|
|||
{
|
||||
"num_agents": 7,
|
||||
"agent_config": {
|
||||
"interceptor_type": "HYDRA_70",
|
||||
"threat_type": "MISSILE",
|
||||
"threat_type": "ROLL_STABILIZED_MISSILE",
|
||||
"initial_state": {
|
||||
"position": {
|
||||
"x": 0,
|
||||
|
@ -108,7 +107,7 @@
|
|||
},
|
||||
"rotation": {
|
||||
"x": 90,
|
||||
"y": 0,
|
||||
"y": 50,
|
||||
"z": 0
|
||||
},
|
||||
"velocity": {
|
||||
|
@ -137,9 +136,6 @@
|
|||
"type": "IDEAL",
|
||||
"frequency": 0
|
||||
}
|
||||
},
|
||||
"static_config": {
|
||||
|
||||
},
|
||||
"submunitions_config": {
|
||||
"num_submunitions": 0
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 22c1e00f13b5ec6468892b8c6df37933
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"accelerationConfig": {
|
||||
"maxReferenceAcceleration": 300,
|
||||
"referenceSpeed": 1000
|
||||
},
|
||||
"boostConfig": {
|
||||
"boostTime": 0.3,
|
||||
"boostAcceleration": 350
|
||||
},
|
||||
"liftDragConfig": {
|
||||
"liftCoefficient": 0.2,
|
||||
"dragCoefficient": 0.7,
|
||||
"liftDragRatio": 5
|
||||
},
|
||||
"bodyConfig": {
|
||||
"mass": 0.37,
|
||||
"crossSectionalArea": 0.0003,
|
||||
"finArea": 0.0006,
|
||||
"bodyArea": 0.01
|
||||
},
|
||||
"hitConfig": {
|
||||
"hitRadius": 1,
|
||||
"killProbability": 0.9
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 72573475cbd372d4dbb25291cc6545b0
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue