Author Topic: Wii Hammer - Wii Remote 6 degree of Freedom All Optical Motion Tracking  (Read 8880 times)

Offline zainey

  • *
  • Posts: 64
  • Karma: +2/-0
    • View Profile
Hi,

This is a project that I have completed.



For more information please visit - http://www.mtbs3d.com/phpBB/viewtopic.php?f=6&t=4251   



Offline zainey

  • *
  • Posts: 64
  • Karma: +2/-0
    • View Profile
Hi,

 I have reproduced the fully working GlovePie 0.30 script here as well.


// ***START OF GLOVEPIE PROGRAM***

// Proof of Concept - Prototype Wii Remote 6 Degree of Freedom All Optical Tracking
// Requires Two Wii Remotes each with a Wii HammerHead sensorbar attachment
// Programmed using GLOVEPIE v0.30

// Fake TrackIR tested on Battle of Britain 2 - Wings of Victory - with patch v2.08 - Full 6 DOF cockpit model

// Concept and hardware by M.A.V. Brisbane Australia
// Public Release v1, 14 September 2009
// Thanks to all third parties including Carl Kenner (GlovePie), Natural Point Inc (TrackIR), Nintendo (Wii Remote), Shockwave (BOB2).

// Thanks to "Meant to be Seen" MTBS for originally hosting this post at MTBS Forums
//               www.mtbs3d.com/phpBB/viewtopic.php?f=6&t=4251


 pie.framerate = 100Hz

 var.screenwidth = screen.Width
 var.screenheight = screen.Height

 // Wii camera centre pixel coordinates
 var.wiicameraxcentre = 512
 var.wiicameraycentre = 384

 // Wii camera nominal half field of view x & y axis
 var.wiicameraxhalfFOV = 20
 var.wiicamerayhalfFOV = 15

 // Wii camera nominal angular resolution
 var.wiicamangletopixel = 20/512

 // Wii Hammerhead sensor bar LED separation in centimetres for both Wii remotes
 var.S_ledbaseline = 6


 //CONNECTION ORDER for TWO Wii Remote controllers
 // First wiimote connected is mobile wiimote1 followed by stationary wiimote2

 debug = ' working '

// Check for and read in all IR point coordinates at once

 if wiimote1.dot1vis AND wiimote1.dot2vis AND wiimote2.dot1vis AND wiimote2.dot2vis

    var.w1dx1 = wiimote1.dot1x
    var.w1dy1 = wiimote1.dot1y

    var.w1dx2 = wiimote1.dot2x
    var.w1dy2 = wiimote1.dot2y

    var.w2dx1 = wiimote2.dot1x
    var.w2dy1 = wiimote2.dot1y

    var.w2dx2 = wiimote2.dot2x
    var.w2dy2 = wiimote2.dot2y

    // debug = 'W1 LED 1 ( ' + var.w1dx1 + ' ,' + var.w1dy1 + ' ) ' + ' W1 LED 2 ( ' + var.w1dx2 + ' ,' + var.w1dy2 + ' ) ' +  ' W2 LED 1 ( ' + var.w2dx1 + ' ,' + var.w2dy1 + ' ) ' + ' W2 LED 2 ( ' + var.w2dx2 + ' ,' + var.w2dy2 + ' ) '

    // CODE FOR MOBILE WIIMOTE - W1
    // Mobile Wii Remote wiimote1 looking at sensorbar2 on stationary wiimote2

    // Mobile wiimote IR pixel coordinates looking at stationary sensorbar w2 leds       (0,0) bottom left corner
    // w2 IR camera centre position located at middle of w2 sensorbar leds

    var.M_saveragex = (var.w1dx1 + var.w1dx2)/2
    var.M_saveragey = (var.w1dy1 + var.w1dy2)/2

    // for rotation calculations

    //ordinary coordinates for w1 transformations                                             (-512, -384) bottom left corner
    var.M_sanglex =  ( var.M_saveragex/512 - 1 ) * var.wiicameraxhalfFOV            // x positive to right of vertical
    var.M_sangley =  ( var.M_saveragey/384 - 1 ) * var.wiicamerayhalfFOV            // y positive up from horizontal


    // Twist gradient for artificial horizon as seen by mobile w1 camera                (0,0) bottom left corner
    var.twistgrad = ( var.w1dy2 - var.w1dy1)/( var.w1dx2 - var.w1dx1 )

    // NOTE: roll angle between +90 to -90 with atan function
    // The actual roll angle for the mobile w1 remote is opposite to the perceived artificial horizon roll angle
    var.M_roll = 0 - atan( var.twistgrad )


    // for translation calculations
    // stationary sensorbar2 led pixel separation distance as seen by mobile remote w1
    var.M_Sledbaselinepixeldist =  sqrt( ( var.w1dx1 - var.w1dx2)^2 +  (var.w1dy1 - var.w1dy2)^2 )

    // End mobile w1 code


    // CODE FOR STATIONARY WII REMOTE - W2
    // Stationary Wii Remote wiimote2 looking at sensorbar1 on mobile wiimote1          (0,0) bottom left corner

    var.S_maveragex = (var.w2dx1 + var.w2dx2)/2
    var.S_maveragey = (var.w2dy1 + var.w2dy2)/2

    // for rotation calculations
    // absolute x,y angle coordinates of mobile w1 camera centre as seen from stationary w2        (-512, -384) bottom left corner

    var.S_manglex = ( var.S_maveragex/512 - 1 ) * var.wiicameraxhalfFOV
    var.S_mangley = ( var.S_maveragey/384 - 1 ) * var.wiicamerayhalfFOV


    // for translation calculations
    // for w2 stationary camera centre axis to w1 mobile camera centre included angle as seen from stationary w2

    var.S_angleYP = sqrt(var.S_manglex^2 + var.S_mangley^2)

    // End stationary w2 code


    //********************************************************************************************************************
    // STATIONARY WII REMOTE w2 - YAW AND PITCH COMPONENT CALCULATIONS - WITHOUT ANY OFFSETS AND WITH SENSE CORRECTION

    var.S_yaw =   0 - var.S_manglex

    var.S_pitch =  var.S_mangley

    var.S_roll = 0


    //********************************************************************************************************************
    // MOBILE WII REMOTE w1 - YAW AND PITCH COMPONENT CALCULATIONS WITH ROLL RECTIFICATION

    // METHOD: Rotate the angle coordinate vector about the origin so the s2 artificial horizon is effectively level
    // Roll rectification rotation of coordinates is in the same sense as the actual mobile camera roll rotation


    var.M_Sxref =  var.M_sanglex * cos( var.M_roll ) - var.M_sangley * sin( var.M_roll )

    var.M_Syref =  var.M_sanglex * sin( var.M_roll ) + var.M_sangley * cos( var.M_roll )


    //*********************************************************************************************************************

    // MOBILE WII REMOTE w1 - YAW AND PITCH COMPONENTS AFTER ROLL RECTIFICATION AND SENSE CORRECTION

    var.M_yawangle = var.M_Sxref            // rectified yaw angle component

    var.M_pitchangle = 0 -  var.M_Syref     // rectified pitch angle component


    //*********************************************************************************************************************

    // ANGLE ROTATION SECTION

    // NET REAL YAW, PITCH & ROLL ANGLES as detected by the Mobile Remote looking at the Stationary Remote
    // One to One direct motion output
    // Angles in DEGREES
    // Based on Right Hand Coordinate System
    // PHYSICAL VIEW basis - Motion measured relative to the Stationary Wii Remote Axes Orientation


    var.yawout =   var.M_yawangle  +  var.S_yaw           // yaw positive is left of vertical

    var.pitchout = var.M_pitchangle - var.S_pitch            // pitch positive is up from horizontal

    var.rollout =  var.M_roll                                          // roll positive is anticlockwise from horizontal

    // debug = 'Mobile Controller Output Angles   (yaw, pitch, roll)    ( ' + var.yawout + ', ' +  var.pitchout + ', ' +  var.rollout + ' )'


    //*********************************************************************************************************************

    // OUTPUTTING ANGLES FOR APPLICATIONS

    // CUSTOM Angle Profile settings can be adapted here for particular applications/features
    // Examples of features include Smoothing, Deadband, Inversion, Mouseview, Sensitivity Bias and TrackIR emulation
    // TrueView has not been implemented
    // Note: ROLL may require inversion for applications based on a Left Hand Coordinate system

    //Custom Angle settings for Battle of Britain 2
    //Game settings, Options - Advanced - Game : check TRACKIR & VECTOR EXPANSION & VE Z AXIS MODE ( Z Axis or FOV mode as required)


     var.interimy  = 0 - 6 * var.yawout
     var.interimp = 6 * var.pitchout
     var.interimr = 0 - var.rollout


     FakeTrackIR.yaw =  Smooth( var.interimy , 5)

     FakeTrackIR.pitch = Smooth( var.interimp , 5)

     FakeTrackIR.roll  = Smooth( var.interimr, 5)


    //*********************************************************************************************************************

    // TRANSLATIONS SECTION


     var.M_Sobliquesemibaselinedist = var.S_ledbaseline/2*cos( var.S_yaw )

     var.M_Sbaselinehalfangle = var.wiicamangletopixel * var.M_Sledbaselinepixeldist /2

     var.twistaxisdistance = var.M_Sobliquesemibaselinedist/tan( var.M_Sbaselinehalfangle)

     var.zdistance =  var.twistaxisdistance * cos( var.S_angleYP )


    // REAL TRANSLATIONS
    // NET REAL X, Y & Z translations as detected by the Mobile Remote looking at the Stationary Remote
    // One to One direct motion output
    // Translations in CENTIMETRES
    // Based on Right Hand Coordinate System
    // PHYSICAL VIEW basis - Motion is measured relative from the centre point of the Stationary Wii Remote Camera


     var.xtranslation =  var.zdistance * tan( var.S_yaw )         // X positive is directed right of vertical

     var.ytranslation =  var.zdistance * tan( var.S_pitch )       // Y positive is directed up from horizontal

     var.ztranslation =  var.zdistance                            // Z positive is directed backwards on the horizontal

    //debug = ' Mobile Controller Output Translations  (x,y,z)   (' + var.xtranslation + ', ' + var.ytranslation + ', ' + var.ztranslation + ' )'

    //*********************************************************************************************************************

    // OUTPUTTING TRANSLATIONS FOR APPLICATIONS

    // CUSTOM Translation Profile settings can be adapted here for particular applications/features
    // Examples of features include Smoothing, Deadband, Inversion, Sensitivity Bias, Zooming and TrackIR emulation
    // TrueView has not been implemented
    // NOTE: TrackIR and FakeTrackIR Translation outputs need to be in METRES (refer GlovePie Help Manual)
    // NOTE: Z-axis motion may require inversion for applications based on a Left Hand Coordinate system

    //Custom Translation settings for Battle of Britain 2
    //Game settings, Options - Advanced - Game : check TRACKIR & VECTOR EXPANSION & VE Z AXIS MODE ( Z Axis or FOV mode as required)

     FakeTrackIR.x = Smooth(var.xtranslation/100, 5)

     FakeTrackIR.y = Smooth(var.ytranslation/100, 5)


    // FOV MODE - zooming for external view
    // FakeTrackIR.z = Smooth(  (0.6 - var.ztranslation/100 ) * 1.5 , 5)

    // Z AXIS MODE - zooming for cockpit instruments - internal view
     FakeTrackIR.z = Smooth(  (0.6 - var.ztranslation/100 ) * 1.5 , 5)


    // end translation section

  else // LED coordinate not detected

    // debug = 'W1 LED 1 ( ' + var.w1dx1 + ' ,' + var.w1dy1 + ' ) ' + 'W1 LED 2 ( ' + var.w1dx2 + ' ,' + var.w1dy2 + ' ) ' +  'W2 LED 1 ( ' + var.w2dx1 + ' ,' + var.w2dy1 + ' ) ' + 'W2 LED 2 ( ' + var.w2dx2 + ' ,' + var.w2dy2 + ' ) '  +  wiimote1.dot1vis + '  ' + wiimote1.dot2vis + '  ' +  wiimote2.dot1vis + '  ' + wiimote2.dot2vis


  end // stop

//***END OF GLOVEPIE PROGRAM***

« Last Edit: September 16, 2009, 05:13:06 AM by zainey »



Offline zainey

  • *
  • Posts: 64
  • Karma: +2/-0
    • View Profile
Hi,

The parts to construct the Wii "HammerHead" can be entirely sourced from Jaycar Electronics.

http://www.jaycar.com.au

The parts list.


  • 1 x    PLASTIC ENCLOSURE  -  GREY ABS  -  90 X 50 X 16MM  -  CAT. NO. HB6030 -  $4.95
     
  • 2 x    5mm INFRARED TRANSMITTING LED  -  940 nm  -  CAT. NO. ZD1945  -  $1.25 each    
                
            NOTE: Or other equivalent preferably with at least 40 degrees viewing angle
     
  • 1 x    2 X AAA CELL BATTERY HOLDER  -  CAT. NO. PH9226  -  $1.45

            NOTE: The lower side of the base of the battery holder must be filed/sanded so as to fit into the enclosure  
     
  • 1 x    SLIDER SWITCH  -  CAT. NO. SS0823  -  $1.45
     

Extras include: Two part epoxy, wires and batteries.

Thanks.
« Last Edit: September 15, 2009, 08:57:51 AM by zainey »



Offline benpaddlejones

  • Support Admin
  • *
  • Posts: 1178
  • Karma: +49/-0
    • View Profile
    • Inter.Connect.Ed
zainey
Great to see another Aussie Wii-inventer on the run. Any chance of a youtube video showing this in action?

benpaddlejones :)


See my full profile and links on my Google Profile: http://www.google.com/profiles/benpaddlejones


Offline zainey

  • *
  • Posts: 64
  • Karma: +2/-0
    • View Profile
Hi  Ben,


I would like to do it, but it may have to wait.  :-\    :)


I am a YouTube noob, and it will be my first time.   :-[ 


In the meantime I will practise my Johnny Lee presentation technique.


Thanks.




« Last Edit: September 17, 2009, 10:05:46 PM by zainey »