Add Radar simulation

This commit is contained in:
Ksyer
2024-05-09 16:48:41 +08:00
parent c57d8588e3
commit 392f83b068
29 changed files with 409 additions and 56 deletions
+14
View File
@@ -0,0 +1,14 @@
global c f_c B T_r N F_s M k lambda
c = 3e8; %光速
f_c = 70e9; %发射信号载频 中心频率
B = 500e6; %发射信号带宽
T_r = 1e-5; %扫频时间 也就是周期
N = 256; %采样点
F_s = round(N / T_r); %采样率
M = 256; %chirp的数目
k = B/T_r; %chirp斜率
lambda = c / (f_c - B/2);
ksy_main;
draw;
+38
View File
@@ -0,0 +1,38 @@
% https://blog.csdn.net/Xiao_Jie123/article/details/115296169
%% 超参数
c = 3e8; %光速
f_c = 76.5e9; %发射信号载频 中心频率
B = 500e6; %发射信号带宽
T_r = 10e-6; %扫频时间 也就是周期
N = 256; %采样点
F_s = 25.6e6; %采样率
M = 256; %chirp的数目
k = B/T_r; %chirp斜率
index = 1:1:N; %产生点向量
IF_mat = zeros(M,N); %存储带有噪声的中频信号
%% 发射信号参数
AT = 10; %发射信号增益
t = 0:1/F_s:T_r-1/F_s; %时间向量 确定256个点在一个Tr中的每个时刻
t = t - T_r/2; %将fc作为中心频率
%% 回波信号参数
distance = 50; %目标距离雷达50m的距离
t_d = 2 * distance / c; %目标距离雷达的延迟
velocity = -20; %目标距雷达的相对速度为30m/s
f_d = 2 * (f_c - B/2) * velocity / c; %多普勒频移
AR = 0.8; %回波信号衰减的比例值
%% 生成数据
for i = 1:1:M %chirp的循环
s_T = AT*exp((1i*2*pi)*(f_c*(t+i*T_r)+k/2*t.^2)); %发射信号
s_R = AR*AT*exp((1i*2*pi)*((f_c-f_d)*(t-t_d+i*T_r)+k/2*(t-t_d).^2)); %回波信号
%% 求回波信号的共轭
s_R_conj = conj(s_R); %求回波信号的共轭
%% 求中频信号
IF = s_T .* s_R_conj; %求中频信号
SNR = 10; %信噪比
IF_with_Noise = awgn(IF,SNR,'measured'); %给中频信号加高斯白噪声,在添加噪声的时候,要进行能量的测量
IF_mat(i,:) = IF_with_Noise; %将带有噪声的中频信号保存
end
save('Ego_vehicle.mat', 'IF_mat'); %进行数据的保存
+44
View File
@@ -0,0 +1,44 @@
% https://blog.csdn.net/Xiao_Jie123/article/details/115296169
clc; clear;
global c T_r F_s k lambda
%% 加载数据
% IF_mat = cell2mat(struct2cell(load('Ego_vehicle.mat','IF_mat')));
IF_mat = cell2mat(struct2cell(load('Ego_vehicle_ksy.mat','IF_mat')));
[N, M] = size(IF_mat);
%% 生成窗
range_win = hamming(N); %生成range窗
doppler_win = hamming(M); %生成doppler窗
%% range fft
for i = 1:1:N
temp = IF_mat(i,:) .* range_win';
% temp_fft = fftshift(fft(temp,N));
temp_fft = fft(temp,N);
IF_mat(i,:) = temp_fft;
end
%% doppler fft
for j = 1:1:M
temp = IF_mat(:,j) .* doppler_win;
temp_fft = fftshift(fft(temp,M));
IF_mat(:,j) = temp_fft;
end
%% 画图
figure;
distance_temp = (-N/2:N/2 - 1) * F_s * c / N / 2 / k;
% distance_temp = (0:N - 1) * F_s * c / N / 2 / k;
speed_temp = (-M / 2:M / 2 - 1) * lambda / T_r / M / 2;
[X,Y] = meshgrid(distance_temp,speed_temp);
mesh(X,Y,(abs(IF_mat)));
xlabel('距离(m)');
ylabel('速度(m/s)');
zlabel('信号幅值');
title('2维FFT处理三维视图');
figure;
speed_temp = -speed_temp;
imagesc(distance_temp,speed_temp,abs(IF_mat));
title('距离-多普勒视图');
xlabel('距离(m)');
ylabel('速度(m/s)');
+39
View File
@@ -0,0 +1,39 @@
%% 超参数
global c f_c B T_r N F_s M k lambda
index = 1:1:N; %产生点向量
IF_mat = zeros(M,N); %存储带有噪声的中频信号
t = 0:1/F_s:T_r-1/F_s; %时间向量 确定256个点在一个Tr中的每个时刻
t = t - T_r/2; %将fc作为中心频率
dist = 10; %目标距离雷达50m的距离
t_d = 2 * dist / c; %目标距离雷达的延迟
velocity = -20; %目标距雷达的相对速度为30m/s
f_d = 2 * f_c * velocity / c; %多普勒频移
% f_d = 2 * (f_c - B/2) * velocity / c; %多普勒频移
scat_coef = 0.8; %回波信号衰减的比例值
s_T = chirp(t, f_c, t(end), f_c + B);
pad = round(t_d * F_s);
s_R = [zeros(1, pad), scat_coef * s_T(1: end - pad)];
for i = 1: M
s_T = 1*exp((1i*2*pi)*(f_c*(t+i*T_r)+k/2*t.^2)); %发射信号
s_R = scat_coef*exp((1i*2*pi)*((f_c-f_d)*(t-t_d+i*T_r)+k/2*(t-t_d).^2)); %回波信号
IF = s_T .* conj(s_R);
% SNR = 10;
% IF_Noise = awgn(IF, SNR, 'measured');
IF_Noise = IF;
IF_mat(i, :) = IF_Noise;
end
save('Ego_vehicle_ksy.mat','IF_mat');
% figure;
% subplot(211);
% plot(t, s_T);
% ylim([-1.3, 1.3]);
%
% subplot(212);
% plot(t, s_R);
% ylim([-1.3, 1.3]);