自制合成孔径雷达(1) 后处理程序在Octave下运行

发布时间 2023-07-20 18:04:23作者: SymPny

我最近看到一个麻省理工学院的开放课程,用一些简易电路来实现一个雷达,可以测距、测速也可以做合成孔径雷达。硬件电路用adc+单片机+usb转接实现,然后传输给电脑,电脑上c#程序做实时处理。但是这个教程资料还不是很完善,我没找到单片机和c#代码。然后我上MIT opencourseware网站上找到了老版本的资料。

链接: https://pan.baidu.com/s/1bvSZxAIw3A-79efm4WifsA  密码: 4qr7

老版本与新版本的区别是:

1.硬件上老版本全部都是模拟电路,然后通过声卡线路输入传输给电脑,也就是说adc是利用了电脑内部的,不是自己搭的。

2.软件上老版本用matlab实现,是把音频文件录下来做后处理的,但我觉得我可以改写为python,然后实时处理。

在搭硬件电路前,我想先试试软件行不行,毕竟试一下软件没啥成本,而且如果软件不行那硬件也白搭。

而且我的电脑比较慢,我不打算装庞大的matlab,我用了octave。

下面几个图就是我用octave跑的3个范例程序。多普勒测速是可以直接跑的。测距和SAR是需要改一下代码,其实也很简单只需要把&改为&&就行。有一点要注意多普勒测速程序运行起来比较快可能几秒就有结果,后面两个程序大概要等个几分钟才会有结果。

doppler:

 

range:

read_data_RTI.m

  1. %MIT IAP Radar Course 2011
  2. %Resource: Build a Small Radar System Capable of Sensing Range, Doppler,
  3. %and Synthetic Aperture Radar Imaging
  4. %
  5. %Gregory L. Charvat
  6. %Process Range vs. Time Intensity (RTI) plot
  7. %NOTE: set up-ramp sweep from 2-3.2V to stay within ISM band
  8. %change fstart and fstop bellow when in ISM band
  9. clear all;
  10. close all;
  11. %read the raw data .wave file here
  12. [Y,FS,NBITS] = wavread('running_outside_20ms.wav');
  13. %constants
  14. c = 3E8; %(m/s) speed of light
  15. %radar parameters
  16. Tp = 20E-3; %(s) pulse time
  17. N = Tp*FS; %# of samples per pulse
  18. fstart = 2260E6; %(Hz) LFM start frequency for example
  19. fstop = 2590E6; %(Hz) LFM stop frequency for example
  20. %fstart = 2402E6; %(Hz) LFM start frequency for ISM band
  21. %fstop = 2495E6; %(Hz) LFM stop frequency for ISM band
  22. BW = fstop-fstart; %(Hz) transmti bandwidth
  23. f = linspace(fstart, fstop, N/2); %instantaneous transmit frequency
  24. %range resolution
  25. rr = c/(2*BW);
  26. max_range = rr*N/2;
  27. %the input appears to be inverted
  28. trig = -1*Y(:,1);
  29. s = -1*Y(:,2);
  30. clear Y;
  31. %parse the data here by triggering off rising edge of sync pulse
  32. count = 0;
  33. thresh = 0;
  34. start = (trig > thresh);
  35. for ii = 100:(size(start,1)-N)
  36. if start(ii) == 1 && mean(start(ii-11:ii-1)) == 0
  37. %start2(ii) = 1;
  38. count = count + 1;
  39. sif(count,:) = s(ii:ii+N-1);
  40. time(count) = ii*1/FS;
  41. end
  42. end
  43. %check to see if triggering works
  44. % plot(trig,'.b');
  45. % hold on;si
  46. % plot(start2,'.r');
  47. % hold off;
  48. % grid on;
  49. %subtract the average
  50. ave = mean(sif,1);
  51. for ii = 1:size(sif,1);
  52. sif(ii,:) = sif(ii,:) - ave;
  53. end
  54. zpad = 8*N/2;
  55. %RTI plot
  56. figure(10);
  57. v = dbv(ifft(sif,zpad,2));
  58. S = v(:,1:size(v,2)/2);
  59. m = max(max(v));
  60. imagesc(linspace(0,max_range,zpad),time,S-m,[-80, 0]);
  61. colorbar;
  62. ylabel('time (s)');
  63. xlabel('range (m)');
  64. title('RTI without clutter rejection');
  65. %2 pulse cancelor RTI plot
  66. figure(20);
  67. sif2 = sif(2:size(sif,1),:)-sif(1:size(sif,1)-1,:);
  68. v = ifft(sif2,zpad,2);
  69. S=v;
  70. R = linspace(0,max_range,zpad);
  71. for ii = 1:size(S,1)
  72. %S(ii,:) = S(ii,:).*R.^(3/2); %Optional: magnitude scale to range
  73. end
  74. S = dbv(S(:,1:size(v,2)/2));
  75. m = max(max(S));
  76. imagesc(R,time,S-m,[-80, 0]);
  77. colorbar;
  78. ylabel('time (s)');
  79. xlabel('range (m)');
  80. title('RTI with 2-pulse cancelor clutter rejection');
  81. % %2 pulse mag only cancelor
  82. % figure(30);
  83. % clear v;
  84. % for ii = 1:size(sif,1)-1
  85. % v1 = abs(ifft(sif(ii,:),zpad));
  86. % v2 = abs(ifft(sif(ii+1,:),zpad));
  87. % v(ii,:) = v2-v1;
  88. % end
  89. % S=v;
  90. % R = linspace(0,max_range,zpad);
  91. % for ii = 1:size(S,1)
  92. % S(ii,:) = S(ii,:).*R.^(3/2); %Optional: magnitude scale to range
  93. % end
  94. % S = dbv(S(:,1:size(v,2)/2));
  95. % m = max(max(S));
  96. % imagesc(R,time,S-m,[-20, 0]);
  97. % colorbar;
  98. % ylabel('time (s)');
  99. % xlabel('range (m)');
  100. % title('RTI with 2-pulse mag only cancelor clutter rejection');

sar:

SBAND_RMA_opendata.m

  1. MIT IAP Radar Course 2011
  2. %Resource: Build a Small Radar System Capable of Sensing Range, Doppler,
  3. %and Synthetic Aperture Radar Imaging
  4. %
  5. %Gregory L. Charvat
  6. %SAR algorithm from:
  7. %Range Migration Algorithm from ch 10 of Spotlight Synthetic Aperture Radar
  8. %Signal Processing Algorithms, Carrara, Goodman, and Majewski
  9. %NOTE: set up-ramp sweep from 2-3.2V to stay within ISM band
  10. %change fstart and fstop bellow when in ISM band
  11. %-------------------------------------------%
  12. %Process raw data here
  13. clear all;
  14. close all;
  15. %read the raw data .wave file here
  16. [Y,FS,NBITS] = wavread('towardswarehouse.wav');
  17. %constants
  18. c = 3E8; %(m/s) speed of light
  19. %radar parameters
  20. Tp = 20E-3; %(s) pulse time
  21. Trp = 0.25; %(s) min range profile time duration
  22. N = Tp*FS; %# of samples per pulse
  23. fstart = 2260E6; %(Hz) LFM start frequency
  24. fstop = 2590E6; %(Hz) LFM stop frequency
  25. %fstart = 2402E6; %(Hz) LFM start frequency for ISM band
  26. %fstop = 2495E6; %(Hz) LFM stop frequency for ISM band
  27. BW = fstop-fstart; %(Hz) transmti bandwidth
  28. f = linspace(fstart, fstop, N/2); %instantaneous transmit frequency
  29. %the input appears to be inverted
  30. trig = -1*Y(:,1);
  31. s = -1*Y(:,2);
  32. clear Y;
  33. %parse data here by position (silence between recorded data)
  34. rpstart = abs(trig)>mean(abs(trig));
  35. count = 0;
  36. Nrp = Trp*FS; %min # samples between range profiles
  37. for ii = Nrp+1:size(rpstart,1)-Nrp
  38. if rpstart(ii) == 1 && sum(rpstart(ii-Nrp:ii-1)) == 0
  39. count = count + 1;
  40. RP(count,:) = s(ii:ii+Nrp-1);
  41. RPtrig(count,:) = trig(ii:ii+Nrp-1);
  42. end
  43. end
  44. %parse data by pulse
  45. count = 0;
  46. thresh = 0.08;
  47. clear ii;
  48. for jj = 1:size(RP,1)
  49. %clear SIF;
  50. SIF = zeros(N,1);
  51. start = (RPtrig(jj,:)> thresh);
  52. count = 0;
  53. jj
  54. for ii = 12:(size(start,2)-2*N)
  55. [Y I] = max(RPtrig(jj,ii:ii+2*N));
  56. if mean(start(ii-10:ii-2)) == 0 && I == 1
  57. count = count + 1;
  58. SIF = RP(jj,ii:ii+N-1)' + SIF;
  59. end
  60. end
  61. %hilbert transform
  62. q = ifft(SIF/count);
  63. sif(jj,:) = fft(q(size(q,1)/2+1:size(q,1)));
  64. end
  65. sif(find(isnan(sif))) = 1E-30; %set all Nan values to 0
  66. %SAR data should be ready here
  67. clear s;
  68. s = sif;
  69. save routsidewarehouse2 s; %for image data
  70. %-------------------------------------------%
  71. %load additional varaibles and setup constants for radar here
  72. clear all;
  73. c = 3E8; %(m/s) speed of light
  74. %load IQ converted data here
  75. load routsidewarehouse2 s; %load variable sif %for image data
  76. for ii = 1:size(s,1)
  77. s(ii,:) = s(ii,:) - mean(s,1);
  78. end
  79. %sif = s-sif_sub; %perform coherent background subtraction
  80. %sif = sif_sub; %image just the background
  81. sif = s; %image without background subtraction
  82. clear s;
  83. clear sif_sub;
  84. %***********************************************************************
  85. %radar parameters
  86. fc = (2590E6 - 2260E6)/2 + 2260E6; %(Hz) center radar frequency
  87. B = (2590E6 - 2260E6); %(hz) bandwidth
  88. cr = B/20E-3; %(Hz/sec) chirp rate
  89. Tp = 20E-3; %(sec) pulse width
  90. %VERY IMPORTANT, change Rs to distance to cal target
  91. %Rs = (12+9/12)*.3048; %(m) y coordinate to scene center (down range), make this value equal to distance to cal target
  92. Rs = 0;
  93. Xa = 0; %(m) beginning of new aperture length
  94. delta_x = 2*(1/12)*0.3048; %(m) 2 inch antenna spacing
  95. L = delta_x*(size(sif,1)); %(m) aperture length
  96. Xa = linspace(-L/2, L/2, (L/delta_x)); %(m) cross range position of radar on aperture L
  97. Za = 0;
  98. Ya = Rs; %THIS IS VERY IMPORTANT, SEE GEOMETRY FIGURE 10.6
  99. t = linspace(0, Tp, size(sif,2)); %(s) fast time, CHECK SAMPLE RATE
  100. Kr = linspace(((4*pi/c)*(fc - B/2)), ((4*pi/c)*(fc + B/2)), (size(t,2)));
  101. %Save background subtracted and callibrated data
  102. save sif sif delta_x Rs Kr Xa;
  103. %clear all;
  104. %run IFP
  105. SBAND_RMA_IFP;