BrianPeek.com

A Compendium of Random Uselessness
in Search

BalanceBoard Additions

Last post Wed, Jul 23 2008 10:24 AM by twobunnyrabbit. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • Mon, Jun 16 2008 1:42 PM

    • SJB
    • Top 50 Contributor
    • Joined on Mon, Jun 16 2008
    • Posts 3

    BalanceBoard Additions

    Hi congratulations on the release of 1.5.2, the board works great for me.

    After a little play this weekend I made a few additions that Id like to run by you and hope may be of some use to people:

       1. Addition of UK Stones measure (At my wife’s request)
       2. Output of Center Of Gravity (COG) via moments.

    With this accomplished I’m now trying to figure out how I can track a users orientation (via just the board) with the aim of using the board to walk around a 3D environment. At this stage any suggestions are more than welcome.

    The mods are as follows (taken from a tutorial im currently writing so apologies for bad grammar and style)

    Adding UK Stones measure to WiimoteLib 1.5.2

    Open up Datatypes.cs and add the following definitions to the public struct BalanceBoardState:

    /// <summary>
    /// Stones per sensor
    /// </summary>
    public BalanceBoardSensorsF SensorValuesSt;

    and

    /// <summary>
    /// Total stones on the Balance Board
    /// </summary>
    public float WeightSt;

    Next open up Wiimote.cs and add the following variable above the default constructor just below the Kg - Lb vars:

    // kilograms to stones
    private const float KG2ST = 6.35029318f;

    Next we are going to add the code that populates these definitions/variables

    Still within Wiimote.cs add the following code to the BalanceBoard case of the ParseExtension function just below the Kg - Lb equivalent code:

    mWiimoteState.BalanceBoardState.SensorValuesSt.TopLeft = (mWiimoteState.BalanceBoardState.SensorValuesKg.TopLeft / KG2ST);
    mWiimoteState.BalanceBoardState.SensorValuesSt.TopRight = (mWiimoteState.BalanceBoardState.SensorValuesKg.TopRight / KG2ST);
    mWiimoteState.BalanceBoardState.SensorValuesSt.BottomLeft = (mWiimoteState.BalanceBoardState.SensorValuesKg.BottomLeft / KG2ST);
    mWiimoteState.BalanceBoardState.SensorValuesSt.BottomRight = (mWiimoteState.BalanceBoardState.SensorValuesKg.BottomRight / KG2ST);

    The above block of code enables calls to be made to obtain values for each of the four sensors in exactly the same way as you would for Kg's and Lb's e.g.

    TopLeftInStones = ws.BalanceBoardState.SensorValuesSt.TopLeft;

    Finally for total weight in stones add the following line below the equivalent Kg / Lb definitions:

    mWiimoteState.BalanceBoardState.WeightSt = (mWiimoteState.BalanceBoardState.SensorValuesSt.TopLeft + mWiimoteState.BalanceBoardState.SensorValuesSt.TopRight + mWiimoteState.BalanceBoardState.SensorValuesSt.BottomLeft + mWiimoteState.BalanceBoardState.SensorValuesSt.BottomRight) / 4.0f;

    And there you have it your balance board will now cater for the UK Stones measure and calls can be made using equivalent code to that provided for Kg's and Lb's.

    Adding facility for COG to WiimoteLib 1.5.2

    Open up Datatypes.cs and add the following to public struct BalanceBoardState:

    /// <summary>
    /// The Balance Boards center of gravity
    /// </summary>
    public BalanceBoardCOG CenterOfGravity;

    Next add a new struct to Datatypes.cs to contain the COG X and Y values, like so:

    /// <summary>
    /// The Balance Boards center of gravity (float values)
    /// </summary>
    public struct BalanceBoardCOG
    {
    /// <summary>
    /// Balance Board center of gravity X value
    /// </summary>
    public float X;
    /// <summary>
    /// Balance Board center of gravity Y value
    /// </summary>
    public float Y;
    /// <summary>
    /// Balance Board center of gravity point value
    /// </summary>
    public PointF COG;
    }

    Next add the following variable definitions above the default constructor within Wiimote.cs:

    // length between board sensors
    private const int BSL = 43;

    // width between board sensors
    private const int BSW = 24;

    BSL is board sensor length and BSW is board sensor width. These points were obtained via measuring the distances between the centers of the boards feet. I am not brave enough to open my board up to get the exact values but these seem to work fine for me.

    Finally add the following chunck of code to the BalanceBoard case of ParseExtension:

    float Kx = (mWiimoteState.BalanceBoardState.SensorValuesKg.TopLeft + mWiimoteState.BalanceBoardState.SensorValuesKg.BottomLeft) / (mWiimoteState.BalanceBoardState.SensorValuesKg.TopRight + mWiimoteState.BalanceBoardState.SensorValuesKg.BottomRight);
    float Ky = (mWiimoteState.BalanceBoardState.SensorValuesKg.TopLeft + mWiimoteState.BalanceBoardState.SensorValuesKg.TopRight) / (mWiimoteState.BalanceBoardState.SensorValuesKg.BottomRight + mWiimoteState.BalanceBoardState.SensorValuesKg.BottomLeft);
    //
    mWiimoteState.BalanceBoardState.CenterOfGravity.X = ((float)(Kx - 1) / (float)(Kx + 1)) * (float)(-BSL / 2);
    mWiimoteState.BalanceBoardState.CenterOfGravity.Y = ((float)(Ky - 1) / (float)(Ky + 1)) * (float)(-BSW / 2);
    //
    mWiimoteState.BalanceBoardState.CenterOfGravity.COG.X = mWiimoteState.BalanceBoardState.CenterOfGravity.X;
    mWiimoteState.BalanceBoardState.CenterOfGravity.COG.Y = mWiimoteState.BalanceBoardState.CenterOfGravity.Y;

    This calculates the COG using moments. The values can then be obtained via the following calls:

    X = ws.BalanceBoardState.CenterOfGravity.X.ToString();
    Y = ws.BalanceBoardState.CenterOfGravity.Y.ToString();

    COG (as floating point) = ws.BalanceBoardState.CenterOfGravity.COG.ToString();

    Using COG your board can easily be adapted for use as a joystick. The X and Y values can also easily be plotted for a visual representation if required.

    Again I hope above is of use to someone, any suggestions and improvements are more than welcome, SJB

     



  • Mon, Jun 16 2008 4:28 PM In reply to

    Re: BalanceBoard Additions

    Awesome.  I love the COG stuff.  I'll be stealing both of these for the next release (with credit to you, of course)  Big Smile

    Thanks for sharing!

  • Tue, Jun 17 2008 4:42 AM In reply to

    Re: BalanceBoard Additions

    Just what I was looking for!! Looking into developing a balance assessment application to assess falls risk.

    Thank you Brian and SJB.

    Will post my progress for anyone who is interested.

     

     

  • Wed, Jun 18 2008 6:21 PM In reply to

    • SJB
    • Top 50 Contributor
    • Joined on Mon, Jun 16 2008
    • Posts 3

    Re: BalanceBoard Additions

     

    Thanks for the feedback guys and Brian I’m honoured you like my stuff. 

     

    Currently I am working on tying down user orientation and have a few methods that are beginning to look promising, Ill keep you updated as they progress. 

     

    twobunnyrabbit I for one would be very interested to hear about your progress.


  • Thu, Jun 19 2008 1:20 AM In reply to

    Re: BalanceBoard Additions

    SJB, do keep me informed...I'd like to add the user orientation stuff as well.

    And twobunnyrabbit, keep us updated as well.  I'd like to see how you use this.  I write a lot of health care apps in my real job life, one piece of which was a patient assessment module.  It would have been interesting to see it go from checkboxes and textboxes to something interactive like that.

  • Tue, Jul 8 2008 4:26 AM In reply to

    Re: BalanceBoard Additions

    Will do Brian. Just came back from a 2 week break. 

  • Thu, Jul 10 2008 8:35 AM In reply to

    Re: BalanceBoard Additions

    Had some time in the last couple of days to play around with it.

    My ultimate aim is to develop a "swaymeter" from the Wii Balance board as a tool to assess the risk of falls in elderly. It has been done commercially with similar devices such as "force platform board". I also have ideas with using the wiimote's IR camera, but that will come later.

    Had incorporated SJB's (thanks again) COG into Brian's source and recompiled the DLL.

    So far it can graphically display the COG inside a picturebox in real time and capturing the COG values (as Point) into a predefined array for a duration of 10s. Plotted the COG values onto a second picturebox to graphicaly represent the amount of "sway" with beziers.

    There's a few questions which I'd like to ask for those who had played around with their balance board.

    1. What are your default values from the 4 sensors? ( My values are as follow TL = 2.0 +/- 0.5; BL = 2.0 +/- 0.5; TR = 0 +/- 0.5; BR = 0 +/- 0.5)

    2. What is your baseline COG values (My values are COG.X = -21 +/- 0.5, COG.Y = 1.5 +/- 0.5; guess it relates to Q1.)

    3. Do you really need to calibrate the board? (I find when I stand on it and tried to get the circle in the middle of the picturebox, the respective COG cordinates comes to zero).

    4. What are the use of the BalanceBoardCalibrationInfo method?

    5. Anyway of getting the board to reconnect without having to do the synchronisation all over again? (I had read somewhere that its possible to use glovepie and bluesoleil, but this was for the wiimote).

    I dont have access to a second board to figure out some of the above questions. Once I have the basics and interface sorted out, will implement a database to store the values and various charts and graphs.

     Thanks

     

     

     

  • Tue, Jul 22 2008 4:19 PM In reply to

    • SJB
    • Top 50 Contributor
    • Joined on Mon, Jun 16 2008
    • Posts 3

    Re: BalanceBoard Additions

    Hi just a quick note to say I’m still about, but numerous work and PhD deadlines are forcing the orientation and stuff to take a back seat at the moment.

     

    For your ref my default readings on first poll are approximately:

     

    TL =  2.5

    TR = -1.5

    BL = -1.8

    BR = 2.9

     

    COGX = 8.39 to 11.28

    COGY = -1.56 to 2.95

     

    Within my wwii (wiimote windows) application I have an additional calibrate function that averages out the weight readings however with no weight applied I still have a COG offset to the right.

     

    As soon as weight is applied however everything evens out ok and I can quite easily manipulate a graphic to mimic my position.

     

    I do this with the following:

     

    int cogX = (int)(ws.BalanceBoardState.CenterOfGravity.X);

    int cogY = (int)(ws.BalanceBoardState.CenterOfGravity.Y);

     

    rather than the COG point:

     

    ws.BalanceBoardState.CenterOfGravity.COG

     

    Within wwii I have handled auto paring and detection upon holding down buttons 1+2 or sync (for the board) via usage of the freely available lib from in the hand (InTheHand.Net.Personal.dll).

     

    I have a little connection app that I plan to release with wwii very soon (August, I will finally be on my holl’s and will get some overdue focus time)

     

    Hope this is of some help

     

     

     

     

     

  • Wed, Jul 23 2008 7:00 AM In reply to

    Re: BalanceBoard Additions

    Thanks for the info. Will play around with the InTheHand library.
  • Wed, Jul 23 2008 10:24 AM In reply to

    Re: BalanceBoard Additions

    Hi

    Just had a go with the InTheHand library. Managed to get the app to sync and connect with the wiimote within the program. Saves the effort of manually connecting it through control panel. The only issue i found is that once the wiimote is registered as a HID device, any calls to make a re-connection (using BluetoothClient.Connect() method) does not work. I see a "Connect" momentarily in the Bluetooth device info and it disappears everytime i press the button to connect. The work around I found was to remove the device from the list and re-register it again. Not elegant, but it works Big Smile.  I havent tried it with the Balance board yet, but i think it should work.

     

Page 1 of 1 (10 items)
Copyright (C) 2008 Brian Peek
Powered by Community Server (Commercial Edition), by Telligent Systems