Skip to main content
Up and Coming
March 29, 2013

Magnetic yaw correction

So I downloaded the SDK and looked over what you guys are doing in regards to sensor fusion. It looks really basic (having seen what several multicopter projects are doing to calculate orientation) and the magnetometer doesn't get used at all.

Now I don't have a Rift yet, but I imagine that drifts in the yaw axis and should be visible after some time. Any plans to use the magnetometer or are you open to suggestions? ;-)

P.S.: If EnableGravity is set to false, there doesn't seem to be any normalisation of Q.

    35 replies

    SebbiAuthor
    Up and Coming
    March 30, 2013
    class MessageBodyFrame : public Message
    {
    public:
    MessageBodyFrame(DeviceBase* dev)
    : Message(Message_BodyFrame, dev), Temperature(0.0f), TimeDelta(0.0f)
    {
    }

    Vector3f Acceleration; // Acceleration in m/s^2.
    Vector3f RotationRate; // Angular velocity in rad/s^2.
    Vector3f MagneticField; // Magnetic field strength in Gauss.
    float Temperature; // Temperature reading on sensor surface, in degrees Celsius.
    float TimeDelta; // Time passed since last Body Frame, in seconds.
    };


    All three sensors are 3-axis and you can also use it as a thermometer (and maybe correct for gyro temperature drift over time? who knows?). It doesn't look like there is any calibration going on in the code. Maybe the rift does it internally? Like wait a few 100 ms and measure gyro bias and what is a level orientation? Haven't found anything in the SDK ...
    Up and Coming
    March 30, 2013
    "msat" wrote:
    Changes in the magnetic field over a given area will generally be gradual - it's unlikely that you'll get a particular value in one spot, and a completely different one several cm away (assuming we're talking about just translation here and not rotation). Even if it did, what I'm suggesting is just using the mag data as a simple verification factor for the gyro's data, and not for correction - something like: Is the gyro reporting angular changes? If yes, is there also changes in the mag readings? If not, ignore gyro data. This can only eliminate drift in certain cases, and is not viable for detecting discrepancies between actual rotations and measured rotations. It'll only prevent the world from slowly spinning in front of you.


    This won't actually work in practice, because you will never be able to tell rotating a really small amount from mag noise. Whatever mag change threshold you choose here will end up throwing away small gyro rotations that were actually needed, and you will drift anyway.

    kingtut: Do you plan to try to correct drift for the sensors on your gun/hip as well? Or are you just hoping that if you stay in one spot there won't be an issue?
    Up and Coming
    March 30, 2013
    bteitler: Good question. I guess I'll need to do some experimentation and see. I need to see a) if I can differentiate between local and global magnetic fields based on the vertical component and/or magnitude, b) how much the magnetic fields tend to vary based on height (i.e. between hip and head), c) whether gyro drift is in some way common/consistent between head and hip.

    Drift in the head isn't too bad if you're stood up as you'll just turn to adjust - but differential drift between head and hip would be a nightmare.

    What will be interesting will be using constraints - e.g. head yaw = hips +/- 90degrees, and averages over time at 0 (or maybe some other constant?) degrees. Gun likewise will average to a constant location - although that may be offset. I'm not too worried about gun drift, as with a HUD you can get visual feedback. You could also use a specific action to recenter (for some value of 'center') - e.g. tilting your head to the right to look down iron sights/scope.

    I'm wondering if use could be made of translation movements, to identify whether and how much drift there is. E.g. if you step sideways then that linear motion will effect all sensors identically.

    Finally, I really like the idea of using SLAM/PTAMM Computer Vision methods (or much simpler fiduciary markers).

    In the future, I could even imagine game designers building in periodic and non-obvious in-game checkpoints, where players can be expected to be looking/standing straight ahead, so that trackers can sync up automagically.
    New Participant
    March 31, 2013
    For a lighter experience you can go wireless without the battery pack and laptop. Building a wireless power mat to stand on isn't that hard to do. I don't know if it would interfere with any of the equipment though so maybe keep it low. As a note, the distance you want the power to travel is the diameter of the first coil.this can vary though. ;)
    Up and Coming
    March 31, 2013
    If I remember correctly gimbal lock is a problem related to using Euler angles instead of quaternions for rotations. I also thought that Kalman filtering would be the best way to fuse the raw sensor data into orientation.
    Up and Coming
    March 31, 2013
    "kingtut" wrote:
    bteitler: Good question. I guess I'll need to do some experimentation and see. I need to see a) if I can differentiate between local and global magnetic fields based on the vertical component and/or magnitude, b) how much the magnetic fields tend to vary based on height (i.e. between hip and head), c) whether gyro drift is in some way common/consistent between head and hip.

    Please do publish your results, and even negative results.

    As per

    ...the global geomagnetic field isn't always pointing to the horizon and it is different night and day. You may wish to incorporate the computer's locale settings in your calculations. =)

    If you are able to tell local fields from global ones, you may be able to plot the fields. If you can then spot three magnets at known nearby locations of x, y, z, you might be able to do positional tracking.
    SebbiAuthor
    Up and Coming
    March 31, 2013
    "Robert" wrote:
    If I remember correctly gimbal lock is a problem related to using Euler angles instead of quaternions for rotations. I also thought that Kalman filtering would be the best way to fuse the raw sensor data into orientation.


    That is correct, but Kalman filters tend to be laggy and if the gyros are good enough (which they are nowadays) a complementary filter should be better.

    @magnetic positional tracking: isn't that what the Razr Hydra is doing? Just strap one of the controllers to your head :D
    Up and Coming
    March 31, 2013
    "Sebbi" wrote:
    @magnetic positional tracking: isn't that what the Razr Hydra is doing? Just strap one of the controllers to your head :D

    You laugh! But that's exactly what I am going to do! :lol:

    It may actually be the perfect solution since the Hydra has two controllers and I have a Joystick.
    Up and Coming
    March 31, 2013
    From the Hydra support page:

    Q: Will the magnetic field of the Razer Hydra affect objects in its vicinity?
    A: The Razer Hydra uses a magnetic field which is 20 times weaker than the Earth's natural magnetic field, allowing it to operate without adversely affecting objects in its surrounding, such as credit cards, hard disk drives and speakers.


    I can't imagine that working in my apartment if it is that much weaker than Earth's field, especially if I wanted to move it around during play. Does it require a lot of calibration? I can see just rotating the base during play being a problem potentially.
    Up and Coming
    March 31, 2013
    "Sebbi" wrote:

    @magnetic positional tracking: isn't that what the Razr Hydra is doing? Just strap one of the controllers to your head :D


    Yeah, I've done that. I sat the hydra base on top of a ceiling fan, and stood below it with one controller taped to my HMD, the other in my hand. I used MotionController to set up a profile which measured the distance between the controller on my head and the base. Then I could map jumping and crouching to some keys. I also mapped movements on the hand controller to sword swings in Skyrim. It was pretty cool, but a pain to set up.