Difference between revisions of "Alpha testing"

From The Relativty Wiki
(Splitting Alpha Testing into logical sections)
(Tag: Replaced)
Line 1: Line 1:
Relativty has recently been working on some fairly major technical advances to our existing codebase. In addition to the hardware switch from the Arduino Due to the STM32 board for our main 6DoF tracker, we have also been working towards a full 9DoF upgrade. Positional tracking is complex field, full of obtuse terms and complicated mathematics. In a nutshell though, for those of you wondering what this upgrade will give us, it'll fix the main problem that 6DoF trackers have, which is drift.  
+
The '''Alpha Testing''' space is a place where some of the potential code branches of Relativty can be found. Because this is all "Alpha" code, it is all very much in development. That means that it still needs ''a lot of work''. If you are interested in helping out, get in touch with us on Discord, download some of the code & have a play around with it. You might be the one who makes a massive breakthrough for the project, or who takes us in a completely new direction, or who helps to increase our understanding of how everything works and fits together.
  
This is best explained in the two 1 minute videos below, from Sebastian Madgwick - the guy who developed the sensor fusion algorithms that we all use as part of his Ph.D research at the University of Bristol in 2009. Basically, the direction that your 6DoF headset tracker thinks is forwards slowly drifts sideways because of sensor errors, so you have to keep on recalibrating it - but not if you have a 9DoF headset tracker. A 9DoF tracker also measures the earth's magnetic field, alongside the standard 6DoF measurements, & uses a mathematical algorithm to continually compensate for the 6DoF errors.
 
  
 +
We have several areas that we are working on at the moment, although feel free to start a new one if you have a really interesting concept that needs developing.
  
<center><youtube>Egl75nv9E7s</youtube>
 
<br>YouTube: 6Dof Demonstration of Basic Concepts and Drift
 
  
 +
Top of the list is our migration from 6DoF to 9DoF. This is a wide ranging project, with lots of different components, so we've had to break it down into different sections.
  
<youtube>fOSTOnQzZCI</youtube>
+
An [[Introduction_9DoF introduction]] to 6Dof, 9Dof, and why they are important.
<br>YouTube: 9Dof Demonstration of Zero Drift</center>
 
 
 
 
 
The hardware has moved on since Sebastian Madgwick was first playing with it, as have the mathematical algorithms. An American called Kris Winer took Madgwick's algorithm and applied them to new Arduino compatible MPU-9250 sensor boards that had recently become available. He released his work to the world as "Beerware" - which means that anyone can do whatever they like with it, but if they ever get the chance, they should buy him a beer. His work is beyond epic, so if you ever meet him, please, buy him as much beer as you can!
 
 
 
However, to those of us who are not so mathematically adept, the algorithms are rather hard to understand. Thankfully, various people have taken them & wrapped them up in nice, approachable Arduino libraries which are pretty straightforward to use. The library that we will be using was created from Kris Winer's code by Hideaki Tai in Japan - however, as is normal in this field, there is a hardware gotcha that you have to be aware of.
 
 
 
[[File:MPU-9250.png|150px|thumb|left]] The breakout boards that are widely available are supposed to be based on a specific sensor chip: The InvenSense MPU 9250 Nine-Axis (Gyro + Accelerometer + Compass) MEMS MotionTracking&trade; Device. Or, as you or I would call it, a 9250 chip. However, most of the boards that are now in circulation on eBay ad AliExpress are actually based on a 9255 chip instead! It's still made by InvenSense and, as far as we're concerned, it's pretty much identical to the 9250 in every respect bar one. The chips have information storage slots inside them called registers, one of which is called '''Who_am_I'''. This register lives up to its name, and just returns a simple hexadecimal code that identifies the chip - and thus the sensor. The 9250 chip '''Who_am_I''' register returns '''0x71''' whereas the 9255 chip '''Who_am_I''' register returns '''0x73'''. It's a small, but rather significant difference, as it causes all the sanity checks inside the library to fail. If the chip doesn't identify itself as '''0x71''' (i.e. a 9250), nothing runs and everything errors.
 
 
 
 
 
You need to connect your sensor to your Arduino. I am working on the assumption that you have your board all prepared and ready to rock'n'roll (e.g. if you are using an STM32, you have your bootloader). I am also assuming that you have Dupont jumper wires or some way of wiring in your sensor passably. You need 4 wires. If your board is like mine, we will be using the first 4 pins. '''VCC''' goes to '''3v3''' on your Arduino, and '''GND''' goes to '''GND'''. Connect the '''SDA''' and '''SCL''' up as follows:
 
 
 
{| class="wikitable" style="margin: auto;"
 
|- style="vertical-align:middle;"
 
| style="height:50px; width:100px; text-align:center;" | '''Sensor'''
 
| style="height:50px; width:100px; text-align:center;" | '''SCL/SCLK'''
 
| style="height:50px; width:100px; text-align:center;" | '''SDA/SDI'''
 
|- style="vertical-align:middle;"
 
| style="height:50px; width:100px; text-align:center;" | STM32
 
| style="height:50px; width:100px; text-align:center;" | B6
 
| style="height:50px; width:100px; text-align:center;" | B7
 
|- style="vertical-align:middle;"
 
| style="height:50px; width:100px; text-align:center;" | Nano
 
| style="height:50px; width:100px; text-align:center;" | A5
 
| style="height:50px; width:100px; text-align:center;" | A4
 
|- style="vertical-align:middle;"
 
| style="height:50px; width:100px; text-align:center;" | Uno
 
| style="height:50px; width:100px; text-align:center;" | A5
 
| style="height:50px; width:100px; text-align:center;" | A4
 
|- style="vertical-align:middle;"
 
| style="height:50px; width:100px; text-align:center;" | Due
 
| style="height:50px; width:100px; text-align:center;" | 21
 
| style="height:50px; width:100px; text-align:center;" | 20
 
|}
 
 
 
 
 
As I mentioned earlier, the 9DoF sensor uses the earth's magnetic field to compensate and correct for drift. There are two important considerations when it comes to dealing with the earth's magnetic field however. The first is that it varies depending on where you physically are on the surface of the earth. The second is that it varies over time as well. This isn't quite as much of a problem as it seems though. The magic number that we need is called Magnetic Declination, and we need to work out a new value about once a year or so. That means that you should update your library & reflash your tracker sketch every now and then, to keep you accurately aligned. Thankfully, there are web pages linked to Google Maps that do the whole thing for you, and 5 seconds with a calculator gives you the number that you need to type in. The entire procedure is documented in my '''[https://github.com/JustinS-B/9DoF/blob/master/Magnetic_Declination.txt  Magnetic_Declination.txt]''' file. You'll need this number shortly, to update your library.
 
 
 
 
 
Before that though, you will need to add the library to your Arduino IDE. Go to the '''Sketch''' menu -> '''Include Library''' -> '''Manage Libraries'''. This will give you your Library Manager. In the search field enter '''9250''' and scroll down the list of results until you get to '''MPU9250 by hideakitai Version 0.1.1''' and install it.
 
 
 
 
 
Next, we need to find out if you have a 9250 or a 9255 chip. Download the sketch called '''Chip_Test''' from '''[https://github.com/JustinS-B/9DoF here]'''. Select your Arduino Board and Port (if required) from the menus in the IDE & flash the sketch as normal. Once it has completed, open the serial monitor. You will see something resembling either one of these two images.
 
 
 
 
 
[[File:MPU9250-0x71.png|frameless|center|700px]]
 
 
 
<Div align="center">Default Library settings & a 9255 chip: Looking for 0x71 but found 0x73</div>
 
 
 
 
 
[[File:MPU9250-0x73.png|frameless|center|700px]]
 
 
 
<Div align="center">Updated Library settings & a 9255 chip: Looking for 0x73 and found 0x73</div>
 
 
 
 
 
Basically, in the first image, I am using a completely default library, with nothing changed. I also have a 9255 chip plugged into my Arduino. It's looking for 0x71 but getting 0x73 - and it's not happy about it. Go to your Arduino libraries folder, look for '''MPU9250''' and open '''MPU9250.h''' in a text editor. Scroll down to line 26 and look for this text:
 
 
 
'''const uint8_t MPU9250_WHOAMI_DEFAULT_VALUE {0x71};'''
 
 
 
Change 0x71 to 0x73
 
 
 
'''const uint8_t MPU9250_WHOAMI_DEFAULT_VALUE {0x73};'''
 
 
 
 
 
Whilst you are editing this file, you also need to update your '''Magnetic Declination''', so scroll down to line 55 and look for this text:
 
 
 
'''float magnetic_declination = -7.51; // Japan, 24th June'''
 
 
 
Change it to the value for your location that you calculated earlier. It really helps if you put a date and location in the comment field next to it, so you know when & where you last updated it.
 
 
 
'''float magnetic_declination = -0.25; // London, 25th April, 2019'''
 
 
 
 
 
Save your library file, & reflash your sketch. You should now see something like the second image as it's now looking for 0x73 and getting 0x73, so it knows that it has the right chip (even if it's an updated version). If, however, you get something that looks like the second image straight away (but with 71 instead of 73), then you actually have a 9250 chip. '''This means that you only need to update your Magnetic Declination, so don't touch the WHOAMI_DEFAULT_VALUE.'''
 
 
 
 
 
'''If you have a board with a 9250 chip, please take a screen grab of the Serial Monitor screen, so that I can update the Wiki as I don't have one'''
 
 
 
 
 
The next step is to calibrate your sensor. If you don't, your readings will be all over the place. Trust me, you really cannot skip this step! All you have to do is to open the '''File''' menu in your Arduino IDE, select '''Examples''', select '''MPU9250''' and load the '''calibrate''' sketch. Once you have uploaded it, check that your Serial Monitor is set to '''115200''' and just follow the instructions. To begin with, the sensor needs to be stationary, but once it has done its first calibration it will ask you to move it in a figure of 8 for 30 seconds or so. It appears to store its calibration settings inside the sensor registers, so the calibration is preserved between sketch flashes.
 
 
 
Once you have calibrated your sensor, flash the '''9DoF_Tracker''' sketch from my GitHub repo. Open the Serial Monitor & check that it appears to be working. '''It is important to note what Com Port it is using whilst you have the Arduino IDE open, as it is probably different from your old sensor.''' All you should need to do it to update the Com Port your OSVR '''osvr_server_config.json''' file and you should be good to go.
 
 
 
Please feed back your findings, experiences or problems to '''help-hardware'''.
 

Revision as of 11:20, 28 April 2019

The Alpha Testing space is a place where some of the potential code branches of Relativty can be found. Because this is all "Alpha" code, it is all very much in development. That means that it still needs a lot of work. If you are interested in helping out, get in touch with us on Discord, download some of the code & have a play around with it. You might be the one who makes a massive breakthrough for the project, or who takes us in a completely new direction, or who helps to increase our understanding of how everything works and fits together.


We have several areas that we are working on at the moment, although feel free to start a new one if you have a really interesting concept that needs developing.


Top of the list is our migration from 6DoF to 9DoF. This is a wide ranging project, with lots of different components, so we've had to break it down into different sections.

An Introduction_9DoF introduction to 6Dof, 9Dof, and why they are important.