diff --git a/CHANGELOG.md b/CHANGELOG.md index ac559e7..7de2045 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,8 @@ - 完善了集成测试的菜单逻辑,可以反复运行了 - 给导弹增加了巡航攻角、制导下视角参数,完善了三个阶段的朝向逻辑 - 增加了激光/红外复合制导导弹 +- 给装备增加了可选参数 +- 完善了末敏弹子弹的朝向和传感器运动状态 ## [1.1.20] - 2025-05-19 - 增加了SwerlingRCS回波模型 diff --git a/ThreatSource/data/equipments/apcs/apc_001.toml b/ThreatSource/data/equipments/apcs/apc_001.toml index 344ca40..c52642e 100644 --- a/ThreatSource/data/equipments/apcs/apc_001.toml +++ b/ThreatSource/data/equipments/apcs/apc_001.toml @@ -19,6 +19,11 @@ MillimeterWaveRadiationIntensity = 8.0 # 毫米波辐射强度 (瓦特/球 MillimeterWaveRadiationTemperature = 350.0 # 毫米波辐射温度 (开尔文) LaserReflectivity = 0.25 # 激光反射率 +# === 装甲车特定参数 === +[Properties.APCProperties] +BodyGroundClearance = 0.45 # 车底距地高 (米) +CrewCapacity = 10 # 乘员数量 + [Properties.ThermalPattern] # 热辐射特征模型 StaticPatternSource = [ # 静态时温度分布 [35, 40, 65], diff --git a/ThreatSource/data/equipments/helicopters/heli_001.toml b/ThreatSource/data/equipments/helicopters/heli_001.toml index dc76da7..90c6d99 100644 --- a/ThreatSource/data/equipments/helicopters/heli_001.toml +++ b/ThreatSource/data/equipments/helicopters/heli_001.toml @@ -19,6 +19,43 @@ MillimeterWaveRadiationIntensity = 6.0 # 毫米波辐射强度 (瓦特/球 MillimeterWaveRadiationTemperature = 450.0 # 毫米波辐射温度 (开尔文) LaserReflectivity = 0.2 # 激光反射率 +# === 直升机特定参数(新增) === +[Properties.HelicopterProperties] +FlightAltitude = 6400.0 # 飞行高度 (米) +ServiceCeiling = 6000.0 # 服务升限 (米) +HoverCeiling = 4000.0 # 悬停升限 (米) + +# === 自定义参数示例 === +[Properties.CustomParameters] + +[Properties.CustomParameters.RotorBladeCount] +Value = 4 +Unit = "片" +Category = "旋翼系统" +Description = "主旋翼叶片数量" +DataType = "System.Int32" + +[Properties.CustomParameters.TailRotorDiameter] +Value = 2.4 +Unit = "m" +Category = "旋翼系统" +Description = "尾桨直径" +DataType = "System.Double" + +[Properties.CustomParameters.WeaponSystemType] +Value = "反坦克导弹+航炮" +Unit = "" +Category = "武器系统" +Description = "武器系统配置" +DataType = "System.String" + +[Properties.CustomParameters.MissileCapacity] +Value = 16 +Unit = "枚" +Category = "武器系统" +Description = "导弹携带数量" +DataType = "System.Int32" + [Properties.ThermalPattern] # 热辐射特征模型 StaticPatternSource = [ # 静态时温度分布 [85, 110, 80], diff --git a/ThreatSource/data/equipments/tanks/mbt_001.toml b/ThreatSource/data/equipments/tanks/mbt_001.toml index 035da80..f4004e5 100644 --- a/ThreatSource/data/equipments/tanks/mbt_001.toml +++ b/ThreatSource/data/equipments/tanks/mbt_001.toml @@ -19,6 +19,12 @@ MillimeterWaveRadiationIntensity = 10.0 # 毫米波辐射强度 (瓦特/球 MillimeterWaveRadiationTemperature = 150.0 # 毫米波辐射温度 (开尔文) LaserReflectivity = 0.3 # 激光反射率 +# === 坦克特定参数 === +[Properties.TankProperties] +BodyGroundClearance = 0.45 # 车底距地高 (米) +TurretHeight = 1.2 # 炮转台高度 (米) +BarrelLength = 5.8 # 炮管长度 (米) + [Properties.ThermalPattern] # 热辐射特征模型 StaticPatternSource = [ # 静态时温度分布 [40, 45, 80], diff --git a/ThreatSource/data/equipments/tanks/mbt_002_enhanced.toml b/ThreatSource/data/equipments/tanks/mbt_002_enhanced.toml new file mode 100644 index 0000000..502f01e --- /dev/null +++ b/ThreatSource/data/equipments/tanks/mbt_002_enhanced.toml @@ -0,0 +1,204 @@ +# 主战坦克-002 增强配置(展示新参数结构) +Type = "Tank" # 目标类型 + +[Name] +Zh = "99A主战坦克" +En = "ZTZ-99A Main Battle Tank" + +[Properties] +Type = "Tank" # 属性中的类型 +Mass = 55000.0 # 质量 (千克) +Length = 11.0 # 总长度 (米) - 包含炮管 +Width = 3.5 # 宽度 (米) +Height = 2.37 # 高度 (米) +MaxSpeed = 70.0 # 最大速度 (千米/小时) +ArmorThickness = 800.0 # 装甲厚度 (毫米) +InfraredRadiationIntensity = 2500.0 # 红外辐射强度 (瓦特/球面度) +UltravioletRadiationIntensity = 15.0 # 紫外辐射强度 (瓦特/球面度) +MillimeterWaveRadiationIntensity = 10.0 # 毫米波辐射强度 (瓦特/球面度) +MillimeterWaveRadiationTemperature = 400.0 # 毫米波辐射温度 (开尔文) +LaserReflectivity = 0.3 # 激光反射率 + +# === 坦克特定参数 === +[Properties.TankProperties] +BodyGroundClearance = 0.5 # 车底距地高 (米) +TurretHeight = 1.35 # 炮转台高度 (米) +BarrelLength = 6.25 # 炮管长度 (米) + +# === 自定义参数 === +[Properties.CustomParameters] + +# 武器系统参数 +[Properties.CustomParameters.MainGunCaliber] +Value = 125.0 +Unit = "mm" +Category = "武器系统" +Description = "主炮口径" +DataType = "System.Double" + +[Properties.CustomParameters.MainGunAmmunitionCapacity] +Value = 39 +Unit = "发" +Category = "武器系统" +Description = "主炮弹药基数" +DataType = "System.Int32" + +[Properties.CustomParameters.MachineGunType] +Value = "12.7mm高射机枪" +Unit = "" +Category = "武器系统" +Description = "副武器类型" +DataType = "System.String" + +# 防护系统参数 +[Properties.CustomParameters.ReactiveArmorType] +Value = "FY-4" +Unit = "" +Category = "防护系统" +Description = "反应装甲型号" +DataType = "System.String" + +[Properties.CustomParameters.FrontArmorThickness] +Value = 950.0 +Unit = "mm" +Category = "防护系统" +Description = "正面装甲厚度" +DataType = "System.Double" + +[Properties.CustomParameters.SideArmorThickness] +Value = 600.0 +Unit = "mm" +Category = "防护系统" +Description = "侧面装甲厚度" +DataType = "System.Double" + +[Properties.CustomParameters.RearArmorThickness] +Value = 400.0 +Unit = "mm" +Category = "防护系统" +Description = "后面装甲厚度" +DataType = "System.Double" + +# 动力系统参数 +[Properties.CustomParameters.EngineType] +Value = "1500马力柴油机" +Unit = "" +Category = "动力系统" +Description = "发动机类型" +DataType = "System.String" + +[Properties.CustomParameters.EnginePower] +Value = 1500.0 +Unit = "hp" +Category = "动力系统" +Description = "发动机功率" +DataType = "System.Double" + +[Properties.CustomParameters.FuelCapacity] +Value = 1200.0 +Unit = "L" +Category = "动力系统" +Description = "燃油容量" +DataType = "System.Double" + +[Properties.CustomParameters.OperationalRange] +Value = 450.0 +Unit = "km" +Category = "动力系统" +Description = "作战半径" +DataType = "System.Double" + +# 火控系统参数 +[Properties.CustomParameters.FireControlSystemType] +Value = "综合火控系统" +Unit = "" +Category = "火控系统" +Description = "火控系统类型" +DataType = "System.String" + +[Properties.CustomParameters.LaserRangefinderRange] +Value = 8000.0 +Unit = "m" +Category = "火控系统" +Description = "激光测距仪射程" +DataType = "System.Double" + +[Properties.CustomParameters.ThermalImagingRange] +Value = 5000.0 +Unit = "m" +Category = "火控系统" +Description = "热像仪探测距离" +DataType = "System.Double" + +# 机动性能参数 +[Properties.CustomParameters.ClimbingAngle] +Value = 32.0 +Unit = "°" +Category = "机动性能" +Description = "爬坡角度" +DataType = "System.Double" + +[Properties.CustomParameters.WadingDepth] +Value = 1.4 +Unit = "m" +Category = "机动性能" +Description = "涉水深度" +DataType = "System.Double" + +[Properties.CustomParameters.TrenchCrossingWidth] +Value = 2.7 +Unit = "m" +Category = "机动性能" +Description = "越壕宽度" +DataType = "System.Double" + +[Properties.CustomParameters.VerticalObstacleHeight] +Value = 0.85 +Unit = "m" +Category = "机动性能" +Description = "垂直越障高度" +DataType = "System.Double" + +# 通信电子系统参数 +[Properties.CustomParameters.CommunicationSystem] +Value = "数字化指挥系统" +Unit = "" +Category = "通信电子" +Description = "通信系统类型" +DataType = "System.String" + +[Properties.CustomParameters.BattlefieldManagementSystem] +Value = "BMS-T" +Unit = "" +Category = "通信电子" +Description = "战场管理系统" +DataType = "System.String" + +[Properties.CustomParameters.CrewCapacity] +Value = 3 +Unit = "人" +Category = "基本信息" +Description = "乘员数量" +DataType = "System.Int32" + +[Properties.ThermalPattern] # 热辐射特征模型 +StaticPatternSource = [ # 静态时温度分布 + [40, 45, 80], + [35, 40, 90], + [50, 50, 60] +] +MovingPatternSource = [ # 移动时温度分布 + [45, 50, 85], + [40, 45, 95], + [65, 65, 75] +] + +[Properties.RcsPattern] +RcsMatrixDataSource = [ + [10.0, 10.0, 10.0, 10.0], # 前 (Front) [Q1, Q2, Q3, Q4] + [10.0, 10.0, 10.0, 10.0], # 后 (Back) + [13.0, 13.0, 13.0, 13.0], # 左 (Left) + [13.0, 13.0, 13.0, 13.0], # 右 (Right) + [13.0, 13.0, 13.0, 13.0], # 上 (Top) + [13.0, 13.0, 13.0, 13.0] # 下 (Bottom) +] \ No newline at end of file diff --git a/ThreatSource/data/missiles/terminal_sensitive/tsm_001.toml b/ThreatSource/data/missiles/terminal_sensitive/tsm_001.toml index 8cfb1e6..68c3b29 100644 --- a/ThreatSource/data/missiles/terminal_sensitive/tsm_001.toml +++ b/ThreatSource/data/missiles/terminal_sensitive/tsm_001.toml @@ -21,6 +21,7 @@ ExplosionRadius = 5.0 # 爆炸半径 (米) SelfDestructHeight = 0.0 # 自毁高度 (米) [SubmunitionProperties] # 子弹药属性 +Type = "TerminalSensitiveSubmunition" # 属性中的类型 MaxSpeed = 2000.0 # 最大速度 (米/秒) MaxFlightTime = 60.0 # 最大飞行时间 (秒) MaxFlightDistance = 2000.0 # 最大飞行距离 (米) @@ -42,10 +43,10 @@ SeparationRange = 10.0 # 分离散布范围 (米) DecelerationAcceleration = 150.0 # 减速加速度 (米/秒^2) DecelerationEndSpeed = 200.0 # 减速结束速度 (米/秒) ParachuteDeploymentHeight = 400.0 # 开伞高度 (米) -ParachuteDeceleration = 95.0 # 降落伞减速度 (米/秒^2) +ParachuteDeceleration = 110.0 # 降落伞减速度 (米/秒^2) StableScanHeight = 200.0 # 稳定扫描高度 (米) VerticalDeclineSpeed = 10.0 # 垂直下降速度 (米/秒) -SpiralRotationSpeed = 25.13 # 螺旋旋转速度 (弧度/秒) +SpiralRotationSpeed = 1440.0 # 螺旋旋转速度 (度/秒) ScanAngle = 30.0 # 扫描角度 (度) TargetDetectionDistance = 150.0 # 目标探测距离 (米) SelfDestructHeight = 20.0 # (子弹药)自毁高度 (米) @@ -55,14 +56,14 @@ TotalProcessingTime = 15.0 # 整体处理时间 (秒),用于目 [SubmunitionConfig.InfraredDetectorConfig] # 子弹药红外探测器配置 MaxDetectionRange = 1000.0 # 最大探测距离 (米) Band = "Medium" # 工作波段 (例如: "Short", "Medium", "Long") -FieldOfView = 1.0 # 视场角 (弧度) +FieldOfView = 2.0 # 视场角 (度) DetectionRadiationIntensityThreshold = 50.0 # 探测辐射强度阈值 (瓦特/球面度) JammingResistanceThreshold = 1.0e-4 # 干扰抗性阈值 (瓦特) [SubmunitionConfig.RadiometerConfig] # 子弹药辐射计配置 MaxDetectionRange = 1000.0 # 最大探测距离 (米) Band = "Band8" # 工作波段 (例如: "Band3", "Band8", "Band35", "Band94") -ScanFieldOfView = 1.0 # 扫描视场角 (弧度) +ScanFieldOfView = 2.0 # 扫描视场角 (度) JammingResistanceThreshold = 1.0e-4 # 干扰抗性阈值 (瓦特) [SubmunitionConfig.AltimeterConfig] # 子弹药高度计配置 diff --git a/ThreatSource/src/Equipment/EquipmentProperties.cs b/ThreatSource/src/Equipment/EquipmentProperties.cs index 0e4cf9a..dc2c03c 100644 --- a/ThreatSource/src/Equipment/EquipmentProperties.cs +++ b/ThreatSource/src/Equipment/EquipmentProperties.cs @@ -1,7 +1,6 @@ - namespace ThreatSource.Equipment { - /// + /// /// 目标类型枚举 /// /// @@ -34,6 +33,181 @@ namespace ThreatSource.Equipment Helicopter } + /// + /// 参数值类,用于存储动态参数的值、单位和类型信息 + /// + public class ParameterValue + { + /// + /// 参数值 + /// + public object Value { get; set; } = 0.0; + + /// + /// 参数单位 + /// + public string Unit { get; set; } = ""; + + /// + /// 参数分类 + /// + public string Category { get; set; } = ""; + + /// + /// 参数数据类型(字符串形式) + /// + public string DataType { get; set; } = "System.Double"; + + /// + /// 获取实际的数据类型 + /// + public Type ActualDataType => ParseDataType(DataType); + + /// + /// 参数描述 + /// + public string Description { get; set; } = ""; + + /// + /// 初始化参数值类的新实例 + /// + public ParameterValue() { } + + /// + /// 初始化参数值类的新实例 + /// + /// 参数值 + /// 参数单位 + /// 参数分类 + /// 参数描述 + public ParameterValue(object value, string unit = "", string category = "", string description = "") + { + Value = value; + Unit = unit; + Category = category; + Description = description; + DataType = value?.GetType().FullName ?? "System.Double"; + } + + /// + /// 安全地解析数据类型字符串为Type对象 + /// + /// 数据类型字符串 + /// 解析后的Type对象,解析失败时返回typeof(double) + private static Type ParseDataType(string dataTypeString) + { + if (string.IsNullOrEmpty(dataTypeString)) + return typeof(double); + + try + { + // 处理常见的简化类型名称 + return dataTypeString switch + { + "System.Double" or "double" => typeof(double), + "System.Int32" or "int" => typeof(int), + "System.String" or "string" => typeof(string), + "System.Boolean" or "bool" => typeof(bool), + "System.Single" or "float" => typeof(float), + "System.Int64" or "long" => typeof(long), + "System.Decimal" or "decimal" => typeof(decimal), + _ => Type.GetType(dataTypeString) ?? typeof(double) + }; + } + catch + { + return typeof(double); + } + } + } + + /// + /// 坦克特定参数类 + /// + public class TankSpecificProperties + { + /// + /// 车底距地高度 + /// + /// + /// 单位:米 + /// + public double BodyGroundClearance { get; set; } = 0.5; + + /// + /// 炮转台高度 + /// + /// + /// 单位:米 + /// + public double TurretHeight { get; set; } = 1.35; + + /// + /// 炮管长度 + /// + /// + /// 单位:米 + /// + public double BarrelLength { get; set; } = 6.25; + } + + /// + /// 装甲车特定参数类 + /// + public class APCSpecificProperties + { + /// + /// 车底距地高度 + /// + /// + /// 单位:米 + /// + public double BodyGroundClearance { get; set; } = 0.5; + + /// + /// 载员数量 + /// + public int CrewCapacity { get; set; } = 8; + } + + /// + /// 直升机特定参数类 + /// + public class HelicopterSpecificProperties + { + /// + /// 旋翼直径 + /// + /// + /// 单位:米 + /// + public double RotorDiameter { get; set; } = 6.0; + + /// + /// 飞行高度 + /// + /// + /// 单位:米 + /// + public double FlightAltitude { get; set; } = 6400.0; + + /// + /// 服务升限 + /// + /// + /// 单位:米 + /// + public double ServiceCeiling { get; set; } = 6000.0; + + /// + /// 悬停升限 + /// + /// + /// 单位:米 + /// + public double HoverCeiling { get; set; } = 4000.0; + } + /// /// 装备属性类,定义了目标装备的所有基本属性和性能参数 /// @@ -42,6 +216,7 @@ namespace ThreatSource.Equipment /// - 配置目标的物理特性 /// - 设置目标的频谱特征 /// - 定义目标的热辐射特性 + /// - 支持类型特化参数和自定义参数 /// 所有目标实例都基于此配置进行初始化 /// public class EquipmentProperties @@ -161,6 +336,43 @@ namespace ThreatSource.Equipment /// public RcsPattern RcsPattern { get; set; } + // === 类型特化参数 === + + /// + /// 坦克特定参数 + /// + /// + /// 仅当Type为Tank时有效 + /// + public TankSpecificProperties? TankProperties { get; set; } + + /// + /// 装甲车特定参数 + /// + /// + /// 仅当Type为APC时有效 + /// + public APCSpecificProperties? APCProperties { get; set; } + + /// + /// 直升机特定参数 + /// + /// + /// 仅当Type为Helicopter时有效 + /// + public HelicopterSpecificProperties? HelicopterProperties { get; set; } + + // === 自定义参数 === + + /// + /// 自定义参数字典 + /// + /// + /// 用于存储完全自定义的参数,支持任意类型的参数扩展 + /// 键为参数名称,值为ParameterValue对象 + /// + public Dictionary CustomParameters { get; set; } = new(); + /// /// 初始化装备属性类的新实例 /// @@ -168,6 +380,7 @@ namespace ThreatSource.Equipment /// 构造过程: /// - 设置所有属性的默认值 /// - 初始化温度分布模式 + /// - 根据类型初始化特定参数 /// public EquipmentProperties() { @@ -177,7 +390,8 @@ namespace ThreatSource.Equipment new double[ThermalPattern.GRID_SIZE, ThermalPattern.GRID_SIZE], new double[ThermalPattern.GRID_SIZE, ThermalPattern.GRID_SIZE] ); - RcsPattern = new RcsPattern(); + RcsPattern = new RcsPattern(); + InitializeTypeSpecificProperties(); } /// @@ -205,5 +419,70 @@ namespace ThreatSource.Equipment MillimeterWaveRadiationTemperature = 400.0; LaserReflectivity = 0.3; } + + /// + /// 根据装备类型初始化特定参数 + /// + private void InitializeTypeSpecificProperties() + { + switch (Type) + { + case EquipmentType.Tank: + TankProperties = new TankSpecificProperties(); + break; + case EquipmentType.APC: + APCProperties = new APCSpecificProperties(); + break; + case EquipmentType.Helicopter: + HelicopterProperties = new HelicopterSpecificProperties(); + break; + } + } + + /// + /// 添加自定义参数 + /// + /// 参数名称 + /// 参数值 + /// 单位 + /// 分类 + /// 描述 + public void AddCustomParameter(string name, object value, string unit = "", string category = "", string description = "") + { + CustomParameters[name] = new ParameterValue(value, unit, category, description); + } + + /// + /// 获取自定义参数值 + /// + /// 期望的返回类型 + /// 参数名称 + /// 默认值 + /// 参数值 + public T GetCustomParameter(string name, T defaultValue = default!) + { + if (CustomParameters.TryGetValue(name, out var parameter)) + { + try + { + return (T)Convert.ChangeType(parameter.Value, typeof(T)); + } + catch + { + return defaultValue; + } + } + return defaultValue; + } + + /// + /// 检查是否存在自定义参数 + /// + /// 参数名称 + /// 是否存在 + public bool HasCustomParameter(string name) + { + return CustomParameters.ContainsKey(name); + } } } \ No newline at end of file diff --git a/ThreatSource/src/Guidance/BaseGuidanceSystem.cs b/ThreatSource/src/Guidance/BaseGuidanceSystem.cs index 4318d9e..2943dec 100644 --- a/ThreatSource/src/Guidance/BaseGuidanceSystem.cs +++ b/ThreatSource/src/Guidance/BaseGuidanceSystem.cs @@ -100,10 +100,7 @@ namespace ThreatSource.Guidance /// protected Vector3D GuidanceAcceleration { get; set; } - /// - /// 标记制导阶段朝向是否已初始化 - /// - private bool hasInitializedGuidanceOrientation = false; + /// /// 初始化基础制导系统的新实例 @@ -156,19 +153,13 @@ namespace ThreatSource.Guidance /// public override void Activate() { - // 重置制导阶段朝向初始化标志 - hasInitializedGuidanceOrientation = false; - if (!IsActive) { IsActive = true; // 统一订阅 JammingEvent SimulationManager.SubscribeToEvent(HandleJammingEvent); SimulationManager.SubscribeToEvent(HandleJammingStoppedEvent); - // 子类应在此方法中调用 base.Activate() 并订阅其他需要的事件 } - // 调用 SimulationElement 的基类 Activate (如果存在) - // base.Activate(); // SimulationElement 似乎没有公开的 Activate } /// @@ -182,7 +173,6 @@ namespace ThreatSource.Guidance // 统一取消订阅 JammingEvent和JammingStoppedEvent SimulationManager.UnsubscribeFromEvent(HandleJammingEvent); SimulationManager.UnsubscribeFromEvent(HandleJammingStoppedEvent); - // 子类应在此方法中调用 base.Deactivate() 并取消订阅其他事件 } HasGuidance = false; // 停用时失去制导 GuidanceAcceleration = Vector3D.Zero; diff --git a/ThreatSource/src/MIssile/BaseMissile.cs b/ThreatSource/src/MIssile/BaseMissile.cs index 89baf43..748e56e 100644 --- a/ThreatSource/src/MIssile/BaseMissile.cs +++ b/ThreatSource/src/MIssile/BaseMissile.cs @@ -278,8 +278,10 @@ namespace ThreatSource.Missile } } - // 公共运动学与生命周期管理 + // 运动学状态更新 UpdateMotionState(deltaTime); + + // 检查是否应该自毁 if (ShouldSelfDestruct()) { SelfDestruct(); @@ -728,7 +730,7 @@ namespace ThreatSource.Missile } else { - statusInfo.ExtendedProperties["GuidanceSystem"] = "无制导系统"; + statusInfo.ExtendedProperties["GuidanceSystem"] = "无"; } return statusInfo; diff --git a/ThreatSource/src/MIssile/TerminalSensitiveSubmunition.cs b/ThreatSource/src/MIssile/TerminalSensitiveSubmunition.cs index 6bc809e..53a35be 100644 --- a/ThreatSource/src/MIssile/TerminalSensitiveSubmunition.cs +++ b/ThreatSource/src/MIssile/TerminalSensitiveSubmunition.cs @@ -88,6 +88,16 @@ namespace ThreatSource.Missile /// private double spiralAngle = 0; + /// + /// 螺旋扫描旋转速度,单位:弧度/秒 + /// + private readonly double SpiralRotationSpeedInRadians = 0; + + /// + /// 扫描角度,单位:弧度 + /// + private readonly double ScanAngleInRadians = 0; + /// /// 扫描方向向量 /// @@ -202,6 +212,9 @@ namespace ThreatSource.Missile radiometer = new MillimeterWaveRadiometer(Id+"_MW", this, submunitionConfig.RadiometerConfig, manager); altimeter = new MillimeterWaveAltimeter(Id+"_MW_ALT", this, submunitionConfig.AltimeterConfig, manager); rangefinder = new LaserRangefinder(Id+"_LASER", this, submunitionConfig.RangefinderConfig, manager); + + SpiralRotationSpeedInRadians = config.SpiralRotationSpeed * Math.PI / 180.0; + ScanAngleInRadians = config.ScanAngle * Math.PI / 180.0; } /// @@ -370,7 +383,7 @@ namespace ThreatSource.Missile } // 更新螺旋角度(顺时针旋转,标准方位角) - spiralAngle += config.SpiralRotationSpeed * deltaTime; // 顺时针角度增加 + spiralAngle += SpiralRotationSpeedInRadians * deltaTime; // 顺时针角度增加 while (spiralAngle >= 2 * Math.PI) { spiralAngle -= 2 * Math.PI; @@ -378,11 +391,14 @@ namespace ThreatSource.Missile // 更新扫描方向(标准方位角,顺时针为正) scanDirection = new Vector3D( - Math.Sin(spiralAngle) * Math.Sin(config.ScanAngleInRadians), - -Math.Cos(config.ScanAngleInRadians), - Math.Cos(spiralAngle) * Math.Sin(config.ScanAngleInRadians) + Math.Sin(spiralAngle) * Math.Sin(ScanAngleInRadians), + -Math.Cos(ScanAngleInRadians), + Math.Cos(spiralAngle) * Math.Sin(ScanAngleInRadians) ).Normalize(); + // 更新末敏弹的朝向,指向扫描方向 + KState.Orientation = Orientation.FromVector(scanDirection); + // 如果距离小于等于目标探测距离,则进入目标探测阶段 RangefinderSensorData rangefinderData = (RangefinderSensorData)rangefinder.GetSensorData(); if (rangefinderData.IsValid && rangefinderData.Distance <= config.TargetDetectionDistance) @@ -417,7 +433,7 @@ namespace ThreatSource.Missile } // 更新扫描角度(顺时针旋转) - spiralAngle += config.SpiralRotationSpeed * deltaTime; // 顺时针角度增加 + spiralAngle += SpiralRotationSpeedInRadians * deltaTime; // 顺时针角度增加 while (spiralAngle >= 2 * Math.PI) { spiralAngle -= 2 * Math.PI; @@ -425,11 +441,14 @@ namespace ThreatSource.Missile // 更新扫描方向 scanDirection = new Vector3D( - Math.Sin(spiralAngle) * Math.Sin(config.ScanAngleInRadians), - -Math.Cos(config.ScanAngleInRadians), - Math.Cos(spiralAngle) * Math.Sin(config.ScanAngleInRadians) + Math.Sin(spiralAngle) * Math.Sin(ScanAngleInRadians), + -Math.Cos(ScanAngleInRadians), + Math.Cos(spiralAngle) * Math.Sin(ScanAngleInRadians) ).Normalize(); + // 更新末敏弹的朝向,指向扫描方向 + KState.Orientation = Orientation.FromVector(scanDirection); + // 获取传感器数据 RadiometerSensorData radiometerData = (RadiometerSensorData)radiometer.GetSensorData(); InfraredSensorData infraredData = (InfraredSensorData)infraredDetector.GetSensorData(); @@ -469,7 +488,7 @@ namespace ThreatSource.Missile } double timeSinceLastDetection = FlightTime - lastDetectionTime.Value; - if (timeSinceLastDetection >= 0.75 * 2 * Math.PI / config.SpiralRotationSpeed) // 转过3/4圈以后 + if (timeSinceLastDetection >= 0.75 * 2 * Math.PI / SpiralRotationSpeedInRadians) // 转过3/4圈以后 { // 确保firstDetectionAngle不为null if (!firstDetectionAngle.HasValue) @@ -480,7 +499,7 @@ namespace ThreatSource.Missile // 检查当前角度是否接近记录的目标方位角 double angleDiff = Math.Abs(spiralAngle - firstDetectionAngle.Value); // 根据仿真步长和转速计算允许的角度误差 - double allowedError = deltaTime * config.SpiralRotationSpeed / 2; + double allowedError = deltaTime * SpiralRotationSpeedInRadians / 2; if (angleDiff <= allowedError) { if (isRadiometerDetected || isInfraredDetected) @@ -573,14 +592,26 @@ namespace ThreatSource.Missile { targetAzimuth += 2 * Math.PI; // 转换到 [0, 2π] } + Debug.WriteLine($"目标方位角: {targetAzimuth * 180 / Math.PI:F2}°"); + Debug.WriteLine($"螺旋角度: {spiralAngle * 180 / Math.PI:F2}°"); + Debug.WriteLine($"扫描方向: {scanDirection}"); + Debug.WriteLine($"视场角: {fieldOfView}°"); + double targetDotProduct = Vector3D.DotProduct(scanDirection, toTarget); + double angleInRadians = Math.Acos(Math.Clamp(targetDotProduct, -1.0, 1.0)); + Debug.WriteLine($"扫描方向与目标方向的夹角: {angleInRadians * 180 / Math.PI:F2}°"); // 视场检测 double cosFieldOfView = Math.Cos(fieldOfView * Math.PI / 180); - foreach(var vertex in vertices) + for(int i = 0; i < vertices.Length; i++) { - Vector3D toVertex = (vertex - KState.Position).Normalize(); - if(Vector3D.DotProduct(scanDirection, toVertex) > cosFieldOfView) + Vector3D toVertex = (vertices[i] - KState.Position).Normalize(); + double dotProduct = Vector3D.DotProduct(scanDirection, toVertex); + double vertexAngle = Math.Acos(Math.Clamp(dotProduct, -1.0, 1.0)) * 180 / Math.PI; + Debug.WriteLine($"顶点{i+1}夹角: {vertexAngle:F2}°"); + + if(dotProduct > cosFieldOfView) { + Debug.WriteLine($"顶点{i+1}在视场角内,检测成功!"); // 如果目标的任何一个顶点在视场角内,返回目标方位角和目标引用 return new DetectionResult { Angle = targetAzimuth, @@ -623,55 +654,16 @@ namespace ThreatSource.Missile } /// - /// 获取子弹状态信息 + /// 获取末敏弹子弹是否处于制导状态 /// - /// 包含子弹状态的详细描述 /// - /// 返回信息包括: - /// - 基本状态信息 - /// - 当前飞行阶段 - /// - 扫描和检测状态 - /// - 传感器工作状态 + /// 对于末敏弹子弹,制导状态基于攻击阶段而非传统制导系统 + /// 攻击阶段表示子弹已锁定目标并进行精确攻击 + /// 与传统导弹不同,末敏弹子弹使用传感器制导而非制导系统 /// - - public override ElementStatusInfo GetStatusInfo() - { - var statusInfo = base.GetStatusInfo(); - // 获取目标对象并计算距离 - SimulationElement target = SimulationManager.GetEntityById(TargetId) as SimulationElement ?? throw new Exception("目标不存在"); - double distanceToTarget = (target.KState.Position - KState.Position).Magnitude(); - - statusInfo.ExtendedProperties["CurrentStage"] = currentSubmunitionStage.ToString(); - statusInfo.ExtendedProperties["SpiralAngle"] = spiralAngle * 180 / Math.PI; - statusInfo.ExtendedProperties["LastDetectionTime"] = lastDetectionTime?.ToString() ?? "null"; - statusInfo.ExtendedProperties["FirstDetectionAngle"] = firstDetectionAngle?.ToString() ?? "null"; - statusInfo.ExtendedProperties["IsTargetDetected"] = isTargetDetected.ToString(); - statusInfo.ExtendedProperties["TargetPosition"] = target.KState.Position.ToString(); - statusInfo.ExtendedProperties["DistanceToTarget"] = distanceToTarget.ToString(); - statusInfo.ExtendedProperties["IsSensorsJammed"] = IsSensorsJammed().ToString(); - - return statusInfo; - } - - /// - /// 获取子弹状态 - /// - /// 子弹状态 - /// - /// 返回信息包括: - /// - 基本状态信息 - /// - 激光测距仪状态 - /// - 红外探测器状态 - /// - 毫米波辐射计状态 - /// - 测高仪状态 - /// - public override string GetStatus() - { - return base.GetStatus() - + $"\n激光测距仪: {rangefinder.GetStatus()}" - + $"\n红外探测器: {infraredDetector.GetStatus()}" - + $"\n毫米波辐射计: {radiometer.GetStatus()}" - + $"\n测高仪: {altimeter.GetStatus()}"; + public override bool IsGuidance + { + get => currentSubmunitionStage == SubmunitionStage.Attack; } /// @@ -712,16 +704,55 @@ namespace ThreatSource.Missile } /// - /// 获取末敏弹子弹是否处于制导状态 + /// 获取子弹状态信息 /// + /// 包含子弹状态的详细描述 /// - /// 对于末敏弹子弹,制导状态基于攻击阶段而非传统制导系统 - /// 攻击阶段表示子弹已锁定目标并进行精确攻击 - /// 与传统导弹不同,末敏弹子弹使用传感器制导而非制导系统 + /// 返回信息包括: + /// - 基本状态信息 + /// - 当前飞行阶段 + /// - 扫描和检测状态 + /// - 传感器工作状态 /// - public override bool IsGuidance - { - get => currentSubmunitionStage == SubmunitionStage.Attack; + + public override ElementStatusInfo GetStatusInfo() + { + var statusInfo = base.GetStatusInfo(); + // 获取目标对象并计算距离 + SimulationElement target = SimulationManager.GetEntityById(TargetId) as SimulationElement ?? throw new Exception("目标不存在"); + double distanceToTarget = (target.KState.Position - KState.Position).Magnitude(); + + statusInfo.ExtendedProperties["CurrentStage"] = currentSubmunitionStage.ToString(); + statusInfo.ExtendedProperties["SpiralAngle"] = spiralAngle * 180 / Math.PI; + statusInfo.ExtendedProperties["LastDetectionTime"] = lastDetectionTime ?? 0; + statusInfo.ExtendedProperties["FirstDetectionAngle"] = firstDetectionAngle ?? 0; + statusInfo.ExtendedProperties["IsTargetDetected"] = isTargetDetected; + statusInfo.ExtendedProperties["TargetPosition"] = target.KState.Position; + statusInfo.ExtendedProperties["DistanceToTarget"] = distanceToTarget; + statusInfo.ExtendedProperties["IsSensorsJammed"] = IsSensorsJammed(); + + return statusInfo; + } + + /// + /// 获取子弹状态 + /// + /// 子弹状态 + /// + /// 返回信息包括: + /// - 基本状态信息 + /// - 激光测距仪状态 + /// - 红外探测器状态 + /// - 毫米波辐射计状态 + /// - 测高仪状态 + /// + public override string GetStatus() + { + return base.GetStatus() + + $"\n激光测距仪: {rangefinder.GetStatus()}" + + $"\n红外探测器: {infraredDetector.GetStatus()}" + + $"\n毫米波辐射计: {radiometer.GetStatus()}" + + $"\n测高仪: {altimeter.GetStatus()}"; } } } diff --git a/ThreatSource/src/Sensor/InfraredDetector.cs b/ThreatSource/src/Sensor/InfraredDetector.cs index 6a2f1f4..1443554 100644 --- a/ThreatSource/src/Sensor/InfraredDetector.cs +++ b/ThreatSource/src/Sensor/InfraredDetector.cs @@ -99,8 +99,7 @@ namespace ThreatSource.Sensor protected override void UpdateSensor(double deltaTime) { // 从子弹更新位置和朝向 - KState.Position = submunition.KState.Position; - KState.Orientation = Orientation.FromVector(submunition.ScanDirection); + KState = submunition.KState; // 实时计算烟幕衰减 double smokeAttenuation = 1.0; // 默认无衰减 diff --git a/ThreatSource/src/Sensor/LaserRangefinder.cs b/ThreatSource/src/Sensor/LaserRangefinder.cs index 3e7217f..e52be50 100644 --- a/ThreatSource/src/Sensor/LaserRangefinder.cs +++ b/ThreatSource/src/Sensor/LaserRangefinder.cs @@ -105,8 +105,7 @@ namespace ThreatSource.Sensor protected override void UpdateSensor(double deltaTime) { // 从submunition更新位置和朝向 - KState.Position = submunition.KState.Position; - KState.Orientation = Orientation.FromVector(submunition.ScanDirection); + KState = submunition.KState; // 实时计算烟幕衰减 double smokeAttenuation = 1.0; // 默认无衰减 diff --git a/ThreatSource/src/Sensor/MillimeterWaveAltimeter.cs b/ThreatSource/src/Sensor/MillimeterWaveAltimeter.cs index 6463958..b870f0d 100644 --- a/ThreatSource/src/Sensor/MillimeterWaveAltimeter.cs +++ b/ThreatSource/src/Sensor/MillimeterWaveAltimeter.cs @@ -137,8 +137,7 @@ namespace ThreatSource.Sensor protected override void UpdateSensor(double deltaTime) { // 从submunition更新位置和朝向 - KState.Position = submunition.KState.Position; - KState.Orientation = submunition.KState.Orientation; + KState = submunition.KState; // 实时计算烟幕衰减 double smokeAttenuation = 1.0; // 默认无衰减 diff --git a/ThreatSource/src/Sensor/MillimeterWaveRadiometer.cs b/ThreatSource/src/Sensor/MillimeterWaveRadiometer.cs index df74a2f..b39434d 100644 --- a/ThreatSource/src/Sensor/MillimeterWaveRadiometer.cs +++ b/ThreatSource/src/Sensor/MillimeterWaveRadiometer.cs @@ -150,8 +150,7 @@ namespace ThreatSource.Sensor protected override void UpdateSensor(double deltaTime) { // 从submunition更新位置和朝向 - KState.Position = submunition.KState.Position; - KState.Orientation = Orientation.FromVector(submunition.ScanDirection); + KState = submunition.KState; // 实时计算烟幕衰减 double smokeAttenuation = 1.0; // 默认无衰减 diff --git a/ThreatSource/src/Simulation/SimulationConfig.cs b/ThreatSource/src/Simulation/SimulationConfig.cs index d312690..3106573 100644 --- a/ThreatSource/src/Simulation/SimulationConfig.cs +++ b/ThreatSource/src/Simulation/SimulationConfig.cs @@ -896,10 +896,9 @@ namespace ThreatSource.Simulation /// /// /// 定义了螺旋扫描时的旋转角速度 - /// 4转/秒 = 8π弧度/秒 - /// 默认值为25.13弧度/秒 + /// 默认值为1440度/秒(4转/秒) /// - public double SpiralRotationSpeed { get; set; } = 8.0 * Math.PI; + public double SpiralRotationSpeed { get; set; } = 1440.0; /// /// 扫描角度,单位:度 @@ -910,13 +909,6 @@ namespace ThreatSource.Simulation /// public double ScanAngle { get; set; } = 30.0; - /// - /// 扫描角度,单位:弧度 - /// - /// - /// 将度数转换为弧度供内部计算使用 - /// - public double ScanAngleInRadians => ScanAngle * Math.PI / 180.0; #endregion #region 探测和攻击阶段参数 diff --git a/docs/project/tunning.md b/docs/project/tunning.md index 63a8607..e0e8246 100644 --- a/docs/project/tunning.md +++ b/docs/project/tunning.md @@ -543,3 +543,16 @@ - 发射角度:0.05 弧度(此时巡航高度 15 米) +## 末敏弹实验记录(v1.1.22) + +时间:2025-05-28 10:00:00 +版本:v1.1.22 + +### 实验结果 +1. 末敏弹 + - 降落伞减速度:110 m/s² + - 红外探测器视场角:2.0度 + - 毫米波辐射计视场角:2.0度 + +### 实验结论 +1. 2 度的视场角,能够在保证命中率的前提下,扩大搜索范围。 \ No newline at end of file diff --git a/tools/ComprehensiveMissileSimulator.cs b/tools/ComprehensiveMissileSimulator.cs index e96d31e..926e3a7 100644 --- a/tools/ComprehensiveMissileSimulator.cs +++ b/tools/ComprehensiveMissileSimulator.cs @@ -68,8 +68,10 @@ namespace ThreatSource.Tools.MissileSimulation { // 首先初始化过滤器和监听器 logLevelFilter = new EventTypeFilter(SourceLevels.Verbose); // 默认设置为Verbose - consoleListener = new ConsoleTraceListener(); - consoleListener.Filter = logLevelFilter; + consoleListener = new ConsoleTraceListener + { + Filter = logLevelFilter + }; // 清除任何现有的ConsoleTraceListeners并添加我们的控制实例 for (int i = Trace.Listeners.Count - 1; i >= 0; i--) @@ -205,7 +207,7 @@ namespace ThreatSource.Tools.MissileSimulation { Position = new Vector3D(0, 1.2, 0), Orientation = new Orientation(0.0, 0.0, 0.0), - Speed = 2.0 + Speed = 0.0 }; string targetId = "Tank_1"; @@ -1395,40 +1397,29 @@ namespace ThreatSource.Tools.MissileSimulation simulationManager.StopSimulation(); simulationManager.ClearAllEvents(); - // 销毁所有导弹 - foreach (var missile in missiles.Values) + // 获取仿真管理器中所有注册的实体(包括动态生成的末敏弹子弹) + var allEntities = simulationManager.GetAllEntities(); + Console.WriteLine($"发现 {allEntities.Count} 个实体需要清理"); + + // 逐个清理所有实体 + foreach (var entity in allEntities) { - missile.Deactivate(); - simulationManager.UnregisterEntity(missile.Id); - Console.WriteLine($"销毁导弹: {missile.Id}"); + if (entity is SimulationElement simElement) + { + simElement.Deactivate(); + simulationManager.UnregisterEntity(simElement.Id); + Console.WriteLine($"销毁实体: {simElement.Id} ({entity.GetType().Name})"); + } + else + { + Console.WriteLine($"跳过非SimulationElement实体: {entity.GetType().Name}"); + } } + + // 清理本地字典 missiles.Clear(); - - // 销毁所有目标 - foreach (var target in targets.Values) - { - target.Deactivate(); - simulationManager.UnregisterEntity(target.Id); - Console.WriteLine($"销毁目标: {target.Id}"); - } targets.Clear(); - - // 销毁所有指示器 - foreach (var indicator in indicators.Values) - { - indicator.Deactivate(); - simulationManager.UnregisterEntity(indicator.Id); - Console.WriteLine($"销毁指示器: {indicator.Id}"); - } indicators.Clear(); - - // 销毁所有干扰器 - foreach (var jammer in jammers.Values) - { - jammer.Deactivate(); - simulationManager.UnregisterEntity(jammer.Id); - Console.WriteLine($"销毁干扰器: {jammer.Id}"); - } jammers.Clear(); // 清理状态 diff --git a/tools/Program.cs b/tools/Program.cs index 51384b3..1dbdab1 100644 --- a/tools/Program.cs +++ b/tools/Program.cs @@ -360,6 +360,7 @@ namespace ThreatSource.Tools.MissileSimulation Console.WriteLine("1. 低精度 (0.02s)"); Console.WriteLine("2. 中精度 (0.01s)"); Console.WriteLine("3. 高精度 (0.005s)"); + Console.WriteLine("4. 超高精度 (0.001s)"); Console.WriteLine("0. 返回主菜单"); Console.Write("请选择步长: "); string input = Console.ReadLine()?.ToLower() ?? string.Empty; @@ -378,6 +379,10 @@ namespace ThreatSource.Tools.MissileSimulation simulator.TimeStep = 0.005; Console.WriteLine($"仿真步长已设置为: {simulator.TimeStep}s (高精度)"); return; // 设置后返回主菜单 + case "4": + simulator.TimeStep = 0.001; + Console.WriteLine($"仿真步长已设置为: {simulator.TimeStep}s (超高精度)"); + return; // 设置后返回主菜单 case "0": backToMainMenu = true; break;