Multi-mobile-phone positioning method based on sound waves

文档序号:189014 发布日期:2021-11-02 浏览:41次 中文

阅读说明:本技术 一种基于声波的多手机定位方法 (Multi-mobile-phone positioning method based on sound waves ) 是由 朱小军 林国瑞 汤继澳 于 2021-07-09 设计创作,主要内容包括:本发明公开了一种基于声波的多手机定位方法。首先,任选一台手机作为服务端,其他为客户端,服务端建立无线热点,客户端自动连接至服务端;其次,服务端从WiFi信道发出启动麦克风录音指令,所有端开始录音,服务端发出一声特定的声波,间隔1s后,对客户端依次发送发声指令,时间间隔为1s,客户端收到发声指令则发出一声特定的声波,同时通过算法实时识别出特定的声波,记录样本索引,所有端发声完毕,把样本索引通过WiFi信道发送到服务端,服务端计算出各端两两之间的距离;最后,对所有距离应用多维尺度变换算法,得到各端的相对位置。本发明精度高,操作简单,无需GPS硬件支持,适用于室内多手机相对位置的快速确定。(The invention discloses a multi-mobile-phone positioning method based on sound waves. Firstly, selecting one mobile phone as a server and the other mobile phones as clients, wherein the server establishes a wireless hotspot, and the clients are automatically connected to the server; secondly, the server side sends a microphone recording starting instruction from a WiFi channel, all the terminals start recording, the server side sends a specific sound wave, after the interval is 1s, the server side sends a sound production instruction to the client side in sequence, the time interval is 1s, the client side sends a specific sound wave after receiving the sound production instruction, meanwhile, the specific sound wave is identified in real time through an algorithm, a sample index is recorded, the sample index is sent to the server side through the WiFi channel after the sound production of all the terminals is finished, and the server side calculates the distance between every two terminals; and finally, applying a multi-dimensional scale transformation algorithm to all the distances to obtain the relative position of each end. The method has high precision and simple operation, does not need GPS hardware support, and is suitable for quickly determining the relative position of a plurality of indoor mobile phones.)

1. A multi-mobile-phone positioning method based on sound waves is characterized by comprising the following steps:

(1) the system comprises a plurality of mobile phones, a server and a client, wherein one mobile phone is selected as the server, the other mobile phones are selected as the client, the server establishes a wireless hotspot, and the client is automatically connected to the server;

(2) the server side sends a microphone recording starting instruction from the WiFi channel, and all the terminals (including the server side) start recording; then the server side sends out a specific sound wave, after 1s, sound production instructions are sent to the client side in sequence, the time interval is 1s, the client side sends out the specific sound wave after receiving the sound production instructions from the WiFi channel, meanwhile, each end identifies the specific sound wave in real time through an algorithm, and records the identified specific sound wave sample index;

(3) each client sends the recorded sample index to the server, and the server calculates the distance between each two terminals through an algorithm after receiving the sample index;

(4) applying a multi-dimensional scale transformation algorithm to all the distances to obtain the relative position of each end; the server broadcasts the obtained relative position to the client through the WiFi channel, and all the mobile phones obtain the relative positions of other mobile phones.

2. A method as claimed in claim 1, wherein said step (1) comprises the steps of:

(11) a plurality of mobile phones, wherein one mobile phone is selected as a server side, and the other mobile phones are client sides;

(12) the server side can manually or automatically open and close the hot spot, acquire all client sides connected to the hot spot networking and update in real time;

(13) the client can automatically start WiFi, circularly connect to a preset hotspot, and obtain an IP address and monitor the connection state after successfully connecting to the hotspot.

3. A sound wave based multi-handset positioning method according to claim 1, wherein the sound samples recorded in step (2) are matched with specific sound waves in real time by the following method: the method comprises the following steps that recorded sound samples take the length of generated specific sound waves as the length of a sliding window, the absolute value of linear correlation degree of covariance is calculated for the sliding window moving backwards one by one, the absolute value is a matching coefficient, and the larger the value is, the more matching is indicated; under the condition of real-time matching, in order to save storage space, the peak value is not directly compared with all historical values of the matching coefficient, only a sample index array IDX with the length of the number of the mobile phone and a matching coefficient peak value array CORR are stored, the initial values of the two array elements are respectively-1 and 0, and the elements in the two arrays are updated by moving a sliding window backwards and iterating.

4. A method as claimed in claim 1, wherein said step (2) comprises the steps of:

(21) the server side sends a microphone recording starting instruction from the WiFi channel, and all the terminals (including the server side) start recording;

(22) setting the amplitude to be 32767, the sampling rate R to be 48000Hz, the starting point of the frequency to be 10000Hz, the end point of the frequency to be 15000Hz, and the duration to be 0.161s, thereby generating a linear chirp sound wave which is taken as a specific sound wave;

(23) the server sends out a specific sound wave, after 1s, sound-producing instructions are sequentially sent to the client according to the sequence of the IP addresses from small to large, and the time interval is 1 s;

(24) the client sends out a specific sound wave when receiving the sounding instruction from the WiFi channel;

(25) recording is started before each end, and the recorded sound samples are matched with specific sound waves while recording, and the indexes of the sound samples which are successfully matched are recorded; each end records sample indexes matched with specific sound waves sent by the mobile phone and other mobile phones in the sound recording to form a sequence.

5. A multi-handset positioning method based on sound waves according to claim 1, wherein the calculation method for calculating the distance between two handsets in step (3) is as follows: d ═ vt/2+ d0D is the distance between mobile phone A and mobile phone B in meters, d0The constant is a constant influenced by the sum of the distance from the microphone of the mobile phone A to the loudspeaker and the distance from the microphone of the sound wave end B to the loudspeaker, and the unit is meter; v is sound velocity, and the propagation in air is 343.4m/s, t | | | Aa-Ab|-|Ba-BbI) R, t is second; a. theaIs an index corresponding to a specific sound wave sent by the mobile phone A in a sample index sequence recorded by the mobile phone A, wherein A isbIs an index corresponding to a specific sound wave emitted by the mobile phone B; b isaIs the index of the specific sound wave sent by the corresponding mobile phone A in the sample index sequence recorded by the mobile phone B, BbIs an index corresponding to a specific sound wave emitted by the mobile phone B; r is the sampling rate, taken at 48000 Hz.

6. A method as claimed in claim 1, wherein said step (3) comprises the steps of:

(31) each end sends the recorded sound wave sample index sequence to a service end from a WiFi channel;

(32) the server side has the sound sample index sequences of all the terminals, and then the distance between every two terminals is calculated according to the method for calculating the distance between the two terminals.

7. A method as claimed in claim 1, wherein said step (4) comprises the steps of:

(41) storing the distance computed by the server as a two-dimensional matrix D, the elements dist of whichi,jThe distance between the mobile phone corresponding to the row serial number i and the mobile phone corresponding to the column serial number j is 0;

(42) applying a multi-dimensional scale transformation algorithm to the two-dimensional matrix, inputting a distance matrix D, the elements dist thereofi,jIs a sample xiTo xjThe distance matrix dimension of the original space is 2, and the low-dimensional space dimension is 2; the algorithm output is a two-dimensional matrix, and each row is a two-dimensional coordinate of one sample;

(43) the server broadcasts the obtained relative position to the client through the WiFi channel, and all the mobile phones obtain the relative positions of other mobile phones.

Technical Field

The invention belongs to the field of indoor positioning, and particularly relates to a multi-mobile-phone positioning method based on sound waves.

Background

Indoor positioning is the process of acquiring the location of a device or user in an indoor environment. Positioning technologies such as RToF (return time of flight), ToF (time of flight), AoA (angle of arrival), and RSSI (received signal strength indication) are widely used. A variety of wireless technologies such as Ultra Wideband (UWB), acoustic, ultrasonic, and Radio Frequency Identification (RFID) may be used for indoor positioning. Ultra-wideband, ultrasonic and radio frequency identification all require proprietary hardware for positioning, are costly and demanding, and are not economical.

Sound wave based localization techniques typically utilize a microphone sensor in the handset to capture the acoustic signal from a sound source or a reference point and estimate the user's position relative to the reference point. The traditional approach to acoustic based localization is to transmit modulated sound signals containing time stamps or other time-related information, which are used by microphone sensors for ToF estimation. Using time stamp information inevitably introduces errors in time recording inconsistencies between different devices.

Disclosure of Invention

The purpose of the invention is as follows: the invention provides a cheap, accurate and quick indoor mobile equipment relative positioning method based on sound waves.

The technical scheme is as follows: the invention relates to a multi-mobile-phone positioning method based on sound waves, which comprises the following steps:

(1) the system comprises a plurality of mobile phones, a server and a client, wherein one mobile phone is selected as the server, the other mobile phones are selected as the client, the server establishes a wireless hotspot, and the client is automatically connected to the server;

(2) the server side sends a microphone recording starting instruction from the WiFi channel, and all the terminals (including the server side) start recording; then the server side sends out a specific sound wave, after 1s, sound production instructions are sent to the client side in sequence, the time interval is 1s, the client side sends out the specific sound wave after receiving the sound production instructions from the WiFi channel, meanwhile, each end identifies the specific sound wave in real time through an algorithm, and records the identified specific sound wave sample index;

(3) each client sends the recorded sample index to the server, and the server calculates the distance between each two terminals through an algorithm after receiving the sample index;

(4) applying a multi-dimensional scale transformation algorithm to all the distances to obtain the relative position of each end; the server broadcasts the obtained relative position to the client through the WiFi channel, and all the mobile phones obtain the relative positions of other mobile phones.

The step (1) comprises the following steps:

(11) a plurality of mobile phones, wherein one mobile phone is selected as a server side, and the other mobile phones are client sides;

(12) the server side can manually or automatically open and close the hot spot, acquire all client sides connected to the hot spot and update the client sides in real time;

(13) the client can automatically start WiFi, circularly connect to a preset hotspot, and obtain an IP address and monitor the connection state after successfully connecting to the hotspot.

The real-time matching method of the sound sample recorded in the step (2) and the specific sound wave comprises the following steps: the method comprises the following steps that recorded sound samples take the length of generated specific sound waves as the length of a sliding window, the absolute value of linear correlation degree of covariance is calculated for the sliding window moving backwards one by one, the absolute value is a matching coefficient, and the larger the value is, the more matching is indicated; under the condition of real-time matching, in order to save storage space, the peak value is not directly compared with all historical values of the matching coefficient, only a sample index array IDX with the length of the number of the mobile phone and a matching coefficient peak value array CORR are stored, the initial values of the two array elements are respectively-1 and 0, and the elements in the two arrays are updated by moving a sliding window backwards and iterating.

The iterative updating method for updating the elements in the two arrays in the step (2) comprises the following steps: if the matching coefficient is less than or equal to 0.1, the sample index is increased by 1, namely the sliding window continues to move backwards, if the matching coefficient is greater than 0.1, loop section processing is carried out, the number of mobile phones is n, i is taken as a loop variable, and loop execution is carried out from 0 to n-1: if the difference between the current sample index and IDX [ i ] is larger than 30000 and IDX [ i ] is smaller than 0, then storing the matching coefficient into CORR [ i ], storing the current sample index into IDX [ i ], and continuously moving the sliding window backwards; if the difference between the current sample index and the IDX [ i ] is less than 30000, judging whether 3 conditions that the IDX [ i ] is greater than 0, the difference between the current sample index and the IDX [ i ] is less than 4000 and the matching coefficient is greater than CORR [ i ] are met simultaneously, if the 3 conditions are met simultaneously, storing the matching coefficient into CORR [ i ], storing the current sample index into the IDX [ i ], and continuously moving the sliding window backwards; if the 3 conditions cannot be simultaneously met, the sliding window continues to move backwards; until the recording is finished, i.e. the sliding window reaches the end of the recorded array of sound samples.

The step (2) comprises the following steps:

(21) the server side sends a microphone recording starting instruction from the WiFi channel, and all the terminals (including the server side) start recording;

(22) setting the amplitude to be 32767, the sampling rate R to be 48000Hz, the starting point of the frequency to be 10000Hz, the end point of the frequency to be 15000Hz, and the duration to be 0.161s, thereby generating a linear chirp sound wave which is taken as a specific sound wave;

(23) the server sends out a specific sound wave, after 1s, sound-producing instructions are sequentially sent to the client according to the sequence of the IP addresses from small to large, and the time interval is 1 s;

(24) the client sends out a specific sound wave when receiving the sounding instruction from the WiFi channel;

(25) recording is started before each end, and the recorded sound samples are matched with specific sound waves while recording, and the indexes of the sound samples which are successfully matched are recorded; each end records sample indexes matched with specific sound waves sent by the mobile phone and other mobile phones in the sound recording to form a sequence.

The calculation method for calculating the distance between the two mobile phones in the step (3) comprises the following steps: d ═ vt/2+ d0D is the distance between mobile phone A and mobile phone B in meters, d0The constant is a constant influenced by the sum of the distance from the microphone of the mobile phone A to the loudspeaker and the distance from the microphone of the sound wave end B to the loudspeaker, and the unit is meter; v is sound velocity, and the propagation in air is 343.4m/s, t | | | Aa-Ab|-|Ba-BbI) R, t is second; a. theaIs an index corresponding to a specific sound wave sent by the mobile phone A in a sample index sequence recorded by the mobile phone A, wherein A isbIs an index corresponding to a specific sound wave emitted by the mobile phone B; b isaIs the index of the specific sound wave sent by the corresponding mobile phone A in the sample index sequence recorded by the mobile phone B, BbIs an index corresponding to a specific sound wave emitted by the mobile phone B; r is the sampling rate, taken at 48000 Hz.

The step (3) comprises the following steps:

(31) each end sends the recorded sound wave sample index sequence to a server;

(32) the server side has the sound sample index sequences of all the terminals, and then the distance between every two terminals is calculated according to the method for calculating the distance between the two terminals.

The step (4) comprises the following steps:

(41) storing the distance computed by the server as a two-dimensional matrix D, the elements dist of whichi,jThe distance between the mobile phone corresponding to the row serial number i and the mobile phone corresponding to the column serial number j is 0;

(42) applying a multi-dimensional scale transformation algorithm to the two-dimensional matrix, inputting a distance matrix D, the elements dist thereofi,jIs a sample xiTo xjThe distance matrix dimension of the original space is 2, and the low-dimensional space dimension is 2; the algorithm output is a two-dimensional matrix, with each row being the two-dimensional coordinates of one sample.

(43) The server broadcasts the obtained relative position to the client through the WiFi channel, and all the mobile phones obtain the relative positions of other mobile phones.

Has the advantages that: compared with the prior art, the invention has the beneficial effects that: 1. without additional infrastructure, the hardware conditions on the handset are fully applied using acoustic and wireless technologies: a microphone and speaker and a WiFi module; 2. the real-time acoustic wave matching algorithm is adopted, so that the program space overhead and time overhead are saved, and the efficiency is improved.

Drawings

FIG. 1 is a flow chart of the present invention;

FIG. 2 is a schematic diagram of a mobile phone networking of the present invention;

FIG. 3 is a schematic diagram of a process for generating a mobile phone sound according to the present invention;

FIG. 4 is a diagram of a coordinate system of a handset in accordance with the present invention;

fig. 5 shows the actual position of the mobile phone and the calculated position of the mobile phone according to the present invention.

Detailed Description

The present invention is described in further detail below with reference to the attached drawing figures.

As shown in fig. 1, the present invention mainly comprises the following steps:

1. a preparation stage: any one of the mobile phones is selected as a server, the other mobile phones are selected as clients, the wireless hotspots are established at the server, and the clients are automatically connected to the server, as shown in fig. 2.

The server side can manually or automatically open and close the hot spot, acquire all client sides connected to the hot spot and update the client sides in real time; the client can automatically start WiFi, circularly connect to a preset hotspot, and obtain an IP address and monitor the connection state after successfully connecting to the hotspot.

A specific implementation scheme based on android is as follows:

(1) the server side sends the implicit broadcast intention to the broadcast receiver through a sendImplicitBroadcast () method;

(2) registering a broadcast receiver in android manifest.xml, monitoring a self-defined broadcast intention by using the registered broadcast receiver, and starting to execute a callback function once the intention is intercepted, so as to realize the operation of opening or closing an AP hotspot;

(3) the client acquires and checks the SSID to be connected, network connection configuration is completed through the WifiConfiguration, and network connection is realized through the WifiManager;

(4) and finally, a network ConnectChangedReceiver broadcast receiver is created to monitor the change of the WiFi connection state, if the connection is interrupted or fails, reconnection is carried out, and the allocated IP and the connection state are dynamically displayed through the monitored change of the connection state.

2. And (3) playing and recording: as shown in fig. 3, the service end sends a microphone recording start instruction from the WiFi channel, and all the terminals (including the service end) start recording; and then the server sends out a specific sound wave, after 1s, the server sends out sound-producing instructions to the client in sequence from small to large according to the IP address, the time interval is 1s, the client sends out the specific sound wave when receiving the sound-producing instructions from the WiFi channel, meanwhile, the specific sound wave is identified in real time through an algorithm, and the identified specific sound wave sample index is recorded.

Take one embodiment of the present invention as an example. As shown in fig. 4, there are 4 smart phones, 4 points form a square with a side length of 1.5 m, and the correspondence between the phone numbers and the coordinates is shown in table 1.

Table 1 mobile phone number information table

Numbering 0 1 2 3
Name of mobile phone Red rice NOTE9 Nut 3 Millet 5 Red rice S2
Coordinates of the object (0,1.5) (1.5,1.5) (1.5,0) (0,0)
IP 192.168.0.104 192.168.0.105 192.168.0.108 192.168.0.106

The server side sends a microphone recording starting instruction from the WiFi channel, and all the terminals (including the server side) start recording; assuming that the amplitude is 32767, the sampling rate R is 48000Hz, the frequency start point is 10000Hz, the frequency end point is 15000Hz, and the duration is 0.161s, a linear chirp sound wave is generated therefrom as a specific sound wave.

The server side sends out a specific sound wave, after 1s, sound production instructions are sequentially sent to the client side according to the sequence of the IP addresses from small to large, and the time interval is 1 s.

The client sends out a specific sound wave when receiving the sounding instruction from the WiFi channel;

and starting recording before each end, matching the recorded sound sample with a specific sound wave while recording, and recording the index of the sound sample successfully matched.

The method comprises the following steps that recorded sound samples take the length of generated specific sound waves as the length of a sliding window, the absolute value of linear correlation degree of covariance is calculated for the sliding window moving backwards one by one, the absolute value is a matching coefficient, and the larger the value is, the more matching is indicated; under the condition of real-time matching, in order to save storage space, the peak value is not directly compared with all historical values of the matching coefficient, only a sample index array IDX with the length of the number of the mobile phone and a matching coefficient peak value array CORR are stored, the initial values of the two array elements are respectively-1 and 0, and the elements in the two arrays are updated by moving a sliding window backwards and iterating.

If the matching coefficient is less than or equal to 0.1, the sample index is increased by 1, namely the sliding window continues to move backwards, if the matching coefficient is greater than 0.1, loop section processing is carried out, the number of mobile phones is n, i is taken as a loop variable, and loop execution is carried out from 0 to n-1: if the difference between the current sample index and IDX [ i ] is larger than 30000 and IDX [ i ] is smaller than 0, then storing the matching coefficient into CORR [ i ], storing the current sample index into IDX [ i ], and continuously moving the sliding window backwards; if the difference between the current sample index and the IDX [ i ] is less than 30000, judging whether 3 conditions that the IDX [ i ] is greater than 0, the difference between the current sample index and the IDX [ i ] is less than 4000 and the matching coefficient is greater than CORR [ i ] are met simultaneously, if the 3 conditions are met simultaneously, storing the matching coefficient into CORR [ i ], storing the current sample index into the IDX [ i ], and continuously moving the sliding window backwards; if the 3 conditions cannot be simultaneously met, the sliding window continues to move backwards; until the recording is finished, i.e. the sliding window reaches the end of the recorded array of sound samples.

Each end records sample indexes matched with specific sound waves sent by the mobile phone and other mobile phones in the sound recording to form a sequence.

The sample index sequences obtained at each end are shown in table 2, the same row is recorded by the same mobile phone, and the same column is the same infrasonic wave.

Table 2 sample index table

3. And a distance calculating stage: and each client sends the recorded sample index to the server, and the server calculates the distance between each two terminals through an algorithm after receiving the sample index.

Calculating the distance between the two ends: d ═ vt/2+ d0D is the distance between mobile phone A and mobile phone B in meters, d0The constant is a constant influenced by the sum of the distance from the microphone of the mobile phone A to the loudspeaker and the distance from the microphone of the sound wave end B to the loudspeaker, and the unit is meter; v is sound velocity, and the propagation in air is 343.4m/s, t | | | Aa-Ab|-|Ba-BbI) R, t is second; a. theaIs an index corresponding to a specific sound wave sent by the mobile phone A in a sample index sequence recorded by the mobile phone A, wherein A isbIs an index corresponding to a specific sound wave emitted by the mobile phone B; b isaIs the index of the specific sound wave sent by the corresponding mobile phone A in the sample index sequence recorded by the mobile phone B, BbIs an index corresponding to a specific sound wave emitted by the mobile phone B; r is the sampling rate, taken at 48000 Hz.

d0When the value is d, the actual distance between every two mobile phones is measured by adopting the formula d0Given d-vt/2, table 3 gives the constant d between each pair0And (4) matrix.

Table 3 handset pairing constant table (rice)

Red rice NOTE9 Nut 3 Millet 5 Red rice S2
Red rice NOTE9 0 0.3 0.3 -1.7
Nut 3 0.3 0 -0.12 0
Millet 5 0.3 -0.12 0 0
Red rice S2 -1.7 0 0 0

Each end sends the recorded sound wave sample index sequence to a server;

the server side has the sound sample index sequences of all the terminals, and then the distance between every two terminals is calculated according to the method for calculating the distance between the two terminals.

According to the calculation method, a distance matrix D between the two mobile phones is obtained, as shown in table 4.

Watch 4 Mobile phone distance meter (rice)

Red rice NOTE9 Nut 3 Red rice S2 Millet 5
Red rice NOTE9 0 1.47 1.47 2.12
Nut 3 1.47 0 1.95 1.67
Red rice S2 1.47 1.95 0 1.28
Millet 5 2.12 1.67 1.28 0

4. And (3) a relative positioning stage: storing the distance computed by the server as a two-dimensional matrix D, the elements dist of whichi,jThe distance between the mobile phone corresponding to the row serial number i and the mobile phone corresponding to the column serial number j is 0;

applying a multi-dimensional scale transformation algorithm to the two-dimensional matrix:

(1) input distance matrix D, its elements disti,jIs a sample xiTo xjThe distance matrix dimension of the original space is 2, and the low-dimensional space dimension is 2;

(2) the output of the algorithm is a two-dimensional matrix MDS, each row is a low-dimensional coordinate of one sample, and the dimension of the low-dimensional space is 2, so that each row of the two-dimensional matrix is a two-dimensional coordinate of one sample;

the euclidean distance between the obtained point coordinate vector and the actual coordinate vector is 0.30.

The actual positions of the points are separated from the position obtained by the algorithm by the distance shown in table 5. As shown in fig. 5, the position obtained by the algorithm has a very small error from the actual position.

Table 5 mobile phone coordinate table (rice) obtained by multi-dimensional scale transformation

Numbering 0 1 2 3
Name of mobile phone Red rice NOTE9 Nut 3 Millet 5 Red rice S2
Estimating coordinates (0.00,1.51) (1.45,1.54) (1.40,-0.11) (0.15,-0.06)
Error of the measurement 0.01 0.06 0.15 0.16

The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

12页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:基于重构正则化矩阵的奇异值分解微振动振源定位方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!