-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ruida driver: Support mirroring X Axis #198
Comments
If I remember correctly, this is supported only for certain lasercutter types. Please send a screenshot of your laser device settings in VisiCut.
|
Moving the issue to LibLaserCut (which is the library for the lasercutter drivers used by VisiCut). The ruida driver unfortunately does not have the "Flip X Axis" setting that your machine needs. Search for all lines with "flip" here: |
Checking back over here since I'm currently expanding the beta support for MeerK40t Ruida driver. ARRAY_EN_MIRROR_CUT = b"\xE7\x0B" But, these are not a solution. It seems that the real solution would be fix the coordinate system math. Basically a laser with a home position in the upper-left corner and a shape there is same as one flipped horizontally across the bed, for a laser in the upper-right. I don't seem to recall this being commonly used in Visicut. The way I ended up solving this for Meerk40t was to implement the 4point -> 4point math of design space to laser-bed space. Giving a perspective matrix (of which only an affine subset was needed mapping 3pt to 3pt). It's fairly easy to say your corner dots are flipped by replacing C0 with C1 and C2 with C3, and solving for the mapped matrix. def perspective(cls, p1, p2, p3, p4):
x1, y1 = p1
x2, y2 = p2
x3, y3 = p3
x4, y4 = p4
i = 1
try:
j = (y1 - y2 + y3 - y4) / (y2 - y3)
k = (x1 - x2 + x3 - x4) / (x4 - x3)
m = (y4 - y3) / (y2 - y3)
n = (x2 - x3) / (x4 - x3)
h = i * (j - k * m) / (1 - m * n)
g = i * (k - j * n) / (1 - m * n)
except ZeroDivisionError:
h = 0.0
g = 0.0
c = x1 * i
f = y1 * i
a = x4 * (g + i) - x1 * i
b = x2 * (h + i) - x1 * i
d = y4 * (g + i) - y1 * i
e = y2 * (h + i) - y1 * i
return cls(a, d, b, e, c, f) There are even some lasers like galvo scanners that can basically have things effectively rotated to the clockwise etc, and this sort of system to create 3x3 -> 3x3 matrices lets you easily fix the orientations (and scaling) before sending it to the driver. The problem here is not really a driver issue, it will often occur in basically any driver based on the direction of the stepper-motors. In a standard preamble you usually do both array_en_mirror_cut() and array_mirror. @kkaempf or @jnweiger may know what exactly those commands do. Other software that address this problem for Ruida like Lightburn, do include these commands but they are not flipped you change the home corner (rather it changes the design space).
Here's a standard very basic rectangle being sent over the Lightburn Bridge protocol. We have the mirror commands but they don't use other settings even when swapped. They just consider the left side the far side. To solve this within the driver it would require that we realtime-query the bed size and internal to the driver perform the matrix flip which does not seem to be the driver's job. |
I think that the current solution as in other drivers should do the job for now. Keep it simple as long as possible. LibLaserCut/src/main/java/de/thomas_oster/liblasercut/drivers/GenericGcodeDriver.java Lines 527 to 528 in c2bee3a
Once this does not work anymore, then we can create a helper class or similar for the transformations. This will probably have to be handled separately for raster engrave and for vector cutting. |
That should mostly work for most applications. With a couple caveats. It does sort of require that you use absolute positioning and that bed space and design space are uniform. There are a few lasers with potential xy-swapping, and it won't account for issues with slightly non-uniform scaling that sometimes will happen with belt stretching. But, yes 99% of the cases should be covered with those bits of code. Depending a bit on the laser for whether rasters would necessarily work. Though limiting things to isFlipAxis should give you mostly the same directions. Though if you do a vector bottom to top a y-flip becomes a top-to-bottom, since the bottom-to-top is really going max-y to min-y (and a y-flipped top-to-bottom is the same thing). |
Can confirm this bug on an OMTech Polar with the Ruida driver. I'll have time to have a closer look soon with the device. |
On my laser cutter, when I use VisiCut, the output is reversed of what it should be. It's mirrored left to right.
I think the reason is because my lasercutter has an origin in the top right. VisiCut seems to assume it's in the top left. Is there a setting I can use to configure the origin position (and direction!) correctly?
The text was updated successfully, but these errors were encountered: