Sunteți pe pagina 1din 8

First Person Shooter with a Real Gun Waterloo Labs August 3, 2009 PROJECT OVERVIEW The goal of this

project is to be able to triangulate the position of an impact on a wall and then generate a mouse click that corresponds to this location. A computer screen can then be projected onto the wall and a projected action can be performed - seeming as if the impact acts as a mouse click on the projected surface. This can then be extrapolated into use in any software, in our case a flash version of the popular first person shooter game, Half-life. We offer two math routes towards calculating the location of the impact with the wall: a simpler and faster method, albeit less accurate, and a more complicated and more accurate method. In presenting our project we chose to use the simpler method to make the project more accessible to all hobbyists. The simpler method will use four accelerometers placed in a square, and the more advanced method will use three accelerometers placed in an inverted triangle. SYSTEM OVERVIEW Three (or four) accelerometers are put on the wall in an inverted triangle pattern (or square) and connected to a USB-4432 for simultaneous data acquisition. The data from the three accelerometers is then used to calculate the position of the hit and a corresponding mouse click is generated by calling a windows .dll. The computer screen is then projected onto the wall. To perform the calculations and Data Acquisition we used LabVIEW software, which is made by the same people as the Data Acquistion card we used. LabVIEW is a graphical design programming language, as opposed to a text based language, used by shows such as Mythbusters and Deadliest Warrior. 3 or 4 - 50 mv/g accelerometers NI USB-4432 LabVIEW Computer Projector Stuff to throw/shoot at the wall

CALCULATIONS ADVANCED Setup Before we can dive into the calculations we need to understand the overall system of the accelerometers and how they work together. It is important to note that the Data Acquistion device we are using allows for simultaneous sampling of all three accelerometers, allowing us to see the signal from each accelerometer at the same time for better comparison.

In Figure 1 we can see the accelerometers are placed onto the wall in an inverted triangle pattern with the top right accelerometer being referred to as A and the naming convention following in a clockwise pattern. This shape is used because it corresponds to the standard coordinate system of computer screen with (0,0) in the top left and the positive X-axis and positive Y-axis extending right and down respectively.

FIGURE 1. The layout of the accelerometers on the wall with Accelerometer A corresponding to (0,0) When an object hits the wall the vibration signal propogates out from impact point at the speed of sound towards each accelerometer. Because the speed of sound is constant in the wall material the impact signal will reach each accelerometer at a different time, proportional to how close the accelerometers are to the impact point, as shown in Figures 2 and 3.

FIGURE 2. When an object hits the wall, the impact signal is sent through the wall towards each accelerometer at a constant speed. The time for the signal to reach each accelerometer is Tx.

FIGURE 3. The constant speed of the impact in all directions means the same signal will reach each accelerometer in a different amount of time, referred to as Tx.

Once we have these impact signals as recorded by the accelerometers there are two types of math that can be done to triangulate the position of the projectile or wall hit. A simpler version is first presented as it is more accessible and easier to implement. The second method is then presented for the more advanced hobbyist. Phase Delay The first part of the calculation is to determine the delay, , between each accelerometer relative to each other. We will use the phase correlation method which makes use of fast fourier transforms (FFTs) to calculate the transitive movement between two waveforms. The FFT of both signals is first taken. The complex conjugate of the second FFT is then taken and multiplied by the FFT of the first signal. The Inverse FFT is taken of this multiplied result to yield the cross correlation. The maximum value of this cross correlation will occur at the delay between the two signals. This method is demonstrated in Equation 1. Equation 1 Location Calculation The distance from the point of impact to any accelerometer can be given in terms of its horizontal and vertical components by the Pythagorean Theorem as seen in Figure 4 and Equation 2.

FIGURE 4. The distance from the impact to accelerometer A can be given in terms of its horizontal and vertical components.

Equation 2 The travel time, Ta, of the impact pulse can then be determined by dividing the distance traveled by the propogation rate of the impact signal in the wall material as shown in Equation 3.

Equation 3

If we do this for all accelerometers and put the coordinate system in relation to Accelerometer A we can have similar equations describing the time taken for the signal to travel to the other two accelerometers. The only problem with this is that we do not know the time traveled. We do however know the difference between these travel times and we can use that knowledge to generate Equations 4, and 5. Equation 4 Equation 5 By solving this system of nonlinear equations for x and y, you can determine the location of the impact. CALCULATIONS SIMPLIFIED Setup To simplify the calculations we will use four accelerometers placed in a square pattern on the wall. With this simplified math we will only be using ratios and so we no longer need to know the distances between the accelerometers as long as the vertical legs are equal to each other and the horizontal legs are equal to each other. We will label the top left accelerometer as A and continue the naming convention in a clockwise fashion. The (0,0) coordinate of this system will be the exact center of the accelerometer square. Reference Figure 5.

FIGURE 5. Layout of accelerometers for the simple math. When an object impacts the wall it will operate the same as the complex system but propogate out towards the four accelerometers instead of three. Phase Delay Because the same signal is seen by all accelerometers we can look for a common reference point in the signal from each accelerometer and then timestamp it. We can then compare the timestamps from accelerometers to get our phase delay between accelerometers. In our case we looked for the first instance of the signal rising above 2 g and counted that as our start time (Figure 6).

FIGURE 6. We can find the start time of the signal by looking for the reading from the accelerometer to rise above 2 g. We then compare the start times of all signals and just subtract them from each other to calculate our phase delay (Figure 7). We will need the phase delay between the following accelerometer combinations, BA, BC, CD, and AD.

FIGURE 7. The phase delay between signal can be calculated by subtracting the start times from each other. Location Calculation To better determine the location and eliminate some of the error we are taking double Y axis measurements (BC and AD) and double X axis measurements (BA and CD) and averaging them together to get one time delay for the X axis and one for the Y axis. If instead of looking at our coordinate system in units of distance we look at in terms of seconds we can treat the phase delay as our impact location. For instance, if the impact were to strike the center of the board the impact signal would reach all accelerometers at the same time. The X axis delay would then measure zero because the start times of the signals would be the same, as would the Y axis. If instead the impact occurs at some distance away from the center of the square we will assume that the time delay will accurately reflect this location. The pitfall in this math is that the ratio does not perfectly define the location. If, for instance we impact at exactly accelerometer B the time delay between BA will be the exact length of the X-axis and work fine. If however you hit directly below B, even though the X position is the same it will no longer generate the same time delay between the BA. This is because the triangulation is a nonlinear system meaning as you move off the direct axis towards infinity the location will move towards zero.

FIGURE 8. Pitfalls of linear assumptions about the system. Impact 1 will register correctly, but Impact 2 could appear as Impact 3. In Figure 8 Impact 1 will generate the maximum phase delay possible along BA giving the correct X axis location. However Impact 2, though at the same x-axis position will appear as if it struck at Impact 3 because of the additional time needed for the Impact signal to also travel to Accelerometer B. As the impacts move off towards infinity the time for the impact signal to travel to the two accelerometers becomes equal, causing the x-axis location to appear as zero. To compensate for this we can limit the impact to a small area, thus reducing the offset error from the linear assumption.

S-ar putea să vă placă și