Open JensHauser opened 4 years ago
Is this functionality possible by writing a plug-in?
Thanks for the suggestion and everything is possible! 😁
This should be possible to implement as a plugin but might as well be implemented as a core functionality. This should probably be added using the processor API.
We have made a similar thing in the DRO allowing the use of expressions to calculate work positions using a JavaScript environment in GUIBackend:
If we define the variables machine_x
, machine_y
, machine_z
, work_x
, work_y
, work_z
in the script environment we could use the { }
as a general tag for parsing JavaScript and making it possible to use all kinds of arithmetics and logic.
We could then remove the { }
processing from MacroHelper as this would be more general.
One thing that we would need to solve is the {prompt|name}
function and needs to be investigated further if this could be executed from within the script environment.
And in case g code needs to be executed and we expect a result, e.g. current position after G38.2, it should wait for finished movement and make the result usable for calculating.
For future reference, this is how cncjs does it: https://github.com/cncjs/cncjs/blob/b1a82928294b6c82f63077e2bfee856c857636ce/src/server/lib/evaluate-assignment-expression.js
Good morning, I want to control an arm with two Z links via an arduino and GLBR. But GLBR is only programmed for linear axes and not angular connections. I would therefore like to make a macro which retrieves the coordinates of the points to be reached in the gcode, converting them via the inverse geometric model of my robot into angles. is it possible to do this via a macro in CNCJS?
@julien8745 please create a new discussion.
If you have questions regarding CNCJS I would recommend asking it on their project page: https://github.com/cncjs/cncjs
The coordinate can be in whatever unit you want. GRBL will report it in either metric or imperial units. But you can just as well treat it as degrees if you want to.
There is no macro function in UGS to do calculations. If it helps, you can record positions using this feature: https://github.com/winder/Universal-G-Code-Sender/pull/2307
Is it possible to add a macro and calculate a number based on current machine coordinates?
G43.1 Z{machine_z-1} or so would be helpful.
If not, do you have an idea how to come closer to this functionality?