TatianaResend / SPIF-A_v2

Development of a compact incremental stamping machine.
GNU General Public License v3.0
1 stars 0 forks source link

Implementing inverse kinematics in code #18

Open TatianaResend opened 1 year ago

TatianaResend commented 1 year ago

Make a function that receives the spatial coordinates (x,y,z) and converts it into the necessary angle in the motors that control the y axis and the z axis.

TatianaResend commented 1 year ago

Follow the structure of this example:

void CinInv (double coordY_CI, double coordZ_CI) {
  //theta 2
  theta2 = -acos((((pow(120 - coordY_CI, 2)) + (pow(200 - coordZ_CI, 2)) - (pow(L1, 2)) - (pow(L2, 2)))) / (48000)); //48000 = 2*L1*L2
  //theta 1
  float posz = 200 - coordZ_CI;
  float posy = 120 - coordY_CI;
  float poszz = L2 * sin(theta2);
  float posyy = L1 + 200 * cos(theta2);
  theta1 = atan((posz) / (posy)) + atan((poszz) / (posyy));
  //converter para DEG
  theta1 = theta1 * (180 / PI);
  theta2 = theta2 * (180 / PI);
  //determinar pulsos a ser executados pelo motor
  finalposXYZ[0] = round(theta2 * 55.5555555); // 55.555555 = 100 * PulPerRev/360 conversão para pulsos com redutora de 100:1
  finalposXYZ[1] = round(theta1 * 55.5555555); // 100 * (PulPerRev/360)
  //atribuir as posições para mover às coordenadas recebidas
  posTomoveY = coordY_CI;
  posTomoveZ = coordZ_CI;
}
TatianaResend commented 1 year ago

Need to confirm redundancy. In both, I used the arm on top (positive). It is necessary to test with both engines and make a prototype (something simple) to make sure you are positioning it correctly.

TatianaResend commented 1 year ago

Confirm component D1 and D2 are correct. I think I wrote it wrong. The correct is:

TatianaResend commented 1 year ago

I need to have the prototype half assembled to be able to see if the kinematics are correct.

TatianaResend commented 1 year ago

It is essential to take into account the constraints defined by kinematics and be mindful that it will be necessary to implement a variable to apply the discount on z.

TatianaResend commented 11 months ago

The kinematics have been tested and are correct, however there are some positioning errors. These are due to gaps in the connections and essentially to the temporary connection made between the motors and the arms.