Subversion Repositories svnkaklik

Compare Revisions

Ignore whitespace Rev 642 → Rev 643

/programy/C/ix86/echo/SW/sonar/src/sonar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/programy/C/ix86/echo/SW/sonar/src/sonar.c
20,6 → 20,8
 
#define SOUND_SPEED 340.0 // sound speed in air in metrs per second
#define MAX_RANGE 10.0 // maximal working radius in meters
#define APERTURE 0.2 // distance between microphones
#define MAP_SIZE 100
 
static char *device = "plughw:0,0"; /* playback device */
static snd_pcm_format_t format = SND_PCM_FORMAT_S16; /* sample format */
211,6 → 213,8
double df; //frequency resolution
unsigned int frequency_bins; // number of output frequency bins
 
float density_map[MAP_SIZE][MAP_SIZE]; // Array to store two dimensional image of echos
 
double *inchirp;
fftw_complex *outchirp;
fftw_plan fft_plan_chirp;
359,6 → 363,13
correlationr[n]=abs(r);
}
 
printf("Building echo map\n"); // compute map from left and right correlation data
for (i=0;i < MAP_SIZE; i++)
{
for (j=0;j < MAP_SIZE; j++) density_map[i][j]=correlationl[(int)sqrt(i*i + j*j)]*correlationr[(int)sqrt(APERTURE*APERTURE - 2*APERTURE*i + i*i + j*j)];
}
 
 
printf("Searching echos\n");
r=0;
l=0;
395,6 → 406,12
}
fclose(out);
 
out=fopen("/tmp/plane_cut.txt","w");
for (i=0;i < MAP_SIZE; i++)
{
for (j=0;j < MAP_SIZE; j++) fprintf(out,"%6f", density_map);
}
 
out=fopen("/tmp/chirp.txt","w");
for (i=0; i <= (chirp_size - 1); i++)
{
413,10 → 430,6
}
fclose(out);
 
printf("Echo zacina na: %d vzorku.\n", delayl[1]);
printf("Casove na: %f s\n", ((float)delayl[1]/rate));
printf("vzdalenost: %f m\n", (SOUND_SPEED*(float)delayl[1]/rate));
 
free(correlationl);
free(correlationr);
free(L_signal);