Subversion Repositories svnkaklik

Compare Revisions

Ignore whitespace Rev 643 → Rev 644

/programy/C/ix86/echo/SW/sonar/src/sonar.c
23,6 → 23,8
#define APERTURE 0.2 // distance between microphones
#define MAP_SIZE 100
 
#define RESOLUTION 1/100 // resolution in metres per map pixel
 
static char *device = "plughw:0,0"; /* playback device */
static snd_pcm_format_t format = SND_PCM_FORMAT_S16; /* sample format */
static unsigned int rate = 96000; /* stream rate */
207,6 → 209,7
int *L_signal, *R_signal;
short *chirp, *signal;
float *chirp_spect, *lecho_spect, *recho_spect;
float x,y;
unsigned int i,j,m,n;
unsigned int delayl[10],delayr[10]; //store delay of signifed correlation
long int l,r; // store correlation at strict time
366,7 → 369,13
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)];
 
for (j=0;j < MAP_SIZE; j++)
{
x=(float)i*RESOLUTION; y=(float)j*RESOLUTION; //transofm integger index of array to float with appproopirate resolution
 
density_map[i][j]=(float)correlationl[(int)sqrt(x*x + y*y)]*correlationr[(int)sqrt(APERTURE*APERTURE - 2*APERTURE*x + x*x + y*y)];
}
}
 
 
406,10 → 415,11
}
fclose(out);
 
out=fopen("/tmp/plane_cut.txt","w");
out=fopen("/tmp/plane_cut.txt","w"); // writes plane cut - e.g. density map to file
for (i=0;i < MAP_SIZE; i++)
{
for (j=0;j < MAP_SIZE; j++) fprintf(out,"%6f", density_map);
for (j=0;j < MAP_SIZE; j++) fprintf(out,"%3.2f ", density_map);
fprintf(out,"\n");
}
 
out=fopen("/tmp/chirp.txt","w");