예제 #1
0
Application::Application(unsigned int width, unsigned int height, const std::string& title, unsigned int fps)
	:window_(sf::VideoMode(width, height, 32), title),
	hasFocus_(true),
	state_(),
	console_(){
	window_.setFramerateLimit(fps); 
	try{
		ResourcesIDs::readIDs();
	}
	catch (std::runtime_error& e){
		std::cout << e.what() << std::endl;
	}
	std::unique_ptr<State> beginState(new TitleState(*this));
	state_ = std::move(beginState);
}
void scenarioModelSignalProcessing(std::default_random_engine &gen)
{
	const int N = 500;				//Signals modeling
	const float delta_z = 1;		

	float E_max = 200;			    //Max amplitude
	float sigma = 200;

	dmod::array1d background(N, 100);
	dmod::array1d amplitude(N, 50);
	dmod::array1d frequency(N);

	amplitude = dmod::sum(amplitude, dmod::fixedGaussianAmplitude(E_max, sigma, N/2, N));

	for (int i = 0; i < N; i++)
	{
		frequency[i] = 0.105 - 0.00015*i;
	}

	//Estimated signal
	dmod::array1d phase = dmod::phaseFromFrequency(frequency, 0, delta_z);
	dmod::array1d noise = dmod::createNormalNoise(0, 10, N, gen);
	dmod::array1d signal = dmod::createSignal1D(background, amplitude, phase, noise);
	
	printer::print_signal("MatlabScripts/out.txt", signal);
	printer::print_states("MatlabScripts/data.txt", background, amplitude, frequency, phase);
	std::cout << dmod::snr(signal, noise) << std::endl;

	//Creation of EKF
	Eigen::Vector4d beginState(100, 40, 0.17985, 0);
	Eigen::Matrix4d Rw;
	Rw << 0.1, 0, 0, 0,
		0, 0.15, 0, 0,
		0, 0, 0.0005, 0,
		0, 0, 0, 0.002;
	float Rn = 0.5;
	EKF filter(beginState, Eigen::Matrix4d::Identity(), Rw, Rn);

	std::vector<Eigen::Vector4d> states = filter.estimateAll(signal);
	dmod::array1d restoredSignal = filter.getRestoredSignal(states);

	printer::print_states("MatlabScripts/EKF_data.txt", states);
	printer::print_Kalman_stdev("MatlabScripts/EKF_deviations.txt", states, signal, noise, background, amplitude, frequency, phase, restoredSignal);
}
예제 #3
0
void StateMachineMgr::beginInitState()
{
    emit beginState();
}