예제 #1
0
void UmlBroadcastSignalAction::write(FileOut & out) {
  write_begin(out, "BroadcastSignalAction");
  write_end(out, TRUE);
  write_signal(out);
  write_close(out);
}
예제 #2
0
void process_radar_signal(radar &a_radar, vector< valarray<complex<double> > > &y)
{
	vector<double> sx;
	for(size_t i = 0; i < a_radar.x.size(); i++)
	{
		double val = ((double)1e6/a_radar.fs)*i;
		sx.push_back(val);
	}
#if PLOT
	write_signal(a_radar.x, sx, "chirp.dat");
#endif

//	double PRI = 1.0/PRF;

	//compute unambiguous Doppler interval in m/sec
	//compute unambiguous Dopper range interval in meters
	double vua = (-1) * C*PRF/(2*a_radar.fc);
//	double rmin = C*a_radar.T_out[0]/2;
//	double rmax = C*a_radar.T_out[1]/2;
//	double rua = C/2/PRF;

	//convert range samples to absolute range units
	int My = y.size();
	int Ny = y[0].size();
	vector<double> range;
	for(int i = 0; i < My; i++)
	{
		double val = (double(C)/2.0)* ((double)i*(1.0/a_radar.fs) + a_radar.T_out[0])/1e3;
		range.push_back(val);
	}
	vector<int> pulses;
	for(int i = 0; i < Ny; i++)
	{
		pulses.push_back(i);
	}

	//force oversize FFT, and compute doppler scale factor
	int p = nextpow2(Ny);
	int Lfft = pow(2.0, p+3);
	vector<double> doppler;
	for(int i = 0; i < Lfft; i++)
	{
		double val = ((double)i/(double)Lfft - 0.5) * vua;
		doppler.push_back(val);
	}

	/* dopper process and square-law detect the whole
	 * unprocessed array
	 * using Hamming window throughout*/
#if PLOT
	range_doppler_plot(y, doppler, Lfft, "doppler_range.dat");
#endif

	/* processing the data
	 * 1. pulse compression
	 * 	  using time-domain hamming weighting of the
	 * 	  impulse response for range sidelobe control */
	int Ls = a_radar.x.size();
	vector<double> hw = hamming(Ls);
	valarray<complex<double> > h1(Ls);
	for(int i = 0; i < Ls; i++)
	{
		h1[i] = conj(a_radar.x[Ls-1-i]) * hw[i];
	}
	int Myp = My + Ls -1;
	int Nyp = Ny;
	vector< valarray<complex<double> > > yp;
	initVector(Myp, Nyp, yp);
	conv(h1, y, yp, false);
	vector<double> rangep;
	for(int i = 0; i < Myp; i++)
	{
		double rval = (C/2.0)*((double(i)-(Ls-1))*(1.0/a_radar.fs) + a_radar.T_out[0])/1e3;
		rangep.push_back(rval);
	}
#if PLOT
	range_doppler_plot(yp, doppler, Lfft, "doppler_range_compressed.dat");
#endif

	/* 2. apply three-pulse canceller in each range bin to raw data */
	valarray<complex<double> > h2(3);
	h2[0] = complex<double>(1, 0); h2[1] = complex<double>(-2, 0);
	h2[2] = complex<double>(1, 0);
	vector< valarray<complex<double> > > ypm;
	int Nyp2 = Nyp + h2.size() - 1;
	initVector(Myp, Nyp2, ypm);
	conv(h2, yp, ypm, true);
	vector< valarray<complex<double> > > YPM;
	vector<double> w = hamming(Ny);
	doppler_process(ypm, YPM, w, Lfft);
#if PLOT
	range_doppler_plot(ypm, doppler, Lfft, "doppler_range_canceller.dat");
#endif

	/*3. search for the range bins with targets
	 *   first noncoherently integrate across the frequency bins*/
	int Mypm = YPM.size();
//	int Nypm = YPM[0].size();
	valarray<double> YPMrange(Mypm);
	vector<double> ranges_sort;
	for(int i = 0; i < Mypm; i++)
	{
		double sumr = YPM[i].sum().real();
		YPMrange[i] = sumr;
		ranges_sort.push_back(sumr);
	}
	sort(ranges_sort.begin(), ranges_sort.end());
	/* median of YPMrange */
	int md_ind = (Mypm%2) ? Mypm/2 : (Mypm/2+1);
	double Nrange = ranges_sort[md_ind];
	/* threshold 8x (9DB) above noise estimate */
	double Trange = 8*Nrange;

	/* loop identifies which range bins have local peaks above
	 * the threshold. It also set up a vector */
	vector<pair<int, double> > spikesr;
	for(int i = 2; i < Mypm-1; i++)
	{
		if( (YPMrange[i] > YPMrange[i+1]) && (YPMrange[i]>YPMrange[i-1])
		             && (YPMrange[i] > Trange) )
		{
			spikesr.push_back(make_pair(i, YPMrange[i]));
		}
	}

	vector<vector<double> > targets;
	/*  4. find the Doppler peak(s) for each range bin having a target(s).  Keep
		adjoining Doppler values as well to support subsequent interpolation
	*/
 	int Mspikesr = spikesr.size();
	for(int i = 0; i < Mspikesr; i++)
	{
		vector<vector<double> > spikesd_bin;
		spikesd_bin.clear();
		int rb  = spikesr[i].first;
		for(int k = 0; k < Lfft; k++)
		{
			int km1 = k == 0 ? Lfft-1 : k-1;
			int kp1 = k == Lfft-1? 0 : k+1;

			if( YPM[rb][k].real() > YPM[rb][kp1].real() &&
					YPM[rb][k].real() > YPM[rb][km1].real() &&
					YPM[rb][k].real() > (double)Nrange/2.0 )
			{
				vector<double> spikesd;
				vector<double> obj;
				spikesd.clear();
				obj.clear();
//				cout << k << " " <<YPM[rb][km1].real()<<" "<<YPM[rb][k].real()
//						<< " " << YPM[rb][kp1].real() << endl;
				spikesd.push_back(k);
				spikesd.push_back(YPM[rb][km1].real());
				spikesd.push_back(YPM[rb][k].real());
				spikesd.push_back(YPM[rb][kp1].real());
				double amp, del_k;
				double z1 = sqrt(spikesd[1]);
				double z2 = sqrt(spikesd[2]);
				double z3 = sqrt(spikesd[3]);
				peakinterp(amp, del_k, z1, z2, z3);
				obj.push_back(amp);
				obj.push_back(rangep[rb]);

				double vel = ((spikesd[0] + del_k - 1)/Lfft -0.5)*vua;
				obj.push_back(vel);

				spikesd_bin.push_back(spikesd);
				targets.push_back(obj);
			}
		}
	}

	cout << "detected targets are:" << endl;
	int Mtargets = targets.size();
	int Ntargets = targets[0].size();
	for(int i = 0; i < Mtargets; i++)
	{
		for(int j = 0 ; j < Ntargets; j++)
		{
			cout <<" " << targets[i][j];
		}
		cout << endl;
	}


}
예제 #3
0
void UmlSendSignalAction::write(FileOut & out) {
  write_begin(out, "SendSignalAction");
  write_end(out, TRUE);
  write_signal(out);
  write_close(out);
}