• Software Gimbals

    Numerical Gotchas

    The code doesn't like zero magnitude vectors. The current module version detects these and returns a zero vector [0,0,0]. These can occur when the arguments to the functions are zero vectors.

    An additional case occurs when the K vector is zero. This occurs when the cross product of the arguments to the Setup function is a zero vector.
    Let A= [0,0,1] and B= [0,0,1] Setup(A,B) returns [0,0,0].

    I'm considering a flag that if true would cause the zero K vector to be detected and a small dither values to each axis of on of the arguments and start the function over again.

    Sorting Out Issues Theory vs Application

    My first approach was to collect data from an IMU and apply the Rodrigues rotation formula. Some difficulty getting this to work has led to a different approach.

    • Find a small cardboard box and draw the various axis on the sides of the box with a magic marker, along with positive direction arrows.
    • For a given heading and dip angle calculate theoretical values for the magnetometer readings. Use the cardboard box on each of it's six sides to apply the theroretical values to the axis fot that orientation. The direction of the axis detemine the sign of the value.
    • Assuming positive results using the theoretical values, obtain data from an IMU and compare it to the theoretical values and take appropriate action to produce positive results.
    • First results of this proceedure:

      //Accelerometer data
      var Adata=[
      [0.00001,0,1],
      [-1,0,0.00001],
      [0.00001,0,-1],
      [1,0,0.00001],
      
      [0,0.00001,1],
      [0,-1,0.00001],
      [0,0.00001,-1],
      [0,1,0.00001],
      ];
      

    Note use of 0.00001 to avoid the zero value K vector problem previously disscussed
    and

    //Magnetometer data
    var Mdata=[
    
    [0.866,0.5,1.732 ],
    [-1.732,0.5,0.866],  
    [-0.866,0.5,-1.732 ],
    [1.732,0.5,-0.866],  
    
    [0.5,0.866,1.732 ],
    [0.5,-1.732,0.866],  
    [0.5,-0.866,-1.732 ],
    [0.5,1.732,-0.866],  
    
    ];
    

    The Rodrigues' Rotation Formula was applied to this data and produced:
    N= sample
    A= accelerometer vector
    K= roatation axis vctor

    N Aroll Apitch Ayaw Kroll Kpitch Kroll
    0.00 0.00 0.00 1.00 0.00 -1.00 0.00
    1.00 -1.00 0.00 0.00 0.00 1.00 0.00
    2.00 0.00 0.00 -1.00 0.00 -1.00 0.00
    3.00 1.00 0.00 0.00 0.00 -1.00 0.00
    4.00 0.00 0.00 1.00 1.00 0.00 0.00
    5.00 0.00 -1.00 0.00 -1.00 0.00 0.00
    6.00 0.00 0.00 -1.00 1.00 0.00 0.00
    7.00 0.00 1.00 0.00 1.00 0.00 0.00

    and
    Normed vectors
    M= test magnetometer data
    M1= transformed magnetometer data
    and Scalars
    Tilt degrees
    Heading degrees
    Dip degrees

    Mroll Mpitch Myaw M1roll M1pitch M1yaw Tiltdeg Heading Dip
    1.0.43 0.25 0.87 0.43 0.25 0.87 0.00 330.00 60.00
    -0.87 0.25 0.43 0.43 0.25 0.87 90.00 330.00 60.00
    -0.43 0.25 -0.87 0.43 0.25 0.87 0.00 330.00 60.00
    0.87 0.25 -0.43 0.43 0.25 0.87 90.00 330.00 60.00
    0.25 0.43 0.87 0.25 0.43 0.87 0.00 300.00 60.00
    0.25 -0.87 0.43 0.25 0.43 0.87 90.00 300.00 60.00
    0.25 -0.43 -0.87 0.25 0.43 0.87 0.00 300.00 60.00
    0.25 0.87 -0.43 0.25 0.43 0.87 90.00 300.00 60.00

    A sucessful test so far!
    The code follows:

    function test(){
     FF=require("Rodrigues").connect();
     var i;
     for(i=0;i<Adata.length;i++){
    // for(i=0;i<4;i++){
    
     A=FF.Setup(Adata[i],[0,0,1]);
       Theta=FF.theta;
       Kn=FF.Kn;
     A=FF.An;
     B=FF.RotVector(Mdata[i]);
       An=FF.An;
     heading=pirate*Math.atan2(-B[1],B[0]);
     if(heading<0)heading+=360;
     dip=pirate*Math.atan(B[2]/Math.sqrt(B[0]­*B[0]+B[1]*B[1]));
    console.log(i,',',A,',',Kn,',',An,',',B,­',',
     Theta,',',heading,',',dip);
    }//next i
    }
    
About