diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a74f77..1e25afd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,13 @@ - 多种发射弹道模式:低平弹道、高抛弹道、俯冲弹道 - 双模、多模制导 +## [1.1.18] - 2025-05-14 +- 修改了版本号格式(0.2.18 -> 1.1.18) +- 修改了日志输出格式 +- 飞行全程增加重力加速度 +- 完善发射段的推力加速度计算 +- 修改各导弹配置文件的初始发射速度、发动机燃烧时间 +- 修改集成测试中导弹的发射距离、发射高度、发射角度 ## [0.2.17] - 2025-05-11 - Orientation 坐标系的调整(前向方向从X轴改为Z轴) diff --git a/ThreatSource/ThreatSource.csproj b/ThreatSource/ThreatSource.csproj index 5a7211f..76ef3c4 100644 --- a/ThreatSource/ThreatSource.csproj +++ b/ThreatSource/ThreatSource.csproj @@ -4,10 +4,10 @@ net8.0 enable enable - 1.0.0 + 1.1.0 ThreatSource Library A comprehensive library for missile simulation and threat source modeling. - Copyright © 2024 + Copyright © 2025 true diff --git a/ThreatSource/data/missiles/ir_command/irc_001.toml b/ThreatSource/data/missiles/ir_command/irc_001.toml index db02041..fec61cd 100644 --- a/ThreatSource/data/missiles/ir_command/irc_001.toml +++ b/ThreatSource/data/missiles/ir_command/irc_001.toml @@ -11,9 +11,9 @@ MaxSpeed = 300.0 # 最大速度 (米/秒) MaxFlightTime = 60.0 # 最大飞行时间 (秒) MaxFlightDistance = 5000.0 # 最大飞行距离 (米) MaxAcceleration = 100.0 # 最大加速度 (米/秒^2) -ProportionalNavigationCoefficient = 3.0 # 比例导引系数 +ProportionalNavigationCoefficient = 4.0 # 比例导引系数 LaunchAcceleration = 100.0 # 发射加速度 (米/秒^2) -MaxEngineBurnTime = 0.1 # 最大发动机燃烧时间 (秒) +MaxEngineBurnTime = 3.0 # 最大发动机燃烧时间 (秒) CruiseTime = 5.0 # 巡航时间 (秒) Mass = 23.5 # 质量 (千克) ExplosionRadius = 5.0 # 爆炸半径 (米) diff --git a/ThreatSource/data/missiles/ir_imaging/itg_001.toml b/ThreatSource/data/missiles/ir_imaging/itg_001.toml index f1e37b4..2205993 100644 --- a/ThreatSource/data/missiles/ir_imaging/itg_001.toml +++ b/ThreatSource/data/missiles/ir_imaging/itg_001.toml @@ -13,7 +13,7 @@ MaxFlightDistance = 5000.0 MaxAcceleration = 100.0 ProportionalNavigationCoefficient = 3.0 LaunchAcceleration = 100.0 -MaxEngineBurnTime = 0.1 +MaxEngineBurnTime = 2.5 CruiseTime = 5.0 Mass = 25.0 ExplosionRadius = 5.5 diff --git a/ThreatSource/data/missiles/laser_beam_rider/hj10.toml b/ThreatSource/data/missiles/laser_beam_rider/hj10.toml index d7149c9..376e97d 100644 --- a/ThreatSource/data/missiles/laser_beam_rider/hj10.toml +++ b/ThreatSource/data/missiles/laser_beam_rider/hj10.toml @@ -13,7 +13,7 @@ MaxFlightDistance = 5000.0 # 最大飞行距离 (米) MaxAcceleration = 100.0 # 最大加速度 (米/秒^2) ProportionalNavigationCoefficient = 3.0 # 比例导引系数 LaunchAcceleration = 100.0 # 发射加速度 (米/秒^2) -MaxEngineBurnTime = 0.1 # 最大发动机燃烧时间 (秒) +MaxEngineBurnTime = 3.0 # 最大发动机燃烧时间 (秒) CruiseTime = 5.0 # 巡航时间 (秒) Mass = 24.5 # 质量 (千克) ExplosionRadius = 5.0 # 爆炸半径 (米) @@ -33,8 +33,8 @@ DetectorDiameter = 0.03 # 探测器直径 (米) ControlFieldDiameter = 20.0 # 控制视场直径 (米, 通常指在某一距离上的光斑直径) ProportionalGain = 30.0 # 比例增益 IntegralGain = 0.05 # 积分增益 -DerivativeGain = 5.0 # 微分增益 -NonlinearGain = 0.5 # 非线性增益 +DerivativeGain = 10.0 # 微分增益 +NonlinearGain = 0.3 # 非线性增益 MaxGuidanceAcceleration = 50.0 # 最大制导加速度 (米/秒^2) LowPassFilterCoefficient = 0.2 # 低通滤波器系数 Wavelength = 1.06 # 工作波长 (微米) diff --git a/ThreatSource/data/missiles/laser_semi_active/lsgm_001.toml b/ThreatSource/data/missiles/laser_semi_active/lsgm_001.toml index 9457fe0..0520749 100644 --- a/ThreatSource/data/missiles/laser_semi_active/lsgm_001.toml +++ b/ThreatSource/data/missiles/laser_semi_active/lsgm_001.toml @@ -10,7 +10,7 @@ En = "Laser Semi-Active Guidance Missile-001" Type = "LaserSemiActiveGuidance" # properties内部的类型标识符 MaxSpeed = 800.0 # 最大速度 (m/s) MaxFlightTime = 60.0 # 最大飞行时间 (秒) -MaxFlightDistance = 4000.0 # 最大飞行距离 (米) +MaxFlightDistance = 20000.0 # 最大飞行距离 (米) MaxAcceleration = 50.0 # 最大横向加速度 (m/s^2) ProportionalNavigationCoefficient = 2.0 # 比例导引系数 LaunchAcceleration = 100.0 # 初始发射加速度 (m/s^2) diff --git a/ThreatSource/data/missiles/mmw/mmw_001.toml b/ThreatSource/data/missiles/mmw/mmw_001.toml index 45315c4..963958a 100644 --- a/ThreatSource/data/missiles/mmw/mmw_001.toml +++ b/ThreatSource/data/missiles/mmw/mmw_001.toml @@ -13,7 +13,7 @@ MaxFlightDistance = 8000.0 # 最大飞行距离 (米) MaxAcceleration = 100.0 # 最大加速度 (米/秒^2) ProportionalNavigationCoefficient = 3.0 # 比例导引系数 LaunchAcceleration = 100.0 # 发射加速度 (米/秒^2) -MaxEngineBurnTime = 0.1 # 最大发动机燃烧时间 (秒) +MaxEngineBurnTime = 2.5 # 最大发动机燃烧时间 (秒) CruiseTime = 4.0 # 巡航时间 (秒) Mass = 28.0 # 质量 (千克) ExplosionRadius = 5.0 # 爆炸半径 (米) diff --git a/ThreatSource/data/targets/tanks/mbt_001.json b/ThreatSource/data/targets/tanks/mbt_001.json index 0e2981d..d784fc9 100644 --- a/ThreatSource/data/targets/tanks/mbt_001.json +++ b/ThreatSource/data/targets/tanks/mbt_001.json @@ -14,7 +14,7 @@ "armorThickness": 800.0, "radarCrossSection": 15.0, "infraredRadiationIntensity": 250.0, - "ultravioletRadiationIntensity": 15.0, + "ultravioletRadiationIntensity": 15.0, "millimeterWaveRadiationIntensity": 10.0, "millimeterWaveRadiationTemperature": 150.0, "laserReflectivity": 0.3, diff --git a/ThreatSource/src/Indicator/InfraredTracker.cs b/ThreatSource/src/Indicator/InfraredTracker.cs index 1f170ab..28639c2 100644 --- a/ThreatSource/src/Indicator/InfraredTracker.cs +++ b/ThreatSource/src/Indicator/InfraredTracker.cs @@ -158,6 +158,7 @@ namespace ThreatSource.Indicator return; } currentTargetPosition = targetElement.KState.Position; + _lastKnownTargetPosition = currentTargetPosition; // 记录最后已知的目标位置 } IsTracking = true; diff --git a/ThreatSource/src/Indicator/LaserBeamRider.cs b/ThreatSource/src/Indicator/LaserBeamRider.cs index a1a8c0a..cd43541 100644 --- a/ThreatSource/src/Indicator/LaserBeamRider.cs +++ b/ThreatSource/src/Indicator/LaserBeamRider.cs @@ -139,6 +139,7 @@ namespace ThreatSource.Indicator { LaserDirection = newDirection; Debug.WriteLine($"激光驾束仪 {Id} 更新激光指向: {LaserDirection}"); + _lastKnownTargetPosition = targetPosition; // 记录最后已知的目标位置 PublishLaserBeamEvent(); } } diff --git a/ThreatSource/src/MIssile/BaseMissile.cs b/ThreatSource/src/MIssile/BaseMissile.cs index a8626ff..a249747 100644 --- a/ThreatSource/src/MIssile/BaseMissile.cs +++ b/ThreatSource/src/MIssile/BaseMissile.cs @@ -99,6 +99,11 @@ namespace ThreatSource.Missile /// protected Vector3D ThrustAcceleration { get; set; } + /// + /// 重力加速度(北京标准值) + /// + private static readonly Vector3D GravityAcceleration = new Vector3D(0, -9.8015, 0); + /// /// 获取导弹的固定配置参数 /// @@ -134,12 +139,16 @@ namespace ThreatSource.Missile Properties = properties; // 初始化状态 + EngineBurnTime = 0; FlightTime = 0; FlightDistance = 0; IsActive = false; IsGuidance = false; GuidanceAcceleration = Vector3D.Zero; - ThrustAcceleration = Vector3D.Zero; + + // 计算初始推力加速度 + Vector3D launchDirection = kinematicState.Orientation.ToVector().Normalize(); + ThrustAcceleration = launchDirection * properties.LaunchAcceleration; } /// @@ -179,6 +188,21 @@ namespace ThreatSource.Missile /// protected virtual void UpdateMotionState(double deltaTime) { + // 检查发动机是否仍在提供推力 + if (ThrustAcceleration != Vector3D.Zero) + { + EngineBurnTime += deltaTime; // 累加燃烧时间 + + if (EngineBurnTime >= Properties.MaxEngineBurnTime || KState.Speed >= Properties.MaxSpeed) + { + string reason = EngineBurnTime >= Properties.MaxEngineBurnTime ? + $"达到最大燃烧时间({Properties.MaxEngineBurnTime}s)" : + $"达到最大速度({KState.Speed:F2}m/s >= {Properties.MaxSpeed}m/s)"; + Debug.WriteLine($"导弹 {Id}: 发动机推力已于飞行时间 {FlightTime:F2}s 关闭。原因: {reason}"); + ThrustAcceleration = Vector3D.Zero; // 关闭推力 + } + } + // 计算包含风影响的合加速度 Vector3D acceleration = CalculateAcceleration(KState.Velocity); @@ -216,7 +240,7 @@ namespace ThreatSource.Missile /// 计算过程: /// - 获取当前风速向量 /// - 计算空气阻力加速度(已考虑风) - /// - 合成总加速度(制导加速度 + 推力加速度 + 空气阻力加速度) + /// - 合成总加速度(制导加速度 + 推力加速度 + 空气阻力加速度 + 重力加速度) /// - 限制合加速度不超过最大值 /// private Vector3D CalculateAcceleration(Vector3D velocity) @@ -227,11 +251,11 @@ namespace ThreatSource.Missile // 计算空气阻力加速度(考虑风的影响) Vector3D dragAcceleration = CalculateDragAcceleration(velocity, windVector); - // 合成总加速度(制导加速度 + 推力加速度 + 空气阻力加速度) - Vector3D totalAcceleration = GuidanceAcceleration + ThrustAcceleration + dragAcceleration; + // 合成总加速度(制导加速度 + 推力加速度 + 空气阻力加速度 + 重力加速度) + Vector3D totalAcceleration = GuidanceAcceleration + ThrustAcceleration + dragAcceleration + GravityAcceleration; - Debug.WriteLine($"导弹 {Id} 的加速度: {totalAcceleration}, 制导加速度: {GuidanceAcceleration}, " + - $"推力加速度: {ThrustAcceleration}, 空气阻力加速度(含风影响): {dragAcceleration}"); + Debug.WriteLine($"导弹 {Id} 的加速度: {totalAcceleration}, 制导: {GuidanceAcceleration}, " + + $"推力: {ThrustAcceleration}, 空阻(含风): {dragAcceleration}, 重力: {GravityAcceleration}"); if (totalAcceleration.Magnitude() > Properties.MaxAcceleration) { diff --git a/VERSION b/VERSION index dd76784..b0c8928 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.17 \ No newline at end of file +1.1.18 \ No newline at end of file diff --git a/docs/project/tunning.md b/docs/project/tunning.md index f2279f5..cf9c1bf 100644 --- a/docs/project/tunning.md +++ b/docs/project/tunning.md @@ -331,4 +331,87 @@ 2. 坦克速度 0.5米/秒,仿真运行 29.7 秒,命中 3. 坦克速度 1米/秒,仿真运行 38 秒,自毁 +## 激光驾束导弹实验记录(v1.1.18) + +时间:2025-05-14 10:00:00 +版本:v1.1.18 + +### 运行过程 +导弹最大制导加速度, 50 时出现失控,将其增加到 100,击中目标(最大制导加速度为 77) + +### 实验结论 +1. 导弹最大制导加速度,50 不够,需要将其增加到 100 + +## 激光半主动导弹实验记录(v1.1.18) + +时间:2025-05-14 10:00:00 +版本:v1.1.18 + +### 运行过程 +调整发射角度,使其模仿真实环境的发射角度 +距离 10000米,发射角度 30度,导弹速度 500米/秒,导弹无法锁定,飞出范围。 +距离 10000米,发射角度 15度,导弹速度 500米/秒,导弹锁定目标,击中目标。 +距离 10000米,发射角度 10度,导弹速度 500米/秒,导弹锁定目标,击中目标。 +距离 10000米,发射角度 10度,导弹速度 600米/秒,导弹锁定目标,击中目标。 +上述锁定距离在 2300 米左右。 + +### 实验结论 +1. 导弹在无制导阶段,做抛物线运动,需要调整发射距离、速度和角度,使得导弹在制导阶段锁定目标。 +2. 如果要调整锁定距离,可以调整导弹导引头锁定阈值,实验是 1e-7。 + +## 红外指令制导导弹实验记录(v1.1.18) + +时间:2025-05-14 10:00:00 +版本:v1.1.18 + +### 运行过程 +发射高度 1米,发射角度 0.01,导弹很快落地(因为加了重力) +修改引导系数从 3 到 4,发射角度改到 0.2,导弹最低高度大于 0 +修改最大发动机助推时间从 0.1 到 3,发射角度改为 0.15,最大高度 30 米,最低高度大于 0,击中目标 + +### 实验结论 +1. 因为重力影响,原有的发射速度 + + +## 激光驾束导弹实验记录(v1.1.18) + +时间:2025-05-14 10:00:00 +版本:v1.1.18 + +### 发射参数 +- 发射高度:1米 +- 发射角度:0.1 +- 导弹初速度:10米/秒 +- 加速时间:3秒 +- 导弹最大制导加速度:100 m/s² + +### 原有的参数,效果不佳,最低高度在 0 以下。 +- 比例系数(Kp):30,用于控制系统对误差的敏感度和响应速度 +- 积分系数(Ki):0.05,用于消除长期误差 +- 微分系数(Kd):5,用于减少超调量,提高系统稳定性 +- 非线性增益系数(Kc):0.5,用于控制偏移量修正 +- 最大加速度限制:50 m/s² +- 低通滤波系数(alpha):0.2 + +### 调整后的参数,最低高度在 0.6 米以上 +- 微分系数(Kd):10,用于减少超调量,提高系统稳定性 +- 非线性增益系数(Kc):0.3,用于控制偏移量修正 + + +## 红外制导导弹和毫米波制导导弹实验记录(v1.1.18) + +时间:2025-05-14 10:00:00 +版本:v1.1.18 + +### 导弹合理发射参数 +- 发射高度:1米 +- 发射角度:0.2 +- 导弹初速度:10米/秒 +- 加速时间:2.5秒 +- 导弹最大制导加速度:100 m/s² + + + + + diff --git a/tools/ComprehensiveMissileSimulator.cs b/tools/ComprehensiveMissileSimulator.cs index 18d734f..0c5500a 100644 --- a/tools/ComprehensiveMissileSimulator.cs +++ b/tools/ComprehensiveMissileSimulator.cs @@ -34,7 +34,7 @@ namespace ThreatSource.Tools.MissileSimulation private readonly Dictionary indicators; private readonly Dictionary jammers; private readonly Dictionary missileActiveStatus; - private readonly double timeStep = 0.005; // 时间步长,单位:秒 + public double TimeStep { get; set; } = 0.02; // 时间步长,单位:秒,默认为低精度 // 导弹-干扰映射表 private Dictionary> missileJammingMap; @@ -318,9 +318,9 @@ namespace ThreatSource.Tools.MissileSimulation { var motionParameters = new KinematicState { - Position = new Vector3D(2000, 10, 10), - Orientation = new Orientation(Math.PI/2, -0.01, 0), - Speed = 700 + Position = new Vector3D(10000, 10, 10), + Orientation = new Orientation(Math.PI/2, Math.PI/12, 0), + Speed = 500 }; string missileId = "LSGM_1"; var missile = _threatSourceFactory.CreateMissile(missileId, "lsgm_001", "Tank_1", motionParameters); @@ -336,9 +336,9 @@ namespace ThreatSource.Tools.MissileSimulation { var motionParameters = new KinematicState { - Position = new Vector3D(2000, 10, 10), - Orientation = new Orientation(Math.PI/2, -0.01, 0.0), - Speed = 300 + Position = new Vector3D(2000, 1, 10), + Orientation = new Orientation(Math.PI/2, 0.1, 0.0), + Speed = 10 }; string missileId = "LBRM_1"; var missile = _threatSourceFactory.CreateMissile(missileId, "hj10", "Tank_1", motionParameters); @@ -375,8 +375,8 @@ namespace ThreatSource.Tools.MissileSimulation var motionParameters = new KinematicState { Position = new Vector3D(2000, 1, 20), - Orientation = new Orientation(Math.PI/2, 0.01, 0), - Speed = 300 + Orientation = new Orientation(Math.PI/2, 0.15, 0), + Speed = 10 }; string missileId = "ICGM_1"; @@ -393,9 +393,9 @@ namespace ThreatSource.Tools.MissileSimulation { var motionParameters = new KinematicState { - Position = new Vector3D(2000, 10, 0), - Orientation = new Orientation(Math.PI/2, -0.001, 0), - Speed = 300 + Position = new Vector3D(2000, 1, 0), + Orientation = new Orientation(Math.PI/2, 0.2, 0), + Speed = 10 }; string missileId = "ITGM_1"; var missile = _threatSourceFactory.CreateMissile(missileId, "itg_001", "Tank_1", motionParameters); @@ -412,8 +412,8 @@ namespace ThreatSource.Tools.MissileSimulation var motionParameters = new KinematicState { Position = new Vector3D(2000, 1, 20), - Orientation = new Orientation(Math.PI/2, 0.01, 0), - Speed = 300 + Orientation = new Orientation(Math.PI/2, 0.2, 0), + Speed = 10 }; string missileId = "MMWG_1"; var missile = _threatSourceFactory.CreateMissile(missileId, "mmw_001", "Tank_1", motionParameters); @@ -1047,12 +1047,12 @@ namespace ThreatSource.Tools.MissileSimulation PrintSimulationRegisteredComponents(); // 启动仿真系统 - simulationManager.StartSimulation(timeStep); + simulationManager.StartSimulation(this.TimeStep); while (simulationManager.State == SimulationState.Running) { // 让仿真管理器统一处理所有实体的更新 - simulationManager.Update(timeStep); + simulationManager.Update(this.TimeStep); // 检查是否还有活跃的导弹 var activeMissiles = simulationManager.GetEntitiesByType() @@ -1069,7 +1069,7 @@ namespace ThreatSource.Tools.MissileSimulation // 打印状态 PrintSimulationStatus(); - Thread.Sleep((int)(timeStep * 1000)); + Thread.Sleep((int)(TimeStep * 1000)); } } diff --git a/tools/Program.cs b/tools/Program.cs index c8e56ca..24ed3c4 100644 --- a/tools/Program.cs +++ b/tools/Program.cs @@ -51,6 +51,7 @@ namespace ThreatSource.Tools.MissileSimulation Console.WriteLine($"3. 配置干扰 {simulator.GetActiveJammingDescription()} {(string.IsNullOrEmpty(simulator.SelectedMissileId) ? "(需先选导弹)" : "")}"); Console.WriteLine($"4. 设置日志级别 (当前级别: {simulator.CurrentLogLevel})"); Console.WriteLine($"5. 开始仿真 {(string.IsNullOrEmpty(simulator.SelectedMissileId) ? "(需先选导弹)" : "")}"); + Console.WriteLine($"6. 设置仿真步长 (当前: {simulator.TimeStep}s)"); Console.WriteLine("0. 退出程序"); Console.Write("\n请选择: "); string choice = Console.ReadLine()?.ToLower() ?? string.Empty; @@ -85,6 +86,9 @@ namespace ThreatSource.Tools.MissileSimulation Console.WriteLine("请先选择导弹并完成基本配置 (选择导弹是启动仿真的最低要求)。"); } break; + case "6": + ConfigureTimeStep(simulator); + break; case "0": exitProgram = true; break; @@ -349,5 +353,43 @@ namespace ThreatSource.Tools.MissileSimulation } } } + + static void ConfigureTimeStep(ComprehensiveMissileSimulator simulator) + { + bool backToMainMenu = false; + while (!backToMainMenu) + { + Console.WriteLine("\n--- 设置仿真步长 ---"); + Console.WriteLine($"当前步长: {simulator.TimeStep}s"); + Console.WriteLine("1. 低精度 (0.02s)"); + Console.WriteLine("2. 中精度 (0.01s)"); + Console.WriteLine("3. 高精度 (0.005s)"); + Console.WriteLine("0. 返回主菜单"); + Console.Write("请选择步长: "); + string input = Console.ReadLine()?.ToLower() ?? string.Empty; + + switch (input) + { + case "1": + simulator.TimeStep = 0.02; + Console.WriteLine($"仿真步长已设置为: {simulator.TimeStep}s (低精度)"); + return; // 设置后返回主菜单 + case "2": + simulator.TimeStep = 0.01; + Console.WriteLine($"仿真步长已设置为: {simulator.TimeStep}s (中精度)"); + return; // 设置后返回主菜单 + case "3": + simulator.TimeStep = 0.005; + Console.WriteLine($"仿真步长已设置为: {simulator.TimeStep}s (高精度)"); + return; // 设置后返回主菜单 + case "0": + backToMainMenu = true; + break; + default: + Console.WriteLine("无效选择,请重试。"); + break; + } + } + } } } \ No newline at end of file