给导弹增加了巡航攻角、制导下视角参数,完善了三个阶段的朝向逻辑

This commit is contained in:
Tian jianyong 2025-05-25 18:41:52 +08:00
parent 0d46538d15
commit e5d8f2e1cc
14 changed files with 259 additions and 69 deletions

View File

@ -12,12 +12,14 @@
- 支持与 Simulink 模型的数据交互
- 实现实时仿真数据同步
- 处理不同时间步长的协调
- 毫米波跟踪和锁定阶段采用脉冲多普勒制导
- 命中概率和系统随机噪声
## [1.1.21] - 2025-05-24
- 增加了升力加速度的计算
- 将发射、巡航、制导三个阶段汇聚到导弹基类中
- 将毫米波制导的扫描阶段改为螺旋扫描,并调整了参数
- 完善了集成测试的菜单逻辑,可以反复运行了
- 给导弹增加了巡航攻角、制导下视角参数,完善了三个阶段的朝向逻辑
## [1.1.20] - 2025-05-19
- 增加了SwerlingRCS回波模型

View File

@ -0,0 +1,152 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ThreatSource.Guidance;
using ThreatSource.Simulation;
using ThreatSource.Equipment;
using ThreatSource.Utils;
using System.Diagnostics;
namespace ThreatSource.Tests.Guidance
{
/// <summary>
/// 毫米波制导系统SNR平均化功能测试
/// </summary>
[TestClass]
public class MillimeterWaveGuidanceSnrAveragingTests
{
private SimulationManager? simulationManager;
private MillimeterWaveGuidanceSystem? guidanceSystem;
private Tank? target;
[TestInitialize]
public void Setup()
{
simulationManager = new SimulationManager();
// 创建毫米波制导配置
var config = new MillimeterWaveGuidanceConfig
{
MaxDetectionRange = 5000.0,
FieldOfViewAngle = 15.0,
WaveFrequency = 9.4e10,
SearchBeamWidth = 5.0,
TrackBeamWidth = 4.0,
LockBeamWidth = 3.0,
RecognitionSNRThreshold = -25.0,
LockSNRThreshold = -15.0, // 使用新的放宽阈值
TransmitPower = 0.3,
AntennaGainDB = 23.0,
NoiseFigureDB = 7.0,
SystemLossDB = 6.0,
MonopulseSensitivity = 0.1,
LockConfirmationTime = 0.15,
PulseDuration = 1.0e-6,
JammingResistanceThreshold = 1.0e-5
};
// 创建制导系统
guidanceSystem = new MillimeterWaveGuidanceSystem(
"test_guidance",
"test_missile",
100.0,
4.0,
config,
simulationManager);
// 创建目标坦克
var tankProperties = new EquipmentProperties
{
Type = EquipmentType.Tank,
RcsPattern = new RcsPattern()
};
var initialKState = new KinematicState
{
Position = new Vector3D(1000, 0, 0), // 1000米距离
Velocity = new Vector3D(0, 0, 0),
Orientation = new Orientation(0, 0, 0),
Speed = 0
};
target = new Tank("test_tank", tankProperties, initialKState, simulationManager);
// 激活目标和制导系统
target.Activate();
guidanceSystem.Activate();
// 注册到仿真管理器
simulationManager.RegisterEntity("test_tank", target);
}
[TestCleanup]
public void Cleanup()
{
guidanceSystem?.Deactivate();
target?.Deactivate();
}
/// <summary>
/// 测试SNR平均化功能是否能提高锁定稳定性
/// </summary>
[TestMethod]
public void TestSnrAveraging_ImprovesLockStability()
{
// 模拟从Search -> Track -> Lock的过程
// 1. 首先进入Track模式模拟已经找到目标
guidanceSystem.GetType()
.GetMethod("SwitchToTrackMode", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)
?.Invoke(guidanceSystem, null);
// 2. 更新几次以稳定Track模式
for (int i = 0; i < 10; i++)
{
guidanceSystem.Update(0.1);
}
// 3. 切换到Lock模式
guidanceSystem.GetType()
.GetMethod("SwitchToLockMode", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)
?.Invoke(guidanceSystem, null);
// 4. 验证Lock模式下的SNR平均化
int lockSuccessCount = 0;
int totalUpdates = 20;
for (int i = 0; i < totalUpdates; i++)
{
guidanceSystem.Update(0.1);
if (guidanceSystem.HasTarget)
{
lockSuccessCount++;
}
// 输出调试信息
Debug.WriteLine($"Update {i + 1}: HasTarget = {guidanceSystem.HasTarget}, IsInLockMode = {guidanceSystem.IsInLockMode}");
}
// 验证锁定稳定性有所改善
double successRate = (double)lockSuccessCount / totalUpdates;
Debug.WriteLine($"Lock success rate: {successRate:P2} ({lockSuccessCount}/{totalUpdates})");
// 期望成功率应该合理考虑到RCS波动
Assert.IsTrue(successRate > 0.3, $"Lock success rate should be > 30%, but was {successRate:P2}");
Assert.IsTrue(guidanceSystem.IsInLockMode, "Should remain in Lock mode");
}
/// <summary>
/// 测试新的SNR阈值设置
/// </summary>
[TestMethod]
public void TestNewSnrThreshold_IsApplied()
{
// 验证新的SNR阈值已经应用
var config = guidanceSystem.GetType()
.GetField("config", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)
?.GetValue(guidanceSystem) as MillimeterWaveGuidanceConfig;
Assert.IsNotNull(config, "Config should not be null");
Assert.AreEqual(-15.0, config.LockSNRThreshold, 0.1, "Lock SNR threshold should be -15.0 dB");
}
}
}

View File

@ -19,6 +19,8 @@ Mass = 25.0
ExplosionRadius = 5.0
HitProbability = 0.9
SelfDestructHeight = 0.0
CruiseAttackAngle = 5.0 # 巡航阶段攻角 (度)
GuidanceSeekingAngle = 15.0 # 制导阶段导引头下视角 (度)
InfraredRadiationIntensity = 96.0 # 红外辐射强度 (瓦特/球面度)
UltravioletRadiationIntensity = 100.0 # 紫外辐射强度 (瓦特/球面度)
# --- 复合制导特定属性 ---
@ -49,20 +51,6 @@ MinTimeWithGuidanceBeforeSwitchSeconds = 60.0 # 设置为MaxFlightTime使其
ContinueChainOnFailure = false # 这是最后一个,失败也无需继续
# --- 各制导模式的详细配置 ---
[InfraredImagingGuidanceConfig]
MaxDetectionRange = 1000.0 # 最大探测距离 (米)
SearchFieldOfView = 12.0 # 搜索视场角 (度)
TrackFieldOfView = 6.0 # 跟踪视场角 (度)
ImageWidth = 640 # 图像宽度 (像素)
ImageHeight = 480 # 图像高度 (像素)
BackgroundIntensity = 1.0e-4 # 背景辐射强度 (瓦特/球面度)
SearchRecognitionProbability = 0.6 # 搜索模式目标识别概率阈值
TrackRecognitionProbability = 0.8 # 跟踪模式目标识别概率阈值
TargetLostTolerance = 0.3 # 目标丢失容忍时间 (秒)
LockConfirmationTime = 0.5 # 锁定确认时间 (秒)
JammingResistanceThreshold = 1.0e-5 # 干扰抗性阈值 (瓦特)
Wavelength = 3.0 # 波长 (微米)
[MillimeterWaveGuidanceConfig]
MaxDetectionRange = 5000.0 # 最大探测距离 (米)
FieldOfViewAngle = 30.0 # 视场角 (度) - 扩大搜索范围提高目标捕获率
@ -89,4 +77,18 @@ SystemLossDB = 6.0 # 系统损耗 (分贝)
MonopulseSensitivity = 0.1 # 单脉冲灵敏度系数 - 优化测角精度
YawControlEffectiveness = 120.0 # 偏航控制有效性 (度/秒^2 或类似单位)
PitchControlEffectiveness = 150.0 # 俯仰控制有效性 (度/秒^2 或类似单位)
JammingResistanceThreshold = 1.0e-5 # 干扰抗性阈值 (瓦特)
JammingResistanceThreshold = 1.0e-5 # 干扰抗性阈值 (瓦特)
[InfraredImagingGuidanceConfig]
MaxDetectionRange = 1000.0 # 最大探测距离 (米)
SearchFieldOfView = 12.0 # 搜索视场角 (度)
TrackFieldOfView = 6.0 # 跟踪视场角 (度)
ImageWidth = 640 # 图像宽度 (像素)
ImageHeight = 480 # 图像高度 (像素)
BackgroundIntensity = 1.0e-4 # 背景辐射强度 (瓦特/球面度)
SearchRecognitionProbability = 0.6 # 搜索模式目标识别概率阈值
TrackRecognitionProbability = 0.8 # 跟踪模式目标识别概率阈值
TargetLostTolerance = 0.3 # 目标丢失容忍时间 (秒)
LockConfirmationTime = 0.5 # 锁定确认时间 (秒)
JammingResistanceThreshold = 1.0e-5 # 干扰抗性阈值 (瓦特)
Wavelength = 3.0 # 波长 (微米)

View File

@ -19,6 +19,8 @@ Mass = 25.0
ExplosionRadius = 5.0
HitProbability = 0.9
SelfDestructHeight = 0.0
CruiseAttackAngle = 5.0 # 巡航阶段攻角 (度)
GuidanceSeekingAngle = 15.0 # 制导阶段导引头下视角 (度)
InfraredRadiationIntensity = 96.0 # 红外辐射强度 (瓦特/球面度)
UltravioletRadiationIntensity = 100.0 # 紫外辐射强度 (瓦特/球面度)
# --- 复合制导特定属性 ---

View File

@ -7,21 +7,22 @@ En = "IR Command Guided Missile-001"
[Properties]
Type = "InfraredCommandGuidance" # 属性中的类型与顶层Type一致
MaxSpeed = 300.0 # 最大速度 (米/秒)
MaxSpeed = 250.0 # 最大速度 (米/秒)
MaxFlightTime = 60.0 # 最大飞行时间 (秒)
MaxFlightDistance = 5000.0 # 最大飞行距离 (米)
MaxAcceleration = 150.0 # 最大加速度 (米/秒^2)
ProportionalNavigationCoefficient = 4.0 # 比例导引系数
LaunchAcceleration = 150.0 # 发射加速度 (米/秒^2)
MaxEngineBurnTime = 2.0 # 最大发动机燃烧时间 (秒)
MaxAcceleration = 100.0 # 最大加速度 (米/秒^2)
ProportionalNavigationCoefficient = 3.0 # 比例导引系数
LaunchAcceleration = 100.0 # 发射加速度 (米/秒^2)
MaxEngineBurnTime = 3.0 # 最大发动机燃烧时间 (秒)
CruiseTime = 2.0 # 巡航时间 (秒)
Mass = 23.5 # 质量 (千克)
ExplosionRadius = 5.0 # 爆炸半径 (米)
HitProbability = 0.9 # 命中概率
SelfDestructHeight = 0.0 # 自毁高度 (米)
InfraredRadiationIntensity = 96.0 # 红外辐射强度 (瓦特/球面度)
CruiseAttackAngle = 5.0 # 巡航阶段攻角 (度)
GuidanceSeekingAngle = 0.0 # 制导阶段导引头下视角 (度)
InfraredRadiationIntensity = 96.0 # 红外辐射强度 (瓦特/球面度)
UltravioletRadiationIntensity = 100.0 # 紫外辐射强度 (瓦特/球面度)
# TrackerSensitivity, CommandLatency, IrSignature 在JSON中为null此处省略
[InfraredCommandGuidanceConfig]
JammingResistanceThreshold = 1.0e-5 # 干扰抗性阈值 (瓦特)

View File

@ -13,13 +13,15 @@ MaxFlightDistance = 5000.0
MaxAcceleration = 100.0
ProportionalNavigationCoefficient = 4.0
LaunchAcceleration = 100.0
MaxEngineBurnTime = 2.5
CruiseTime = 3.0
MaxEngineBurnTime = 3.0
CruiseTime = 2.5
Mass = 25.0
ExplosionRadius = 5.0
HitProbability = 0.9
SelfDestructHeight = 0.0
InfraredRadiationIntensity = 96.0 # 红外辐射强度 (瓦特/球面度)
CruiseAttackAngle = 5.0 # 巡航阶段攻角 (度)
GuidanceSeekingAngle = 6.0 # 制导阶段导引头下视角 (度)
InfraredRadiationIntensity = 96.0 # 红外辐射强度 (瓦特/球面度)
UltravioletRadiationIntensity = 100.0 # 紫外辐射强度 (瓦特/球面度)
[InfraredImagingGuidanceConfig]

View File

@ -19,6 +19,8 @@ Mass = 24.5 # 质量 (千克)
ExplosionRadius = 5.0 # 爆炸半径 (米)
HitProbability = 0.9 # 命中概率
SelfDestructHeight = 0.0 # 自毁高度 (米)
CruiseAttackAngle = 5.0 # 巡航阶段攻角 (度)
GuidanceSeekingAngle = 0.0 # 制导阶段导引头下视角 (度)
InfraredRadiationIntensity = 96.0 # 红外辐射强度 (瓦特/球面度)
UltravioletRadiationIntensity = 100.0 # 紫外辐射强度 (瓦特/球面度)

View File

@ -11,15 +11,17 @@ Type = "LaserSemiActiveGuidance" # properties内部的类型标识符
MaxSpeed = 800.0 # 最大速度 (m/s)
MaxFlightTime = 60.0 # 最大飞行时间 (秒)
MaxFlightDistance = 20000.0 # 最大飞行距离 (米)
MaxAcceleration = 50.0 # 最大横向加速度 (m/s^2)
MaxAcceleration = 100.0 # 最大横向加速度 (m/s^2)
ProportionalNavigationCoefficient = 3.0 # 比例导引系数
LaunchAcceleration = 0.0 # 初始发射加速度 (m/s^2)
MaxEngineBurnTime = 0.0 # 发动机最大燃烧时间 (秒)
CruiseTime = 10.0 #巡航阶段时长 (秒)
MaxEngineBurnTime = 2.0 # 发动机最大燃烧时间 (秒)
CruiseTime = 1.0 #巡航阶段时长 (秒)
Mass = 22.0 # 导弹质量 (kg)
ExplosionRadius = 5.0 # 爆炸半径 (米)
HitProbability = 0.9 # 固有命中概率 (0.0 到 1.0)
SelfDestructHeight = 0.0 # 离地自毁高度 (米)
CruiseAttackAngle = 5.0 # 巡航阶段攻角 (度)
GuidanceSeekingAngle = 15.0 # 制导阶段导引头下视角 (度)
InfraredRadiationIntensity = 96.0 # 红外辐射强度 (瓦特/球面度)
UltravioletRadiationIntensity = 100.0 # 紫外辐射强度 (瓦特/球面度)

View File

@ -13,12 +13,14 @@ MaxFlightDistance = 8000.0 # 最大飞行距离 (米)
MaxAcceleration = 100.0 # 最大加速度 (米/秒^2)
ProportionalNavigationCoefficient = 4.0 # 比例导引系数
LaunchAcceleration = 100.0 # 发射加速度 (米/秒^2)
MaxEngineBurnTime = 2.5 # 最大发动机燃烧时间 (秒)
CruiseTime = 3.5 # 巡航时间 (秒)
MaxEngineBurnTime = 3.0 # 最大发动机燃烧时间 (秒)
CruiseTime = 2.5 # 巡航时间 (秒)
Mass = 28.0 # 质量 (千克)
ExplosionRadius = 5.0 # 爆炸半径 (米)
HitProbability = 0.9 # 命中概率
SelfDestructHeight = 0.0 # 自毁高度 (米)
CruiseAttackAngle = 5.0 # 巡航阶段攻角 (度)
GuidanceSeekingAngle = 15.0 # 制导阶段导引头下视角 (度)
InfraredRadiationIntensity = 96.0 # 红外辐射强度 (瓦特/球面度)
UltravioletRadiationIntensity = 100.0 # 紫外辐射强度 (瓦特/球面度)

View File

@ -266,13 +266,24 @@ namespace ThreatSource.Missile
// 巡航阶段不使用制导
GuidanceAcceleration = Vector3D.Zero;
if(KState.Orientation.Pitch > 0)
// 调整速度方向为水平飞行
if (Math.Abs(KState.Velocity.Y) > 0.1) // 如果有明显的垂直速度分量
{
KState.Orientation = new Orientation(KState.Orientation.Yaw, -0.01, KState.Orientation.Roll);
// 保持水平速度大小,消除垂直分量
double horizontalSpeed = Math.Sqrt(KState.Velocity.X * KState.Velocity.X + KState.Velocity.Z * KState.Velocity.Z);
if (horizontalSpeed > 0.1) // 确保有水平速度
{
Vector3D horizontalDirection = new Vector3D(KState.Velocity.X, 0, KState.Velocity.Z).Normalize();
KState.Velocity = horizontalDirection * KState.Speed;
}
}
// 计算升力加速度。在巡航阶段,升力加速度与重力加速度抵消
LiftAcceleration = new Vector3D(0, PhysicalConstants.BeijingGravity, 0);
// 设置巡航攻角(相对于水平面)
double cruiseAttackAngleRad = Properties.CruiseAttackAngle * Math.PI / 180.0;
KState.Orientation = new Orientation(KState.Orientation.Yaw, cruiseAttackAngleRad, KState.Orientation.Roll);
// 计算升力加速度:在巡航阶段,基于攻角计算升力
LiftAcceleration = LiftModel.CalculateLiftAcceleration(Properties.CruiseAttackAngle);
// 巡航阶段结束,进入制导阶段
if (FlightTime >= Properties.MaxEngineBurnTime + Properties.CruiseTime)
@ -331,10 +342,17 @@ namespace ThreatSource.Missile
(KState.Position, KState.Velocity) = MotionAlgorithm.CalculateBallisticMotion(KState.Position, KState.Velocity, acceleration, deltaTime);
}
// 在制导阶段,导弹指向速度方向(便于搜索跟踪)
// 在制导阶段,根据是否获得制导来调整导弹朝向
if(currentStage == MissileFlightStage.Guidance)
{
KState.Orientation = Orientation.FromVector(KState.Velocity);
if (!IsGuidance)
{
// 导引头搜索阶段:保持水平飞行,导弹朝向向下一个固定角度进行搜索
// 不改变速度向量,让导引头在下视角范围内搜索目标
double seekingAngleRad = Properties.GuidanceSeekingAngle * Math.PI / 180.0;
KState.Orientation = new Orientation(KState.Orientation.Yaw, -seekingAngleRad, KState.Orientation.Roll);
}
// 如果IsGuidance为true制导系统会通过GuidanceAcceleration自动调整导弹的飞行轨迹和朝向
}
// 限制速度不超过最大速度

View File

@ -99,24 +99,6 @@ namespace ThreatSource.Missile
SimulationManager.UnregisterEntity(guidanceSystem.Id);
}
/// <summary>
/// 更新巡航阶段状态
/// </summary>
/// <param name="deltaTime">时间步长,单位:秒</param>
/// <remarks>
/// 巡航阶段处理:
/// - 启用制导控制
/// - 更新制导系统
/// - 计算制导加速度
/// - 检查自毁条件
/// </remarks>
protected override void OnCruiseStage(double deltaTime)
{
base.OnCruiseStage(deltaTime);
LiftAcceleration = Vector3D.Zero;
}
/// <summary>
/// 更新制导阶段状态
/// </summary>

View File

@ -355,6 +355,27 @@ namespace ThreatSource.Missile
/// </remarks>
public double UltravioletRadiationIntensity { get; set; }
/// <summary>
/// 获取或设置巡航阶段攻角
/// </summary>
/// <remarks>
/// 单位:度
/// 巡航阶段导弹的攻角,用于产生升力平衡重力
/// 典型值为5度左右
/// </remarks>
public double CruiseAttackAngle { get; set; }
/// <summary>
/// 获取或设置制导阶段导引头下视角
/// </summary>
/// <remarks>
/// 单位:度
/// 制导阶段导引头相对于水平面的下视角
/// 用于调整导弹朝向以便导引头能够搜索和跟踪目标
/// 不同导弹类型有不同的典型值
/// </remarks>
public double GuidanceSeekingAngle { get; set; }
/// <summary>
/// 制导组件套件。仅当 Type 为 CompositeGuidance 时有效。
/// 列表中的顺序可能也暗示了串行模式下的默认阶段顺序,除非 ActivationTrigger 另有复杂规定并结合Priority。
@ -415,6 +436,8 @@ namespace ThreatSource.Missile
SelfDestructHeight = 0;
InfraredRadiationIntensity = 100.0;
UltravioletRadiationIntensity = 100.0;
CruiseAttackAngle = 5.0;
GuidanceSeekingAngle = 10.0;
// 设置复合制导相关属性的默认值
if(Type == MissileType.CompositeGuidance)

View File

@ -510,29 +510,29 @@
- 发射角度0.04 弧度
3. 红外指令
- 发射加速度150 m/s²
- 发动机最大燃烧时间2.0 秒
- 巡航时间2 秒
- 发动机最大燃烧时间3.0 秒
- 巡航时间2.0 秒
4. 红外热成像
- 发射加速度100 m/s²
- 发动机最大燃烧时间:2.5
- 巡航时间:3.0
- 发动机最大燃烧时间:3.0
- 巡航时间:2.5
- 发射角度:0.12 弧度(此时巡航高度 150 米,制导阶段起始角度-0.01弧度
- 发射角度:PI/15 弧度12度此时巡航高度 130 米
5. 毫米波末制导
- 发射加速度100 m/s²
- 发动机最大燃烧时间:2.5
- 巡航时间:3.0
- 发动机最大燃烧时间:3.0
- 巡航时间:2.5
- 发射角度0.05 弧度(此时巡航高度 15 米,制导阶段起始角度-0.02弧度,搜索视场角 15 度)
- 发射角度0.05 弧度
6. 激光半主动
- 比例引导系数3
- 发射加速度0.0 m/s²
- 发动机最大燃烧时间0.0 秒
- 巡航时间10.0 秒
- 发射阶段时间2.0 秒
- 巡航时间1.0 秒
- 发射距离:10000 m
- 发射距离:5000 m
- 发射速度700 m/s
- 发射角度Math.PI/20大约 3 度)
7. 复合制导
@ -540,6 +540,6 @@
- 发动机最大燃烧时间2.5 秒
- 巡航时间3.0 秒
- 发射角度0.05 弧度(此时巡航高度 15 米,制导阶段起始角度-0.02弧度,毫米波搜索视场角 15 度
- 发射角度0.05 弧度(此时巡航高度 15 米)

View File

@ -334,7 +334,7 @@ namespace ThreatSource.Tools.MissileSimulation
{
var motionParameters = new KinematicState
{
Position = new Vector3D(10000, 1, 10),
Position = new Vector3D(5000, 1, 10),
Orientation = new Orientation(Math.PI/2, Math.PI/20, 0),
Speed = 700
};
@ -415,7 +415,7 @@ namespace ThreatSource.Tools.MissileSimulation
var motionParameters = new KinematicState
{
Position = new Vector3D(2000, 1, 0),
Orientation = new Orientation(Math.PI/2, 0.12, 0),
Orientation = new Orientation(Math.PI/2, Math.PI/15, 0),
Speed = 10
};