Atomic IMU and some C++: A Generic VR system.

I began to re-cover the topic but never finished the process. Maybe next holidays given more time. In the meantime you can watch an ancient video of it working at the bottom of my old post.

Using an Atomic IMU from SparkFun, some Video Glasses from ebay, Some C++ and some duct-tape; a while ago I hacked together a Generic VR-type system. In this video I explain how it works, what I’m up to, and what I’m planning for it:

A class for constructing from raw IMU data, checks validation and combines bytes:

struct IMU_Data {  
    IMU_Data( unsigned char cp[] ) {
        s_frame = cp[0];
        CombineBytes( &cp[1], sample_count );
        CombineBytes( &cp[3], accel_x );
        CombineBytes( &cp[5], accel_y );
        CombineBytes( &cp[7], accel_z );
        CombineBytes( &cp[9], pitch );
        CombineBytes( &cp[11], roll );
        CombineBytes( &cp[13], yaw );
        e_frame = cp[15];

    void CombineBytes( unsigned char cp[], unsigned short &s) {
        s = unsigned short(cp[0]) << unsigned short(8);
        s += unsigned short(cp[1]);


    bool IsValid() {
        return ( (s_frame == 'A') && (e_frame == 'Z') );

    char s_frame;
    unsigned short sample_count;
    unsigned short accel_x;
    unsigned short accel_y;
    unsigned short accel_z;
    unsigned short pitch;
    unsigned short roll;
    unsigned short yaw;
    char e_frame;
comments powered by Disqus