petotamas / pyArgus

Antenna array signal processing library implemented in python
https://www.tamaspeto.com/pyargus
GNU General Public License v3.0
164 stars 60 forks source link

AoA Music #3

Open tweigel-dev opened 3 years ago

tweigel-dev commented 3 years ago

Hay, i try to implement an AoA with my CSI data from intel5300. Therefore i tried to use your music implementation. i have an csi vector with 3 antennas and 30 subcarrier. If i pass the np.matrix (3,30) through the music function (directionEstimation.py line 317) i get the error:

""ERROR: Correlation matrix is not quadratic"

But why it should be? I didn`t found anything at the MUSIC paper saying that it should be quadratic. Did i misunderstand MUSIC or is there a mistake at the code?

petotamas commented 3 years ago

All the implemented DoA estimation algorithms work with the spatial correlation matrix, which is quadratic. You can calcaulte the spatial correlation matrix with the use of the corr_matrix_estimate() function from your measured data matrix. Note that, this function expects a signal matrix which has a shape of N x M, where N is the number of signal samples and M denotes the number antenna channels. Therefore, you have to transpose your 3x30 mesurement data matrix before you call the correlation matrix estimation. The shape of the output matrix (the correlation matrix) should be 3 x 3.

You can find more information regarding to the usage of the above functions in the documentation: https://github.com/petotamas/pyArgus/blob/master/docs/nb_direction_of_arrival_estimaton.ipynb

tweigel-dev commented 3 years ago

Thanks for the quick response! Now i getting some AoA output by MUSIC but it doesn't work correctly :(. I measure about 30 csi matrix with the same angle to estimate the angle better then with one measurement. now i noticed that each MUSIC result shows his own result. with nearly no correlation to the real angle.

i played around with the parameters. I found out that d has a huge impact to the results. my antennas are 62mm apart of each other. The wavelength of wifi is about 12.3 cm. that means i should have d = 0.5 isn't it? and the output of MUSIC describes tetha, isn't it? why the output is from 0 to 180 and not from -90(270) to 90?

my averaged results of 0°,45° and 90° with 2 measure processes in 2 different environments each of them with about 30 csi matrices:

0° ~45° 90°

petotamas commented 3 years ago

Setting of the proper antenna arangemenet parameters is mandatory for the correct operation.

The 'd' parameter specifies the interelement spacing in case of Uniform Linear Array antenna configuration. This parameter is normalized to the wavelength, so if you are working at 2.4GHz, the free space wavelength is 12.5 cm, and if you placed your 3 antennas in a row 6.25 cm apart from each other than you have to set 'd' to 0.5.

Also note that you have to calibrate your antenna system, and of course your 3 channel data acquisition system must be coherent.

tweigel-dev commented 3 years ago

What did you mean with calibration ?

Thanks for your help!

petotamas commented 3 years ago

Every multichannel receiver hardware has inherent amplitude and phase distortions. This is because the transfer characteritics of the individual receiver channels are different, thus the phase delay information is deteriorated during the reception. This error must be calibared and corrigated prior to the use of these algorithms.

petotamas commented 3 years ago

Since the originally raised problem has resolved, I am considering this issue to be solved.

tweigel-dev commented 3 years ago

I still run into problems when trying to determine the entrance angle. @petotamas

Every multichannel receiver hardware has inherent amplitude and phase distortions. This is because the transfer characteritics of the individual receiver channels are different, thus the phase delay information is deteriorated during the reception. This error must be calibared and corrigated prior to the use of these algorithms.

did you mean, that I have to normalize the CSI amplitude before using corr_matrix_estimate() ?

Here is a plot of the amplitude of 10 sniffs with 1x3x30 CSI shape image

All 3 antennas notice the same Signal with nearly the same amplitude. This shows us that the signal receives with theta 0° , isn't it ? But if I use MUSIC to estimate DoA I get the following result : image

Thanks for your help in advance!

petotamas commented 3 years ago

You have nearly identical amplitude on all the channels, but you have to calibrate the phases as well. This is quite crucial to the correct operation. Could you please plot the phases of the subcarriers as well for all the channels? In case the signal of interest is at boresight, you should see no relative phase differences. Another corner case that you can easily use to verify the correct operation is when the incident ange is 60 deg. In this case you should see 90deg relative phase diffs between the channels (ULA, element distance is 0.5 wavelength)

tweigel-dev commented 3 years ago

Thanks for your support!

Phase RESULTS ## phase of 1 CSI-entry with theta 0° ![image](https://user-images.githubusercontent.com/56434333/103456476-19e4f300-4cf7-11eb-9553-0f27f5592234.png) ## phase of 10 CSI-entries with theta 0° ![image](https://user-images.githubusercontent.com/56434333/103456509-603a5200-4cf7-11eb-8d17-0b7cdb1931a1.png)

It seems to be more or less the same phase, but each CSI has captured a different face from the frame.

By the way: did you have a hint, why the csi get a kink at the middle?

tweigel-dev commented 3 years ago

By the way: I get very different results of MUSIC angles if I change the distance of the capture environment. even though I am aware of the Fresnel Zone and use a LOS environment.

petotamas commented 3 years ago

Based on your results I think the phase differences between the channels are reasonably high and it even changes from sub-carrier to sub-carrier. A more informative plot would be to plot the phase differences of the channels only, unwrap the phases and convert it to deg.

I have the following ideas to check:

I would highly recommend to generate simulated signals as well so you can test you DSP and the correct operation of the PyArgus library as well.

By the way: did you have a hint, why the csi get a kink at the middle? Since it is in the middle, I would think it is related to the DC component of your baseband signal.

tweigel-dev commented 3 years ago

Thanks for your great help and support!

plot would be to plot the phase differences of the channels only

You are right there is a phase diff. and it seems to be nearly constant at at fixed distance! But It isn't constant at different distances. And a few times I get some unclean results. I use (phase_rx_n - phase_rx_0 )mod 2pi.

Phase Diff RESULTS

### 5m ![image](https://user-images.githubusercontent.com/56434333/103532305-4cbff000-4e8b-11eb-9265-b81d2e303caf.png) ### 10m ![image](https://user-images.githubusercontent.com/56434333/103532469-94df1280-4e8b-11eb-8723-1ac5b0e3c507.png) ### 20 m ![image](https://user-images.githubusercontent.com/56434333/103532567-c7890b00-4e8b-11eb-84e7-44800748d782.png) ### 30m ![image](https://user-images.githubusercontent.com/56434333/103532640-e8e9f700-4e8b-11eb-8793-25569887c0e7.png) ### 50m ![image](https://user-images.githubusercontent.com/56434333/103532686-f99a6d00-4e8b-11eb-84e4-36ae63d8ac3b.png)

Interesting is now, if the phase diff is semi constant, how I can be sure that the Phase shift is caused by theta != 0°

I guess you perform some sort of DSP on the captured time domain signal prior to the AoA estimation, as you somehow transform the signal into the sub-carrier domain. You have to make sure that you perform the same operations on all the channels. You are not compensating channel related errors differently. (such as frequency offset compenstation, carrier phase compensation, channel equalization in case it is on OFDM type of signal, passing the signal of the channels on adaptive filters independently or passing them on different filters, and so on.. )

my current CSI gather environment is the the Wifi Chip intel 5300 and I am using the LinuxCSI tool by halerin. This makes the Channel state Information (CSI) available. CSI contains the amplitude and phase of the received layer 2 wifi Frame per antenna. I think it is not possible to send a valid CW to a Wifi NIC, isn't it ? also I have no influence to the subcarrier transformation but I think they are processed equally.

Are you performing this measurement indoor or outdoor?

Currently my Tests are outside to minimize reflection and scattering.