MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.14k stars 19.2k forks source link

Question about the transformation of auto bed leveling #2898

Closed BelovedTutu closed 8 years ago

BelovedTutu commented 8 years ago

Hello, I'm using the Marlin v1.0.2 with auto bed leveling. The command G29 and the auto bed leveling process have no problem, however when I'm printing a rectangular calibration cube, the vertical 'wall' of the cube incline toward the lowest point of the print bed, transforming the cube to a parallelepiped. It is as though even when the base of the print was did perfectly ( I have no issue printing the first layers and the last ones, they are all parallel to the print surface), the object was print vertically to the horizontal surface and not to the bed surface (which is tilted on purpose). Further simulation with the transformation algorithm in matlab give exactly the same issue.

Digging into the code of G29, I eventually arrived at this function in the file vector_3.cpp: matrix_3x3 matrix_3x3::create_look_at(vector_3 target) { vector_3 z_row = target.get_normal(); vector_3 x_row = vector_3(1, 0, -target.x/target.z).get_normal(); vector_3 y_row = vector_3::cross(z_row, x_row).get_normal();

//x_row.debug("x_row");
//y_row.debug("y_row");
//z_row.debug("z_row");

 // create the matrix already correctly transposed
matrix_3x3 rot = matrix_3x3::create_from_rows(x_row, y_row, z_row);

rot.debug("rot");
return rot;

} This function is used by the G29 command to create the equation of the bed level plan after measuring. The problem is I don't understand the logic behind the line vector_3 x_row = vector_3(1, 0, -target.x/target.z).get_normal();. Why would we impose the elements of the y_row like that? Indeed it's perpendicular to z_row, but I just can't see why it's like that. Thank you a lot for your help

AnHardt commented 8 years ago

Leaving the math aside for now. Is there a small possibility your printers coordinate system is not right handed?

BelovedTutu commented 8 years ago

No, my system is not right handed

AnHardt commented 8 years ago

Than that is the reason for correcting to the wrong direction. It works at 0-level but than corrects x/y to the wrong direction. Additionally you are mirroring your parts.

BelovedTutu commented 8 years ago

Thank you very much for your answer :) Now I feel like a chump for not noticing that :))

Any suggestion to how to change the correction to a left handed system?

KiteLab commented 8 years ago

No, I would never do that nonsense.

Roxy-3D commented 8 years ago

Any suggestion to how to change the correction to a left handed system?

You can invert any axis in the Configuration.h file. It doesn't matter where you put your origin. Once you do, make sure moving in the +X and +Y direction moves away from the origin. Then check out:

https://en.wikipedia.org/wiki/Cartesian_coordinate_system#Orientation_and_handedness

BelovedTutu commented 8 years ago

Thank you very much for all the helps :) Guess I'll try what you suggest :)

Good day to you all, :)

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.