|
@@ -8457,18 +8457,18 @@ void prepare_move_to_destination() {
|
8457
|
8457
|
//SERIAL_ECHOPGM("f_delta x="); SERIAL_ECHO(f_scara[X_AXIS]);
|
8458
|
8458
|
//SERIAL_ECHOPGM(" y="); SERIAL_ECHO(f_scara[Y_AXIS]);
|
8459
|
8459
|
|
8460
|
|
- x_sin = sin(f_scara[X_AXIS] / SCARA_RAD2DEG) * Linkage_1;
|
8461
|
|
- x_cos = cos(f_scara[X_AXIS] / SCARA_RAD2DEG) * Linkage_1;
|
8462
|
|
- y_sin = sin(f_scara[Y_AXIS] / SCARA_RAD2DEG) * Linkage_2;
|
8463
|
|
- y_cos = cos(f_scara[Y_AXIS] / SCARA_RAD2DEG) * Linkage_2;
|
|
8460
|
+ x_sin = sin(RADIANS(f_scara[X_AXIS])) * L1;
|
|
8461
|
+ x_cos = cos(RADIANS(f_scara[X_AXIS])) * L1;
|
|
8462
|
+ y_sin = sin(RADIANS(f_scara[Y_AXIS])) * L2;
|
|
8463
|
+ y_cos = cos(RADIANS(f_scara[Y_AXIS])) * L2;
|
8464
|
8464
|
|
8465
|
8465
|
//SERIAL_ECHOPGM(" x_sin="); SERIAL_ECHO(x_sin);
|
8466
|
8466
|
//SERIAL_ECHOPGM(" x_cos="); SERIAL_ECHO(x_cos);
|
8467
|
8467
|
//SERIAL_ECHOPGM(" y_sin="); SERIAL_ECHO(y_sin);
|
8468
|
8468
|
//SERIAL_ECHOPGM(" y_cos="); SERIAL_ECHOLN(y_cos);
|
8469
|
8469
|
|
8470
|
|
- delta[X_AXIS] = x_cos + y_cos + SCARA_offset_x; //theta
|
8471
|
|
- delta[Y_AXIS] = x_sin + y_sin + SCARA_offset_y; //theta+phi
|
|
8470
|
+ delta[X_AXIS] = x_cos + y_cos + SCARA_OFFSET_X; //theta
|
|
8471
|
+ delta[Y_AXIS] = x_sin + y_sin + SCARA_OFFSET_Y; //theta+phi
|
8472
|
8472
|
|
8473
|
8473
|
//SERIAL_ECHOPGM(" delta[X_AXIS]="); SERIAL_ECHO(delta[X_AXIS]);
|
8474
|
8474
|
//SERIAL_ECHOPGM(" delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]);
|
|
@@ -8480,51 +8480,42 @@ void prepare_move_to_destination() {
|
8480
|
8480
|
// The maths and first version were done by QHARLEY.
|
8481
|
8481
|
// Integrated, tweaked by Joachim Cerny in June 2014.
|
8482
|
8482
|
|
8483
|
|
- float SCARA_pos[2];
|
8484
|
|
- static float SCARA_C2, SCARA_S2, SCARA_K1, SCARA_K2, SCARA_theta, SCARA_psi;
|
|
8483
|
+ static float C2, S2, SK1, SK2, THETA, PSI;
|
8485
|
8484
|
|
8486
|
|
- SCARA_pos[X_AXIS] = RAW_X_POSITION(cartesian[X_AXIS]) * axis_scaling[X_AXIS] - SCARA_offset_x; //Translate SCARA to standard X Y
|
8487
|
|
- SCARA_pos[Y_AXIS] = RAW_Y_POSITION(cartesian[Y_AXIS]) * axis_scaling[Y_AXIS] - SCARA_offset_y; // With scaling factor.
|
|
8485
|
+ float sx = RAW_X_POSITION(cartesian[X_AXIS]) * axis_scaling[X_AXIS] - SCARA_OFFSET_X, //Translate SCARA to standard X Y
|
|
8486
|
+ sy = RAW_Y_POSITION(cartesian[Y_AXIS]) * axis_scaling[Y_AXIS] - SCARA_OFFSET_Y; // With scaling factor.
|
8488
|
8487
|
|
8489
|
|
- #if (Linkage_1 == Linkage_2)
|
8490
|
|
- SCARA_C2 = ((sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS])) / (2 * (float)L1_2)) - 1;
|
|
8488
|
+ #if (L1 == L2)
|
|
8489
|
+ C2 = HYPOT2(sx, sy) / (2 * L1_2) - 1;
|
8491
|
8490
|
#else
|
8492
|
|
- SCARA_C2 = (sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) - (float)L1_2 - (float)L2_2) / 45000;
|
|
8491
|
+ C2 = (HYPOT2(sx, sy) - L1_2 - L2_2) / 45000;
|
8493
|
8492
|
#endif
|
8494
|
8493
|
|
8495
|
|
- SCARA_S2 = sqrt(1 - sq(SCARA_C2));
|
|
8494
|
+ S2 = sqrt(1 - sq(C2));
|
8496
|
8495
|
|
8497
|
|
- SCARA_K1 = Linkage_1 + Linkage_2 * SCARA_C2;
|
8498
|
|
- SCARA_K2 = Linkage_2 * SCARA_S2;
|
|
8496
|
+ SK1 = L1 + L2 * C2;
|
|
8497
|
+ SK2 = L2 * S2;
|
8499
|
8498
|
|
8500
|
|
- SCARA_theta = (atan2(SCARA_pos[X_AXIS], SCARA_pos[Y_AXIS]) - atan2(SCARA_K1, SCARA_K2)) * -1;
|
8501
|
|
- SCARA_psi = atan2(SCARA_S2, SCARA_C2);
|
|
8499
|
+ THETA = (atan2(sx, sy) - atan2(SK1, SK2)) * -1;
|
|
8500
|
+ PSI = atan2(S2, C2);
|
8502
|
8501
|
|
8503
|
|
- delta[X_AXIS] = SCARA_theta * SCARA_RAD2DEG; // Multiply by 180/Pi - theta is support arm angle
|
8504
|
|
- delta[Y_AXIS] = (SCARA_theta + SCARA_psi) * SCARA_RAD2DEG; // - equal to sub arm angle (inverted motor)
|
8505
|
|
- delta[Z_AXIS] = RAW_Z_POSITION(cartesian[Z_AXIS]);
|
|
8502
|
+ delta[A_AXIS] = DEGREES(THETA); // theta is support arm angle
|
|
8503
|
+ delta[B_AXIS] = DEGREES(THETA + PSI); // equal to sub arm angle (inverted motor)
|
|
8504
|
+ delta[Z_AXIS] = cartesian[Z_AXIS];
|
8506
|
8505
|
|
8507
|
8506
|
/**
|
8508
|
|
- SERIAL_ECHOPGM("cartesian x="); SERIAL_ECHO(cartesian[X_AXIS]);
|
8509
|
|
- SERIAL_ECHOPGM(" y="); SERIAL_ECHO(cartesian[Y_AXIS]);
|
8510
|
|
- SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(cartesian[Z_AXIS]);
|
8511
|
|
-
|
8512
|
|
- SERIAL_ECHOPGM("scara x="); SERIAL_ECHO(SCARA_pos[X_AXIS]);
|
8513
|
|
- SERIAL_ECHOPGM(" y="); SERIAL_ECHOLN(SCARA_pos[Y_AXIS]);
|
8514
|
|
-
|
8515
|
|
- SERIAL_ECHOPGM("delta x="); SERIAL_ECHO(delta[X_AXIS]);
|
8516
|
|
- SERIAL_ECHOPGM(" y="); SERIAL_ECHO(delta[Y_AXIS]);
|
8517
|
|
- SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(delta[Z_AXIS]);
|
8518
|
|
-
|
8519
|
|
- SERIAL_ECHOPGM("C2="); SERIAL_ECHO(SCARA_C2);
|
8520
|
|
- SERIAL_ECHOPGM(" S2="); SERIAL_ECHO(SCARA_S2);
|
8521
|
|
- SERIAL_ECHOPGM(" Theta="); SERIAL_ECHO(SCARA_theta);
|
8522
|
|
- SERIAL_ECHOPGM(" Psi="); SERIAL_ECHOLN(SCARA_psi);
|
8523
|
|
- SERIAL_EOL;
|
8524
|
|
- */
|
8525
|
|
- }
|
8526
|
|
-
|
8527
|
|
-#endif // SCARA
|
|
8507
|
+ DEBUG_POS("SCARA IK", cartesian);
|
|
8508
|
+ DEBUG_POS("SCARA IK", delta);
|
|
8509
|
+ SERIAL_ECHOPAIR(" SCARA (x,y) ", sx);
|
|
8510
|
+ SERIAL_ECHOPAIR(",", sy);
|
|
8511
|
+ SERIAL_ECHOPAIR(" C2=", C2);
|
|
8512
|
+ SERIAL_ECHOPAIR(" S2=", S2);
|
|
8513
|
+ SERIAL_ECHOPAIR(" Theta=", THETA);
|
|
8514
|
+ SERIAL_ECHOLNPAIR(" Phi=", PHI);
|
|
8515
|
+ //*/
|
|
8516
|
+ }
|
|
8517
|
+
|
|
8518
|
+#endif // MORGAN_SCARA
|
8528
|
8519
|
|
8529
|
8520
|
#if ENABLED(TEMP_STAT_LEDS)
|
8530
|
8521
|
|