Subversion Repositories svnkaklik

Compare Revisions

Ignore whitespace Rev 645 → Rev 646

/programy/C/ix86/echo/DOC/plane_cut.nb
10,10 → 10,10
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[ 145, 7]
NotebookDataLength[ 14427, 524]
NotebookOptionsPosition[ 12951, 467]
NotebookOutlinePosition[ 13288, 482]
CellTagsIndexPosition[ 13245, 479]
NotebookDataLength[ 15724, 569]
NotebookOptionsPosition[ 14134, 508]
NotebookOutlinePosition[ 14471, 523]
CellTagsIndexPosition[ 14428, 520]
WindowFrame->Normal*)
 
(* Beginning of Notebook Content *)
463,6 → 463,47
SuperscriptBox["x", "2"], "+",
SuperscriptBox["y", "2"]}]]}], "}"}]}], "}"}]], "Output",
CellChangeTimes->{3.480263765039091*^9}]
}, Open ]],
 
Cell[CellGroupData[{
 
Cell[BoxData[
RowBox[{"FullSimplify", "[",
FractionBox[
SqrtBox[
RowBox[{
RowBox[{"-",
SuperscriptBox["a", "4"]}], "+",
RowBox[{"2", " ",
SuperscriptBox["a", "2"], " ",
SuperscriptBox["b", "2"]}], "-",
SuperscriptBox["b", "4"], "+",
RowBox[{"2", " ",
SuperscriptBox["a", "2"], " ",
SuperscriptBox["r", "2"]}], "+",
RowBox[{"2", " ",
SuperscriptBox["b", "2"], " ",
SuperscriptBox["r", "2"]}], "-",
SuperscriptBox["r", "4"]}]],
RowBox[{"2", " ", "r"}]], "]"}]], "Input",
CellChangeTimes->{{3.480334626025627*^9, 3.480334632855236*^9}, {
3.4803347434308167`*^9, 3.480334744290421*^9}}],
 
Cell[BoxData[
FractionBox[
SqrtBox[
RowBox[{
RowBox[{"-",
RowBox[{"(",
RowBox[{"a", "-", "b", "-", "r"}], ")"}]}], " ",
RowBox[{"(",
RowBox[{"a", "+", "b", "-", "r"}], ")"}], " ",
RowBox[{"(",
RowBox[{"a", "-", "b", "+", "r"}], ")"}], " ",
RowBox[{"(",
RowBox[{"a", "+", "b", "+", "r"}], ")"}]}]],
RowBox[{"2", " ", "r"}]]], "Output",
CellChangeTimes->{3.480334634541192*^9, 3.4803347455989037`*^9}]
}, Open ]]
},
WindowSize->{1434, 824},
525,6 → 566,10
Cell[CellGroupData[{
Cell[12199, 438, 283, 8, 32, "Input"],
Cell[12485, 448, 450, 16, 46, "Output"]
}, Open ]],
Cell[CellGroupData[{
Cell[12972, 469, 684, 20, 66, "Input"],
Cell[13659, 491, 459, 14, 51, "Output"]
}, Open ]]
}
]
/programy/C/ix86/echo/SW/sonar/TODO
0,0 → 1,7
- Device linkig - link capture and playback togeather.
 
-Automatic Gain Control - adjust microphone sensitivity as function of time
 
-Multi frequency chirp - automatic try some chirps to select best spectrum.
 
-Autocalibrating - Geometric and frequency
/programy/C/ix86/echo/SW/sonar/sonar.kdevelop
187,8 → 187,8
<includestyle>3</includestyle>
<root>/usr/share/qt3</root>
<designerintegration>EmbeddedKDevDesigner</designerintegration>
<qmake></qmake>
<designer></designer>
<qmake>/usr/bin/qmake</qmake>
<designer>/usr/bin/designer</designer>
<designerpluginpaths/>
</qt>
<references/>
/programy/C/ix86/echo/SW/sonar/src/.deps/sonar.Po
1,11 → 1,11
sonar.o: sonar.c /usr/include/stdio.h /usr/include/features.h \
/usr/include/bits/predefs.h /usr/include/sys/cdefs.h \
/usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \
/usr/include/gnu/stubs-32.h \
/usr/lib/gcc/i486-linux-gnu/4.4.1/include/stddef.h \
/usr/include/gnu/stubs-64.h \
/usr/lib/gcc/x86_64-linux-gnu/4.4.1/include/stddef.h \
/usr/include/bits/types.h /usr/include/bits/typesizes.h \
/usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \
/usr/lib/gcc/i486-linux-gnu/4.4.1/include/stdarg.h \
/usr/lib/gcc/x86_64-linux-gnu/4.4.1/include/stdarg.h \
/usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
/usr/include/bits/stdio.h /usr/include/bits/stdio2.h \
/usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \
52,9 → 52,9
 
/usr/include/gnu/stubs.h:
 
/usr/include/gnu/stubs-32.h:
/usr/include/gnu/stubs-64.h:
 
/usr/lib/gcc/i486-linux-gnu/4.4.1/include/stddef.h:
/usr/lib/gcc/x86_64-linux-gnu/4.4.1/include/stddef.h:
 
/usr/include/bits/types.h:
 
66,7 → 66,7
 
/usr/include/wchar.h:
 
/usr/lib/gcc/i486-linux-gnu/4.4.1/include/stdarg.h:
/usr/lib/gcc/x86_64-linux-gnu/4.4.1/include/stdarg.h:
 
/usr/include/bits/stdio_lim.h:
 
/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
4,7 → 4,7
// Uses cross-correlation algorithm to find echos
//
// Author: kaklik (kaklik@mlab.cz)
//
//$Id:$
///////////////////////////////////////////////////////////////////////////////////
 
#include <stdio.h>
21,10 → 21,7
#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
 
#define RESOLUTION 100 // resolution 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 */
206,6 → 203,7
snd_pcm_sw_params_t *swparams;
 
long int *correlationl, *correlationr;
float *echo_map;
int *L_signal, *R_signal;
short *chirp, *signal;
float *chirp_spect, *lecho_spect, *recho_spect;
216,8 → 214,6
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;
227,7 → 223,7
snd_pcm_hw_params_alloca(&hwparams);
snd_pcm_sw_params_alloca(&swparams);
 
printf("Simple PC sonar ver. 000000001 starting work.. \n");
printf("Simple PC sonar $Rev:$ starting work.. \n");
 
//open and set playback device
if ((err = snd_pcm_open(&playback_handle, device, SND_PCM_STREAM_PLAYBACK, 0)) < 0)
278,6 → 274,7
R_signal = malloc(period_size * sizeof(int));
chirp = calloc(2*period_size, sizeof(short));
signal = malloc(2*period_size * sizeof(short));
echo_map = malloc(3*period_size * sizeof(float)); // Array to store two dimensional image of echos
 
// generate ping pattern
chirp_size = linear_windowed_chirp(chirp);
366,17 → 363,18
correlationr[n]=abs(r);
}
 
m=0;
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++)
for (i=0;i < period_size; i++)
{
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)];
for(j=0;j < period_size; j++)
{
echo_map[m]=(i*i-j*j+APERTURE*APERTURE)/(2*APERTURE);
echo_map[m+1]=sqrt(-(i-j-APERTURE)*(i+j-APERTURE)*(i-j+APERTURE)*(i+j+APERTURE))/(2*r);
echo_map[m+2]=correlationl[i]*correlationr[j];
m+=3;
}
}
}
 
 
printf("Searching echos\n");
396,7 → 394,7
}
}
 
//spocitejj frekvencni spektrum pro levy kanal
//spocitej frekvencni spektrum pro levy kanal
for(i=delayl[1]; i < delayl[1] + chirp_size; i++) inchirp[i-delayl[1]] = L_signal[i];
fftw_execute(fft_plan_chirp);
for(i=0; i < frequency_bins; i++) lecho_spect[i] = sqrt(outchirp[i][0] * outchirp[i][0] + outchirp[i][1] * outchirp[i][1]);
415,11 → 413,12
}
fclose(out);
 
j=0;
out=fopen("/tmp/plane_cut.txt","w"); // writes plane cut - e.g. density map to file
for (i=0;i < MAP_SIZE; i++)
for (i=0;i < period_size; i++)
{
for (j=0;j < MAP_SIZE; j++) fprintf(out,"%3.2f ", density_map);
fprintf(out,"\n");
fprintf(out,"%3.2f %3.2f %3.2f\n", echo_map[j], echo_map[j+1], echo_map[j+2]);
j+=3;
}
 
out=fopen("/tmp/chirp.txt","w");
446,6 → 445,7
free(R_signal);
free(chirp);
free(signal);
free(echo_map);
 
snd_pcm_close(playback_handle);
snd_pcm_close(capture_handle);