Inertial tracker based on Arduino and GY-85

  • Tutorial
image

Hi geektimes . Head tracker, sometimes it is also called an inertial tracker - a device that tracks the movement of the head in space, that is, in three axes - X, Y, Z.

Today I will tell you how you can move the mouse cursor with the help of head movements, although, everything is not limited to turnips only, you can use any other moving part of the body, such as a hand.


This video, for the most part, duplicates the text of the article.

The target audience for this device, as I see it at the moment, will be something like this:
  • Gamers, this solution is perfect for all kinds of flight simulators, be it War Thunder or space simulators, such as Elite Dangerous (a usage example will be a bit lower), and simulators in general, where the mouse is mostly used for review, although they say that in Arma 2 also plays well. At the beginning of the video, I demonstrated the work in GTA5 with the third-person view turned on, and I’ll tell you that these are completely different sensations from the game, although it is difficult to aim, and there are still some nuances specifically in this game, such as - you still have to “taxi” a little with the mouse;
  • People with disabilities, I think if we seriously develop this topic, it can be easier to use a computer for people who are hard to use;
  • VR device developers (virtual reality);
  • RC modellers and copter guides;
  • The same tech geeks like me .

In order to repeat this device, we need the following hardware:

- Arduino, the best solution in this case is Arduino Nano V3 (inexpensive, relatively small), it is imperative that the board is equipped with an ATmega328 microcontroller on board. It would also not be bad if there was a USB to UART converter on the CH340 chip in the arduino: so

image

that there would be no problems with the lack of memory on the microcontroller or drivers, such as for example, arduins based on FT232RL chips .

The Case for ATmega328
image

The code, as can be seen from the screenshot above, takes about 16 kilobytes of microcontroller memory, which is definitely not enough if the arduinka is based on ATmega168, although of course you can cut out not quite necessary functionality from the firmware and thus try to fit it. Really, why?

Look for drivers for the CH340G chip in the first links for “ch340g driver” in google , or in the archive for this article.

- GY-85 sensor, it is a three-axis MPU3200 gyroscope, ADXL345 accelerometer and HMC5883L magnetometer on one board. This is more than enough to navigate in space in three axes.

image

He showed himself best, does not require preliminary calibrations, connected, flashed an arduino and works. Although AHRS (Coursework) firmware allows calibration, but this is a separate topic, which, in my opinion, is more than fully disclosed on the WarThunder forum ;

- A different trifle - wires, a soldering iron (you can’t do without it, because Arduino Nano and GY-85 come from China in soldered condition), a USB extension cable, a Mini-USB cable for Arduino Nano V3.

Assembling the Head Tracker: We

connect the Arduino and the GY-85, in the case of the Arduino Nano it will be like this:

image

  • VCC_IN -> 5V;
  • SCL -> A5;
  • SDA -> A4;
  • GND -> GND.


We supply power to the arduino - the LED should light on the sensor.

In the case of Head Tracker, it’s ideal to attach the sensor to the rim of the headphones, so I did it in a “wry-handed” way:

image

I’m sure that you will do it more accurately than me.

Arduino screwed the board with an ordinary wire from a twisted pair cable, so as not to short the insulation on the board, I did not remove the insulation from the wire, everything keeps normal if you do not constantly fiddle it.

image

As for not fumbling the board, I just twisted the USB cable and earphone cable with the same wiring from a twisted pair cable.

I also wanted to do the same with the sensor at first, but through trial and error I found out that this is not an option, I will write below why. I just tied everything with a thread, it turned out like this:

image

Under the sensor, as well as under the arduino, he put a piece of foamed polyethylene so that they would not scratch my headphones, and all this holds better.

True, there are some points, it is important to position the sensor so that the arrow Y points to the monitor.

image

It is also necessary to keep the sensor away from metal objects, the recommended distance is 5-10 cm. Otherwise, there may be a distortion of the readings, glitches in the operation of the sensor. This is true for those who have a metal rim of headphones. Although not only metal can distort the readings, but also the arduinka itself or even the wires, as was shown in the video , so try to remove all this from the sensor at least 5-10 cm away.

The simplest solution with a metal rim of the headphones is a sponge for washing dishes:

image

Since I have a plastic bezel (it was checked by a magnet), I scored it all.

Firmware:
If you still have not installed the latest version of Arduino IDE - download and install. At the time of writing, this is 1.6.8.

In our inertial tracker, we will use custom firmware of the AHRS Firmware for the SparkFun 9DOF Razor IMU and SparkFun 9DOF Sensor Stick project ( archive with everything you need at the bottom of the article ). In the Arduino IDE, open the Razor_AHRS.ino file, which lies in the archive along the DIY headtracker \ RazorAHRS_FaceTrack \ Razor_AHRS path:

image

And load the firmware into the arduino:

image

OpenTrack setup:

OpenTrack is a free open source program designed to track the movements of the user's head and their conversion to coordinates. Able to work with various input devices, including infrared frame and Oculus Rift or with smartphones.

In the video, the dude plays the cult game Elite Dangerous, using his Android smartphone as a mouse:



This allowed both hands to be used for the gameplay. Agree, it looks very cool. True, I do not like a few nuances in this implementation, namely, the smartphone is relatively bulky and heavy, the GY-85 clearly takes up space and weighs less, besides, radiation from the smartphone’s WiFi transmitter does not hammer into its head.

More information can be found here:
https://github.com/opentrack/opentrack/wiki/Smartphone-Headtracking

But let's get back to our rams Arduino and GY-85. First you need to download and install the latest version of the program (currently opentrack-2.3 rc21p11), run it:

image

Now we need to configure the program - in the “Tracker” field, select “Hatire Arduino” and click on the “...” button and we will see that something like this:

Hatire Arduino Settings Window
image

Here it is necessary to change the “Serial port” to the COM port of our arduinka, in my case it is COM42. Next, go to the “Command” tab, set there, in the “Init” and “Start” 1000 fields, then set “BaudRate” 115200, and finally click “Save” and “OK”.

Next, in the main window of the program, click the “Start” button, start to rotate the sensor in different axes and follow the octopus. Most likely, the movements of the sensor and the octopus will be different, at least in my case it happened, without stopping the tracking, press the "..." button in the "Tracker" field. Here we need to configure the “Axis Configuration” in such a way that the movements of the sensor coincide with the movements of the octopus in the program - we set the RotX / RotY / RotZ values ​​for the “Yaw”, “Pich” and “Roll” in the desired sequence, this will help us in this picture:

image

As it turned out for me, you can see on the settings screen “Hatire Arduino” what is higher. The Roll axis had to be inverted because the octopus was spinning in the opposite direction.

The program also allows you to adjust the sensitivity for each of the axes - the “Mapping” button in the main window of the program:

image

Right-click allows you to set and move points, left-click removes points, you can set several points to eliminate non-linearity in the sensor reading, if any . My axes are all set up like this:

image

The Filter tab in the main window of the program allows you to change the type of filter, or even turn it off altogether, in which case the readings will be very unstable and sharp. My filter type is “Accela” with the following settings:

image

If you wish, you can play around with the settings.

We proceed to configure the mouse emulation, for this, in the “Protocol” tab, select “mouse emulation” and press the “...” button, there you need to set “Yaw” and “Pich” for the X, Y axes:

image

Press the start and voila button - prevention cervical osteochondrosis. And finally, I’ll add that before you press the start button, you need to position the head exactly on the monitor, because the sensor is calibrating at that moment.

Results:

Pros before the option using a web camera and IR LEDs:
  • Speed, this firmware produces about 60 readings per second, which is approximately the same as a web camera at 60 fps, but it seems to me that a webcam at 60 frames per second is clearly more expensive than the GY-85 and Arduino boards;
  • There is no dependence on lighting;
  • Since almost all calculations are performed by arduino, the resources of the computer processor are unloaded, that is, fewer glitches in games;
  • It can be used not only for games, but also to facilitate the use of a PC for people with disabilities.

Minuses:
  • Wired connection, which in principle can be solved using the Bluetooth module, for example, as HC-05 / HC-06. The firmware supports this feature.
  • The sensor is relatively expensive, I bought mine for $ 8, which I think is overpriced;
  • The aesthetic appearance of the headphones deteriorates, but I'm sure you will do better than me.


Surely many will have a question, what is the point of turning your head around the monitor if it stands still? As I said in the video, this is just the beginning of the VR theme on my YouTube channel.

Useful links on the topic:

Archive for the article , with everything you need;
A forum thread on the game WarThunder , where there is a lot of interesting things on the topic of the article;
Always the latest version of the Arduino IDE ;
Project AHRS Firmware for the SparkFun 9DOF Razor IMU and SparkFun 9DOF Sensor Stick ;
Custom firmware of the project above , sharpened for working with the OpenTrack program;
A similar project using a smartphone as a position sensor ;
Always fresh and working version of OpenTrack lies here ;
A similar publication from a friend Sergei Novosyolov SergeNovo
Homemade inertial tracker for 3-D points and not only ;
All my publications on geektimes .

PS There is another option when OpenTrack does not emulate mouse movements, but interacts directly with the game, but I can write about this some other time, or you can figure it out myself, I asked a vector for the development of this topic;
PPS If anyone needs it, here is a diagram of the GY-85:
GY-85-SCH.jpg
image

Also popular now: