Difference between revisions of "User:Massima/Howto:Hatire head tracker"

From FlightGear wiki
Jump to: navigation, search
(Created page with "<big><big><big>'''HATIRE HEADTRACK (a little guide)'''</big></big></big> I write this guide to help anyone to use hathire in any sim/game. Let’s start with hw and sw requir...")
 
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
<big><big><big>'''HATIRE HEADTRACK (a little guide)'''</big></big></big>
+
<big><big><big>'''Head Arduino Tracker (aka Hatire)'''</big></big></big>
  
 
I write this guide to help anyone to use hathire in any sim/game. Let’s start with hw and sw requirements.
 
I write this guide to help anyone to use hathire in any sim/game. Let’s start with hw and sw requirements.
  
<big>'''HARDWARE:'''</big>
+
<big>'''hardware:'''</big>
  
 
1. a MPU9250 device preferring a 5V tolerant device, i did not test a 9255;  
 
1. a MPU9250 device preferring a 5V tolerant device, i did not test a 9255;  
[[File:Mpu9250.png|thumb|Mpu9250]]
+
[[File:Mpu9250.png|thumb|150px|Mpu9250]]
 
2. an arduino board, you can choose any kind but if your MPU works at 3.3V,  you need a board with a 3.3V pin. I use this pro micro board 3.3V and 5V (it runs at 4.68V);
 
2. an arduino board, you can choose any kind but if your MPU works at 3.3V,  you need a board with a 3.3V pin. I use this pro micro board 3.3V and 5V (it runs at 4.68V);
[[File:Pro-micro.png|thumb|Pro-micro]]
+
[[File:Pro-micro.png|thumb|150px|Pro-micro]]
 
3. a push button;  
 
3. a push button;  
  
Line 16: Line 16:
  
  
<big>'''SOFTWARE'''</big>
+
<big>'''software'''</big>
  
<big>'''''WINDOWS:'''''</big>
+
<big>'''''Windows:'''''</big>
  
 
1. install arduino IDE and drivers for your board;
 
1. install arduino IDE and drivers for your board;
  
2. connect your board and open device manager as amministrator→ ports (right click) → properties → port setting:
+
2. connect your board and open device manager as amministrator→ ports (right click) → properties → port setting (see images Win setup1-2):
 
[[File:Win setup.png|thumb|Win setup1]][[File:Win setup2.png|thumb|Win setup2]]
 
[[File:Win setup.png|thumb|Win setup1]][[File:Win setup2.png|thumb|Win setup2]]
  
  
<big>'''''LINUX:'''''</big>
+
<big>'''''Linux:'''''</big>
  
 
1. download the arduino IDE, unpack somewhere;
 
1. download the arduino IDE, unpack somewhere;
Line 42: Line 42:
  
  
<big>'''TRICKS:'''</big>you could have problem flashing the code on board try, while you press load, to reset the board connecting for a while RST with GND (windows and linux), remove modemmanager (linux). Perhaps if arduino IDE doesn’t start you need to  make the main binary executable with ''“chmod +x /path/filename”''(linux).
+
<big>'''tricks:'''</big>you could have problem flashing the code on board try, while you press load, to reset the board connecting for a while RST with GND (windows and linux), remove modemmanager (linux). Perhaps if arduino IDE doesn’t start you need to  make the main binary executable with ''“chmod +x /path/filename”''(linux).
  
  
<big>'''CONNECTIONS'''</big>
+
<big>'''connections'''</big>
  
 
A visual scheme is available on the edtracker site, anyway you need the following connections:
 
A visual scheme is available on the edtracker site, anyway you need the following connections:
Line 64: Line 64:
 
*  pins change for different boards.
 
*  pins change for different boards.
  
[[File:My headtrack built.jpg|thumb|my headtrack built]]
+
[[File:My headtrack built.jpg|thumb|150px|my headtrack built]]
  
  
<big>'''THE CODE'''</big>
+
<big>'''the code'''</big>
  
 
I would say thanks to @hideakitai for his library (https://github.com/hideakitai), it is the only that gives us pitch, roll, yaw. I traslate them in a binary format used by hatire. So install its library in the library manager.
 
I would say thanks to @hideakitai for his library (https://github.com/hideakitai), it is the only that gives us pitch, roll, yaw. I traslate them in a binary format used by hatire. So install its library in the library manager.
  
  
<big>'''CALIBRATE THE MPU9250 (be aware from EM sources)'''</big>
+
<big>'''calibrate the MPU9250 (be aware from EM sources)'''</big>
  
 
The first step needs to open the sketch called “calibration” (file→ examples→ MPU9250), load it and open the serial console:
 
The first step needs to open the sketch called “calibration” (file→ examples→ MPU9250), load it and open the serial console:
Line 106: Line 106:
 
   mpu.setMagScale(0, +1.04);
 
   mpu.setMagScale(0, +1.04);
 
   mpu.setMagScale(1, +1.02);
 
   mpu.setMagScale(1, +1.02);
   mpu.setMagScale(2, +0.94);''
+
   mpu.setMagScale(2, +0.94);'''
  
DO NOT ENTER DATA FOR THE ACCELEROMETER, they are commented in that file.
+
Do not enter data for accelerometer, they are commented in that file.
  
  
Line 114: Line 114:
  
  
'''IMPORTANT:''' if you change your environment near the magnetometer (like closer parts, headphones), you need to recalibrate it. Otherwise your HT will work badly. My issue, i worked and calibrated my HT with a mini-breadboard. When i switched to a compact solution (see the image at first page), my HT didn’t work correctly but recalibrating did the trick.
+
'''important:''' if you change your environment near the magnetometer (like closer parts, headphones), you need to recalibrate it. Otherwise your HT will work badly. My issue, i worked and calibrated my HT with a mini-breadboard. When i switched to a compact solution (see the image at first page), my HT didn’t work correctly but recalibrating did the trick.
  
  
<big>'''TEST'''</big>
+
<big>'''test'''</big>
  
 
Now it is time to test your system. The loaded code never freezes, my tests platform:
 
Now it is time to test your system. The loaded code never freezes, my tests platform:
Line 128: Line 128:
  
  
<big>'''SETUP'''</big>
+
<big>'''setup'''</big>
  
 
I share my opentrack setting ini files then you can edit yaw, pitch, roll curves but i strong suggest you, everytime, to center the position of the tracker (options → output → custom center position).
 
I share my opentrack setting ini files then you can edit yaw, pitch, roll curves but i strong suggest you, everytime, to center the position of the tracker (options → output → custom center position).
  
  
<big>'''LINKS'''</big>
+
<big>'''links'''</big>
  
 
A link on the main opentrack site is available [https://github.com/opentrack/opentrack/wiki/Built-a-Hatire-headtracker-with-a-MPU9250 here].
 
A link on the main opentrack site is available [https://github.com/opentrack/opentrack/wiki/Built-a-Hatire-headtracker-with-a-MPU9250 here].
  
 
All useful stuff are available [https://drive.google.com/drive/folders/15HhIHfoJ6WcMU1nhQ93dDLvj_SIr3SEa?usp=sharing here] on my gdrive space, there is an opentrack debian package too.
 
All useful stuff are available [https://drive.google.com/drive/folders/15HhIHfoJ6WcMU1nhQ93dDLvj_SIr3SEa?usp=sharing here] on my gdrive space, there is an opentrack debian package too.

Latest revision as of 11:51, 28 March 2020

Head Arduino Tracker (aka Hatire)

I write this guide to help anyone to use hathire in any sim/game. Let’s start with hw and sw requirements.

hardware:

1. a MPU9250 device preferring a 5V tolerant device, i did not test a 9255;

Mpu9250

2. an arduino board, you can choose any kind but if your MPU works at 3.3V, you need a board with a 3.3V pin. I use this pro micro board 3.3V and 5V (it runs at 4.68V);

Pro-micro

3. a push button;

4. i used classic Dupont wires and some Dupont core plus and DuPont plastic shell plug chief.

Obviously this is not the only way to connect it, see http://edtracker.org.uk/ you could use a breadboard or a PCB. I use wires because i can disassemble it if needed.


software

Windows:

1. install arduino IDE and drivers for your board;

2. connect your board and open device manager as amministrator→ ports (right click) → properties → port setting (see images Win setup1-2):

Win setup1
Win setup2


Linux:

1. download the arduino IDE, unpack somewhere;

2. connect your arduino, open a terminal and type: “lsusb”. You get something like this: “Bus 003 Device 008: ID 2341:8037 Arduino SA Arduino Micro”. Yours will be different;

3. as root create a file in “/etc/udev/rules.d”. Call it “52-arduino.rules”, inside put:

 SUBSYSTEM=="usb", ATTR{idVendor}=="2341", ATTR{idProduct}=="8037", MODE="0666", GROUP="plugdev", SYMLINK+="arduino arduino_micro"

4. IdVendor and idProduct could be different for your board.

5. Restart udev as root with “service udev restart”;


tricks:you could have problem flashing the code on board try, while you press load, to reset the board connecting for a while RST with GND (windows and linux), remove modemmanager (linux). Perhaps if arduino IDE doesn’t start you need to make the main binary executable with “chmod +x /path/filename”(linux).


connections

A visual scheme is available on the edtracker site, anyway you need the following connections:

MPU9250 Arduino Board button Arduino Board
VCC 5V RST
GND GND GND
SDA SDA (pin 2 for micro)*
SCL SCL (pin 3 for micro)*
  • pins change for different boards.
my headtrack built


the code

I would say thanks to @hideakitai for his library (https://github.com/hideakitai), it is the only that gives us pitch, roll, yaw. I traslate them in a binary format used by hatire. So install its library in the library manager.


calibrate the MPU9250 (be aware from EM sources)

The first step needs to open the sketch called “calibration” (file→ examples→ MPU9250), load it and open the serial console:

1. Keep the MPU9250 on the table, horizontal, don’t move it!! so it will calibrate the accelerometer and gyroscope;

2. soon you will read “Mag Calibration: Wave device in a figure eight until done!”. Now rotate it for 360° describing a sphere, fast, rotate it in every position;

3. at the end save datas like these:

< calibration parameters >

  accel bias [g]: 

13.85, 68.24, -206.36

 gyro bias [deg/s]: 

-5.79, -3.03, -2.47

   mag bias [mG]: 

-39.82, 77.82, -422.38

   mag scale []: 

1.04, 1.02, 0.94


4. Open my sketch “mpu9250-hatire” and change values, with yours:

 mpu.setGyroBias(0, -5.79);
 mpu.setGyroBias(1, -3.03);
 mpu.setGyroBias(2, -2.47);
 mpu.setMagBias(0, -39.82);
 mpu.setMagBias(1, +77.82);
 mpu.setMagBias(2, -422.38);
 mpu.setMagScale(0, +1.04);
 mpu.setMagScale(1, +1.02);
 mpu.setMagScale(2, +0.94);

Do not enter data for accelerometer, they are commented in that file.


5. Load the code!!! you can cange the magnetic declination for your country (http://www.magnetic-declination.com) too.


important: if you change your environment near the magnetometer (like closer parts, headphones), you need to recalibrate it. Otherwise your HT will work badly. My issue, i worked and calibrated my HT with a mini-breadboard. When i switched to a compact solution (see the image at first page), my HT didn’t work correctly but recalibrating did the trick.


test

Now it is time to test your system. The loaded code never freezes, my tests platform:

Debian testing+opentrack 2.3.11 unstable+FlighGear 2019.1.1 → running time 1h 35 min;

Windows10+opentrack daily build+Falcon BMS 4.34.3→ running time 1h 25 min;

When you push the button start for the first time you can observe a strange movement of the squid, push the stop and start button again and again.


setup

I share my opentrack setting ini files then you can edit yaw, pitch, roll curves but i strong suggest you, everytime, to center the position of the tracker (options → output → custom center position).


links

A link on the main opentrack site is available here.

All useful stuff are available here on my gdrive space, there is an opentrack debian package too.