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;
};

TextSweeper - A Minesweeper that has gone console

In all the time I spent at work experience with DPI IT (which was awesome, by the way) – I had a load of free time; in fact, in the 5 days I had there, there was about 7 hours of just sitting there doing nothing. My attempt at turning this time into something productive was this:

#TextSweeper

Basically – it’s just minesweeper but it runs on console:-

Download it here (includes source)

(inside the archive is a ‘bin’ folder, the executable is in there) Download is half a meg – but that’s only because of the bloated VC++ dlls – the actual program is 22KB.

But – if you’re into code, I’ve got something for you as well. I tried to use *some *sort of OO paradigm – and I did (sort of). The code for the SweeperBoard header and implementation (most of the code overall) are both pretty well commented and organised. On the other hand, the actual ‘main’ code (TextSweeper.cpp), well, isn’t. Without further ado, here are the files on pastebin (They’re also in the download):-

SweeperBoard.cpp

SweeperBoard.h

TextSweeper.cpp

I’m happy for you to look at the code in the first two, but if you like a good hackjob don’t hesitate to take a peek at the last. You should be able to compile this yourself, just setup files with the same names in visual studio, paste in the contents, and away you go.

Happy Text Sweepin’!