Maycuz / SnapmakerLightBurnHost

Snapmaker 2.0 10W laser camera in LightBurn
GNU General Public License v3.0
8 stars 1 forks source link

Position is fixed, can it not be? #1

Open tyeth opened 1 year ago

tyeth commented 1 year ago

Hey this is great, thanks for putting it out there! (Found it via the snapmaker forum)

About 6months ago I started using the API via browser and postman to do measurements of thickness over existing objects not in a centered spot. It was really helpful with awkward to position items, I'd just tape them down and do a measurement then adjust x/y position and re-measure without untaping object.

All the code seems to use fixed positions for image or measurement capture, and in my experience with the API snapmaker have changed the default position a couple of times. I think it's settled down since 4.4 so probably not important for image capture. I don't really care that much, more of an observation, as it seems like people are using it happily, but I thought I'd mention the main advantage to me was measuring the height of not-flat objects, e.g. imagine the back of a spoon, where I sampled a few positions and then tried a flat engrave, and later messing with the gcode to do z-altering while engraving.

What I'm imagining is if lightburn can give you the position to get a thickness measurement from, therefore ensuring accuracy, but also allowing different height working layers in the lightburn project more easily if the user is foolish enough to try such things.

On a related but side note, I was very curious to try depth mapping an entire object, along with using the camera at different positions to build up a 3d image plus "accurate" depth data.

Maycuz commented 1 year ago

Being able to measure thickness at specified coordinates would be a nice addition, and it is doable. The only downside is that the user would have to put in these coordinates manually, as there is no API or scripting interface available for LightBurn. Perhaps you have an idea of what this would look like, ideally?

As for the depth map: it would be pretty easy to write an application for this, I may play around with it when I have some time. That said, I don't think it really fits in this tool, unless it would be possible to somehow use the depth map in LightBurn.

tyeth commented 1 year ago

Yeah agreed on the depth map. I did consider using the gcode bed mesh leveling map to create a way of lightburn doing flat engraving and the marlin firmware adjusting Z automatically :)

As far as what I envisioned, I think there is a laser position and a cursor position so I was just imagining people would use the cursor position to provide a rough location for measuring (rough due to the offset between laser position on the workpiece and auto-focus triangulation beam position on the workpiece which is variable with height a little over the 50mm usable range). The user would tell the laser to move there(cursor position) and the user would then select measure, is that how it works now if I just didn't supply the x and y coordinates to the API?

On Mon, 19 Dec 2022 at 11:24, Mayco @.***> wrote:

Being able to measure thickness at specified coordinates would be a nice addition, and it is doable. The only downside is that the user would have to put in these coordinates manually, as there is no API or scripting interface available for LightBurn. Perhaps you have an idea of what this would look like, ideally?

As for the depth map: it would be pretty easy to write an application for this, I may play around with it when I have some time. That said, I don't think it really fits in this tool, unless it would be possible to somehow use the depth map in LightBurn.

— Reply to this email directly, view it on GitHub https://github.com/PolymerPrints/SnapmakerLightBurnHost/issues/1#issuecomment-1357495039, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTBZ4ZY5VLR7YEQWM5V2T3WOBAW3ANCNFSM6AAAAAATCVLHQA . You are receiving this because you authored the thread.Message ID: @.***>

Maycuz commented 1 year ago

Unfortunately the API requires the coordinates as arguments. It would be possible to request the current position from the printer and pass these as part of the request. The problem is that the status request on the API requires authentication with a token, which I have not gotten to work reliably yet.

tyeth commented 1 year ago

You've probably seen the thread on snapmaker forum about the API where it mentions that initially you need to poll really frequently (few seconds to 30seconds, can't remember, but watch wireshark) until the user clicks confirm on display, then your last token or the result is a long lived token. I think in earlier firmwares this was not the case and a long lived token was offered with any request to status and the user only accepted once. It seems now a token is given that is short-lived or not valid for anything except confirmation from user touchscreen, and only then can the token be used for normal things and is effectively long-lived. (Can't remember if it gives you a new token after user clicks confirm or if it's the one from the last status check)

Maycuz commented 1 year ago

Do you have a link? There's a good chance I have seen it, but if not it may be valuable information.

tyeth commented 1 year ago

This was the last page I was on, but did a lot more 6months ago including posting the wireshark trace, can't easily find that now (it might have been the lightburn forum not snapmaker forum), but this summarises the issue: https://forum.snapmaker.com/t/status-rest-api/27206/11

Maycuz commented 1 year ago

Not exactly what you wanted, but the "fixed position" can now be changed in a config file, see: https://github.com/PolymerPrints/SnapmakerLightBurnHost/issues/3. However, I still want to keep this open because it would be nice to be even more flexible; I just haven't had the time to dive into the REST API behaviour yet.