Augmented Reality Game Control of Handy Devices Using a Triaxial Accelerometer and an Electronic Compass

Video games created for virtual reality (VR) and augmented reality (AR) have made a major leap forward in recent years. In fact, VR has had an exciting start, and VR gaming has already seen its first megahit. In this research, we designed an AR game for handy devices. We adopted three strategies to make the game more exciting: (1) A video camera screen is used as the background of the game. (2) A player device is used to turn and change the game environment to the left or right. (3) A player device is inclined to watch the game objects in the game world from different angles. From the simulations, it is demonstrated that our scheme is an effective method of using an accelerometer and an electronic compass to control the game on the handy device.


Introduction
Nowadays, we can see people playing games everywhere because human life is already associated with games.Owing to technological advancements, several creative games have been developed, such as TV games, cellphone games, computer games, and professional games.In particular, cellphone games have become important because many people use cellphones and can play games anywhere and anytime.
Owing to the improvement and upgrade of hardware devices, the processors of handy devices all have a multiprocessor architecture.These processors have powerful processing ability and can handle a large work load.Therefore, they work well with augmented reality (AR) game playing.Some applications of these games can be found in Fruit Ninja. (1)n general, all handy devices have several sensors, which are used to manipulate the games; for example, the accelerometer is frequently used in Temple Run. (2)As for the triaxial gyro application, it can be seen in Gun Range. (3)he triaxial gyro is always used in Gun Range (3) and is very popular; it is a well-designed game played on handy devices.In addition, Life is Crime (4) is another type of game that is associated with the global positioning system (GPS) operated by handy devices.Chu et al. (5) presented a game interface using digital textile sensors, accelerometers, and gyroscopic techniques.In their study, a pressure sensor is linked to the accelerometer, and the gyroscope is applied to a dance game to detect the player's movements through conductive, washable fabrics.This fantastic design provides a mixed reality game interface where users can play by using 3 modes with increasing sophistication.
Joselli and Clua (6) proposed a framework for touch or accelerometer gesture recognition for cell phone games.They presented an advanced framework for touch or accelerometer gesture detection that uses a hidden Markov model for the recognition of the gestures.The framework can be developed for mobile applications by the use of gestures.Nils and Didier (7) presented the idea of cognitive AR, which radically modifies existing methods on AR-based support systems and raises a fundamentally new model exploiting former visual observation.They also present a complete approach for founding AR content for programmed tasks from video examples along with the details on the presentation of such content at real time.They show that this novel approach, despite its highly challenging aspects, is scalable and valuable from the point of view of feasibility.Related research about AR can be found in Refs.8-11.
Virvou and Katsionis (12) proposed a virtual reality (VR) game for teaching students geography.They described the evaluation experiments conducted including three kinds of students; novice, intermediate and expert game players; in terms of their level of game-playing expertise.The evaluation results showed that the game can improve the scope for usability and likeability.Simultaneously, the educational benefits may be maximized for all categories of students.The evaluations reported that VR games are important educational games about VR itself in Refs.13-15.
The remainder of this paper is organized as follows.Section 2 describes sensor devices.Section 3 shows the system algorithm.Section 4 describes the experimental results.Finally, Sect. 5 presents the conclusions of this study.

Triaxial accelerometer
Triaxial accelerometers, also known as accelerometers, inertial sensors, or gravity sensors (G-sensor), are used to measure physical changes, such as changes in resistance, capacitance, displacement, and stress, and to detect changes over time using a speed sensor, i.e., to detect the extent of change in an acceleration-measuring sensor over a certain time period.The triaxial accelerometer is used to detect changes in these properties by detecting three-dimensional axial acceleration along the X-, Y-, and Z-axes.
Depending on the proportional changes with respect to Newton's second law of motion, the motion of external objects is governed as a direct proportion by their momentum over a unit of time and inversely proportional to their mass.The pertinent formula is F = ma, where F is the net force, m is the mass of the object in kg, and a is acceleration.Speed is the amount of change in the object's position over time.The equations are: where a is acceleration, v is speed, s is the distance moved, and t is time.
If you know the acceleration of an object, you can use it to calculate the amount of displacement of two points.Equation ( 2) is expressed as The basic physical model of an accelerometer is primarily a combination of a spring and a mass.When its displacement is z, the mass M will be affected by the force of inertia and the spring constant K.Moreover, the traction displacement generated corresponds to y, because it changes the amount of displacement corresponding to the distance from the electrodes and the output voltage of the operating circuit.The acceleration is defined by The acceleration of an object is equal to the spring constant multiplied by the amount of displacement divided by the mass of the object expressed in units of m/s 2 .
The triaxial accelerometer VAS340A (31) from Virtus Advanced Sensors (VAS) company is shown in Fig. 1.For the working principle of its Z-axis acceleration sensor when the system is on the Z-axis, the acceleration, mass, and distance from electrodes will increase in accordance with Newton's law of inertia.With mostly upper and lower capacitance detection voltage variations, after calculation, one can obtain the Z-axis acceleration values.Similarly, the X-axis and Y-axis are accelerating, and the spring will be deformed due to the power; by utilizing the piezoresistive effect to calculate the output voltage, it can calculate the increasing magnitude of the acceleration of X and Y.The piezoresistive effect refers to changes in resistance in the material generated by external stress.
The triaxial accelerometer is used in mobile devices, and data along the three axes has the following meaning.For the upright situation, moving up and down changes the Y-axis data, left and right shifts change the X-axis data, and moving back and forth changes the Z-axis data.Figure 2 shows a schematic, and the details can be seen in Table 1. Figure 3 shows the values for an accelerometer when the device is upright.Figure 3

Electronic compass
A compass uses Earth's magnetic field to determine the geomagnetic north-south direction; the use of a magnet as a compass was developed in ancient China.Its development had a significant impact on aspects of navigation, guidance, and other applications.With the same triaxial accelerometer, micro-electromechanical systems (MEMS), a kind of electronic compass (E-compass), are also known as digital compasses.The digital compass outputs a digital signal used for determining the orientation of a load.It measures the current through the voltage variation of the magnetic field to sense Earth's magnetic north, and turns toward it.Electronic  compasses rely on evolving and mature MEMS technology.Through similar production based on semiconductor technology, it is possible to reduce their size and cost.The triaxial accelerometer, a MEMS product, is generally used in various electronic products.Due to its design principles and operating characteristics, it results in a bias caused by an electronic compass susceptible to external interferences with reference to the placement angle problem.The external interference, including the fixed magnetic strength of magnetic objects, such as magnets and magnets of electronic products, or the use of magnetic interference in electronic products or the surrounding environment, affects the accuracy of the electronic compass.
Thus one needs to calculate an interference correction to correct for such external interference.It is common to require the user to draw a figure eight for an electronic compass to detect the maximum and minimum amounts of magnetic values and to enable calibration after computing.Information placement causing direction deviation angles, because the electronic compass is placed in a nonhorizontal state, increases the angle of inclination.This results in an error in the angle of the direction.Therefore, an electronic compass is divided into an electronic compass plane and two, triaxial electronic compass types.A plane electronic compass must ensure the device maintenance level, and the error direction information is easier to produce, but its price is relatively low.A triaxial electronic compass located by a triaxial accelerometer for auxiliary correction purposes can be determined in accordance with tilt compensation values.
Electronic compass construction principles are based on the Hall effect, and the flux gate can be described as follows.
(A) Based on the Hall effect of an electronic compass: The current is through solid conductive material, when placed in a magnetic field, and its charge inside the conductor will collect on both sides of the conductor so that the positive and negative charges on both sides of the conductor produce a potential difference and an electric field; this is called the Hall effect.By detecting the Hall voltage, the compass can measure Earth's magnetic field.Commonly, it is used in two-dimensional positioning.The advantage for the interior design is that there is no moving mechanism, so it is more durable.(B) Based on the electron flux gate of a compass: the flux-gate magnetometer is of the vector type, and the basic design is composed of a core and pickup coil excitation coils, where the magnetic field pickup coil via a core influence causes magnetic flux changes in the induced voltage.These devices have a long history and are widely used.They have become the main magnetic detection method.In Honeywell's electronic compass, for example, the internal structure is an anisotropic magneto resistor (AMR).It is placed on a nickel-iron alloy thinfilm resistor bridge formed on the silicon crystal.The measured magnetic field strength and a single axial direction of the three axes can be positioned and are suitable for detecting subtle magnetic inductance.Figure 5 shows the chip of an electronic compass.

AR Game Control Algorithm
For an AR game control, several stages are needed to achieve the goal.A system flow chart is shown in Fig. 6 and briefly introduced below.First, we make a story to be used as the content of the game.It is necessary for any game and if it includes a surprise, it will be good.A game needs lots of objects to play roles in the story.Photoshop is a suitable tool for this task.It can be used to easily develop all kinds of objects regardless of their complexity.Certainly, 3D modules are also important for game design.Here, we use the 3D max software to complete the task.3D modules can achieve special effects easily.First, the materials of the game are prepared.Next, it is important to find a game development system; it needs to supply all kinds of tools and offer a friendly operating environment.After a survey, Unity was selected to do the job because it has superior features.However, it must be convenient to change the views in a game in all orientations, like left and right sides or up and down angles.In this research, we selected an electronic compass to change the left or right side control for the game player.On the other hand, we choose an accelerometer to control the view of the game objects and to change their up or down angles.Finally, an intelligent cell phone is used as a platform for the player because it is a convenient and handy device.The details are described as follows.

A. Game perspective
The principle of AR screen presentation is divided into two main parts: 1. Capture real-world images with a rear-view camera on your mobile device.Owing to the ratio of screen sizes captured by a camera in different devices, they are not necessarily the same as the device's screen size, so they must be cropped.After cropping, the screen is used as the background for the game world.2. The virtual information part of the game world is a variety of objects, such as buildings and enemies, which will be generated in the game world in the camera's field of vision and the middle area of real-world pictures, so that both virtual information and a real screen are simultaneously presented in the game screen.

B. Interaction of game players with game objects
The player interacts with the game objects using the up/down and left/right rotation of the mobile device.When the player turns the mobile device left or right, the player can watch the game object in different directions in the game from the value of the electronic compass, which also acts as the player's direction in the game world.
When the player moves the mobile device up or down, the acceleration sensor of the three axes determines the gesture of the mobile devices, i.e., up and down to adjust camera angles of the game world.It allows players through the screen to see the objects and perspective at different angles in the game world.Sensors and Materials, Vol. 29, No. 6 (2017) 733

Electronic compass and left-right view design
In this study, all viewing angles can be adjusted in the autologous coordinate system (local).When the mobile device rotates, the system automatically calculates the value of the electronic compass, and the camera in the game along the Y-axis of rotation changes the direction of viewing game content.Figure 7 shows the flow chart of the left and right control of game objects by the player.
The game begins with an initial calibration of the electronic compass to avoid interference or noise, which results in a poor gaming experience.Then, the electronic compass obtains the initial value of the angle and lets the game world camera rotate along the Y-axis from 0° to the initial angle.
Next, it determines whether the device is rotated left or right.The current angle of the camera in the game world is a, the angle of the electronic compass is b, and the angle before the last movement is c.As the electronic compass outputs the value of a floating-point from 1 to 359°, and if the absolute difference between a and b is greater than 1°, the a value is set to b, and the c value is set to a. Therefore, the game world camera rotates to the current orientation of the electronic compass and records the original angle.However, if the absolute value of the difference between a and b is less than 1°, or if the b value is equal to c or equal to the value of the c plus or minus 0.5°, then it is defined as jitter.To avoid viewing discomfort caused by hand-held shaking noise from the player, the camera does not change the world of the game angle.
After this process, we can accurately determine if the player operates the device by turning left or right to change the orientation.Figure 8 shows the record for the test process.It indicates how to view the left and right sides of the game buildings.Figures 8(a) and 8(b) show the left and right side views of the game, respectively.

Triaxial acceleration and up-down view design
In this study, the design of our view plays a role in the upper and lower viewing angles described below: when the player moves the mobile device up and down, the value of the acceleration sensor determines the current mobile device tilting posture and the amount of up and down motion.After calculation, the game world camera records the value to change the up and down coordinates of the X-axis rotation, which is used to change the viewing angle of the game world.Figure 9 shows the flow chart of the up-down view control of the player.

Get Current Angle
Left or Right Rotate?Game Over ?

No
A limitation of this game design is that the operational gesture of the mobile device lets the screen lie on the horizontal, and the top of the device is toward the left, as shown in Fig. 10. Figure 10(a) shows that when the player watches on the front, the screen is in the front; Fig. 10(b) shows that the player is looking up to watch, and the screen is tilted downwards; and Fig. 10(c) shows that when the player is looking down to watch, the screen is tilted upwards.
Figure 11 shows the measured triaxial moving numerical for changing view angles.The horizontal axis of the graph expresses the time axis, and the vertical axis represents the acceleration in g units.We can see that the Y-axis data does not change owing to the tilted screen.The X-axis data is between 0 and 1g, but it cannot be expressed as a complex value.The Z-axis data is between positive and negative 1g.Positive 1g is for the screen down until the face is downwards, and 0g to negative 1g is for the screen up until the face is upwards.
In this study, the Z-axis is used as the basis, and its value is used to change the angle of up and down views.When the screen is facing the player, the Z-axis data at 0g is set as the starting point.At the same time, the game world camera X-axis is also set to 0°.When the device screen is gradually turned down until the face is at the bottom, the Z-axis values go from 0g to positive 1g, meaning that the player is looking up to watch, so the game world camera X-axis is from 0 to negative 90°.When the device screen is gradually turned up until the face is at the top, the Z-axis values go from 0g to negative 1g, meaning that the player is looking down to watch, so the game world camera X-axis is from 0 to 90°.At the beginning of the game, the first triaxial acceleration value obtained is used as the basis for determining the altitude of the initial device.The Z-axis data is multiplied by 90° and used as the X-axis value for the game world.After the value is in accordance with the Z-axis, changes in the accelerometer correspond to the game world camera X-axis values.A positive 0.01g increase in Z-axis maps to a negative 0.9° of the camera X-axis.Likely, a 0.01g per negative increase in Z-axis maps to a positive 0.9° of the camera X-axis.Figure 12 shows that the different angles built in the game world by the operating device are used to change the angle.Figure 12

Experimental environment
To demonstrate that our system is effective, an Acer personal computer, an ASUS Nexus 7 flat panel computer, and a Sony Xperia TX LT29i cell phone are used for simulations.The personal computer is used to develop 2D and 3D objects and modules.The flat panel computer is used to test all sensors and their data.The cell phone is used to execute the game and display all results.The Acer personal computer has an Intel Core i5 2400 CPU with Windows 7 Professional and 8.0 GB of memory.The ASUS flat panel computer has NVIDIA Tegra and 3 quad core processors with 1 GB of memory.In addition, it has near field communication (NFC), GPS, an accelerometer, and an electronic compass.Finally, the Sony Xperia TX LT29i cell phone has Qualcomm S4 MSM8260A 1.5GHz with dual core processors and a 1280 × 720 multiple touch panel.Some features of the phone include Android 4.1 Jelly Bean operation system, 1 GB RAM, 13 million pixels Exmor R high-photosensitive camera, GPS, Blue tooth, NFC, an accelerometer, and an electronic compass.For software, we use Unity 4.1.5as the game design development system, Adobe Photoshop CS 5.5 is used for the 2D object design, and Autodesk 3ds Max 2011 64-bit is used for 3D module development.

Experimental results
The results of the simulation are described as follows: In this research, the design of the AR interactive operation consists of three parts: a video camera screen is used as the background of the game; the player device is turned to change the game environment left or right; and the player device is inclined to watch the game objects in the game world from different angles.(A) A video camera screen is used as the background of the game: Figure 13  respectively; it is the game environment response to the player's device.Simultaneously, as shown in Fig. 15, the changes from the radar map orientation to the change in the game objects in the game screen is correct, which proves that the electronic compass and the relevant calculation are operating correctly.
Figure 16 shows a simulated situation of the player's actual operation of the mobile device.In the pictures, it is found that the game player watches the game objects in the game world from

Conclusions
In this research, we developed an AR game used in handy devices.In the game design, the three important parts used to construct the system are as follows: video camera screens as the background of the game, turn devices used to change the game environment toward left or right, and incline devices used to watch the game objects at different angles in the game.In the simulation, we let the player hold mobile phones tightly around 360° to observe game situations, and as expected, the game environment changed.On the other hand, we let the player tilt the phone up; the game screen shows the bottom of the game content; when the player tilts the phone down, the game screen shows the top of the game content.Game content downward and upward amplitudes depend on the tilt angles.
Testing shows that our design achieves smooth operations.Meanwhile, it is also evident that the screen can easily rotate 360° and up-down 180° when the handy device inclines while users play the game.It also demonstrates that our system is effective, and the method used is appropriate.
(a) shows the top facing up, and Fig. 3(b) shows the top facing down.Similarly, Fig. 4 shows the values of the accelerometer when the device is upright.Figure 4(a) shows the top facing left, and Fig. 4(b) shows top facing right.

Fig. 2 .
Fig. 2. Force spread situation of an accelerometer in a handy device.

Table 1 1 0 1 0− 1 Fig. 3 .
Fig. 3. (Color online) Values of the accelerometer when the device is upright: (a) the top is facing up and (b) the top is facing down.

Fig. 4 .
Fig. 4. (Color online) Values of the accelerometer when the device is upright: (a) the top is facing left and (b) the top is facing right.(a) (b)

Fig. 6 .
Fig. 6. (Color online) Flow chart of an AR game control.

Fig. 7 .
Fig. 7. (Color online) Flow chart of the left and right control of game objects by the player.

Fig. 9 .
Fig. 9. (Color online) Up-down view control flow chart of the player.

Fig. 8 .Fig. 10 .Fig. 11 .Fig. 12 .
Fig. 8. (Color online) Electronic compass changes the left and right side pictures of the game: (a) left side picture of the game and (b) right side picture of the game.(a) (b) Fig. 13.(Color online) Video picture used as the background of the game.

Fig. 14 .
Fig. 14. (Color online) Schematic of the player's view for different orientations on a handy device: (a) orientation a, (b) orientation b, (c) orientation c, and (d) orientation d.

Fig
Fig. 16.(Color online) Different view results from different orientations on a handy device: (a) viewing up, (b) viewing down, (c) viewing-up picture, and (d) viewing-down picture.