Esempio n. 1
0
int main() {
    double buffer[255];
    double fit;
    double *rbuffer;
    int i;

    wb_robot_init();
    reset();

    receiver_enable(rec,32);
    differential_wheels_enable_encoders(64);
    robot_step(64);
    while (1) {
        // Wait for data
        while (receiver_get_queue_length(rec) == 0) {
            robot_step(64);
        }

        rbuffer = (double *)wb_receiver_get_data(rec);

        // Check for pre-programmed avoidance behavior
        if (rbuffer[DATASIZE] == -1.0) {
            fitfunc(gwaypoints,100);
            // Otherwise, run provided controller
        } else {
            fit = fitfunc(rbuffer,rbuffer[DATASIZE]);
            buffer[0] = fit;
            wb_emitter_send(emitter,(void *)buffer,sizeof(double));
        }
        wb_receiver_next_packet(rec);
    }

    return 0;
}
double ChiSquare (double alpha, double beta, double gamma, double norm)
{
	double chisq = 0.;
	double num, y;
	double thBinCenter, phiBinCenter;
	for (int th = 0; th < nThetaBin; th++)
        for (int phi = 0; phi < nPhiBin; phi++)
        {
			thBinCenter = ThBinWidth/2. -1. + th*ThBinWidth;
			phiBinCenter = PhiBinWidth/2. + phi*PhiBinWidth;
			y = IstoData [th][phi];
			num = y - fitfunc(thBinCenter, phiBinCenter, alpha, beta, gamma, norm);
			// ignoro i bin vuoti			
			if (y > 0)
			{chisq = chisq + num*num/y;}
	}
	return chisq;
}
Esempio n. 3
0
//double e[5]={.0};
void fit78Ni(int e570, int e1100, int e1600, int e2100, int e2700, int e2900, int append, char* addname){
  int e[6] = {e570, e1100, e1600, e2100, e2700, e2900} ;
  int g[6] = {1,1,1,1,1,1}; // option which gamma ray to be used
  fitfunc(e, g, append, addname);
}