TXBDan

05-19-2013, 04:55 PM

Hello all,

I'm working on trying to create my own hexapod program using the MarkII AX12 Hexapod hardware kit. I'm using the Commander libraries for external control input and the AX12 libraries to handle the servos.

I want the program to run at a certain frame rate. For each frame, I'm collecting command input, calculating the gait, running IK for the body and each leg, and updating the servo positions.

So far I have an IK function that works great for a single leg. I derived it using the multiplication of rotation matrices method from a textbook I have. The equations look a little gnarly and I wonder how much time it takes to crunch through. What is the best way for me to time this so that i can plan for my program's "frame rate".

void legIK(int leg, int X, int Y, int Z){

float tib1, tib2, fem1, fem2;

tib1 = (float)(sq(Y-LENGTH_COXA) + sq(X) + sq(Z)- sq( LENGTH_FEMUR) - sq(LENGTH_TIBIA) ) / (2*LENGTH_FEMUR*LENGTH_TIBIA);

tib2 = atan2( sqrt(1 - sq(tib1)) , tib1 );

fem1 = -atan2( Z , sqrt( sq(Y-LENGTH_COXA) + sq(X) ));

fem2 = atan2( LENGTH_TIBIA*sin(tib2) , LENGTH_FEMUR+LENGTH_TIBIA*cos(tib2) );

jointAngles[leg].femur = fem1 - fem2 + 1.571 - 0.237; // 90deg correction for my angular space - physical femur angle due to offset tibia servo mounting location

jointAngles[leg].coxa = asin( X / sqrt( sq(Y) + sq(X) )) + 1.571; // 90deg correction

jointAngles[leg].tibia = tib2 + 1.571 - 0.850 + 0.237; // 90deg correction - the tibia physical 60deg angle between servo mounting and foot + correction of femur offset

}

It looks like the stock NUKEcode from Trossen uses a lot of poses using the Bioloid libraries. Is this going to be too processor heavy for the Arbotix?

Any input or advice would be much appreciated!

I'm working on trying to create my own hexapod program using the MarkII AX12 Hexapod hardware kit. I'm using the Commander libraries for external control input and the AX12 libraries to handle the servos.

I want the program to run at a certain frame rate. For each frame, I'm collecting command input, calculating the gait, running IK for the body and each leg, and updating the servo positions.

So far I have an IK function that works great for a single leg. I derived it using the multiplication of rotation matrices method from a textbook I have. The equations look a little gnarly and I wonder how much time it takes to crunch through. What is the best way for me to time this so that i can plan for my program's "frame rate".

void legIK(int leg, int X, int Y, int Z){

float tib1, tib2, fem1, fem2;

tib1 = (float)(sq(Y-LENGTH_COXA) + sq(X) + sq(Z)- sq( LENGTH_FEMUR) - sq(LENGTH_TIBIA) ) / (2*LENGTH_FEMUR*LENGTH_TIBIA);

tib2 = atan2( sqrt(1 - sq(tib1)) , tib1 );

fem1 = -atan2( Z , sqrt( sq(Y-LENGTH_COXA) + sq(X) ));

fem2 = atan2( LENGTH_TIBIA*sin(tib2) , LENGTH_FEMUR+LENGTH_TIBIA*cos(tib2) );

jointAngles[leg].femur = fem1 - fem2 + 1.571 - 0.237; // 90deg correction for my angular space - physical femur angle due to offset tibia servo mounting location

jointAngles[leg].coxa = asin( X / sqrt( sq(Y) + sq(X) )) + 1.571; // 90deg correction

jointAngles[leg].tibia = tib2 + 1.571 - 0.850 + 0.237; // 90deg correction - the tibia physical 60deg angle between servo mounting and foot + correction of femur offset

}

It looks like the stock NUKEcode from Trossen uses a lot of poses using the Bioloid libraries. Is this going to be too processor heavy for the Arbotix?

Any input or advice would be much appreciated!