Calculating path length

More
22 Nov 2019 19:45 #150962 by An
Calculating path length was created by An
I would like to calculate the length of the path taken by linuxcnc. My idea is to have a function in the kinematics that will Find the difference between x,y,z for each iteration of the code. And then use the distance formula to calculate the segment length between the two points. Does anyone know if it’s possible to do this? if so could you please give me an example of what the code would look like. I’m new to c so apologies if my terminology isn’t correct but hopefully you get the idea.

Thanks

Please Log in or Create an account to join the conversation.

More
22 Nov 2019 20:45 #150969 by PCW
Replied by PCW on topic Calculating path length
I guess you could also do this in a simple hal component
that calculated the distance in axis waypoints every servo thread
and summed it.

Please Log in or Create an account to join the conversation.

More
24 Nov 2019 20:35 #151137 by An
Replied by An on topic Calculating path length
Hmm so this hasn't grabbed too much attention! I have looked a lot for something done before and have had no luck finding anything. There isnt much info on way points either. I thought something similar would have been done before as it would let you create some additional axis function (say an extruder feed rate or perhaps a head that aligns to a path for engraving without a rotating cutter) from the information already being output from the traj planner. Maybe this is a bad idea?

Would really appreciate any and all help with this - thankyou!
The following user(s) said Thank You: Todd Zuercher

Please Log in or Create an account to join the conversation.

More
24 Nov 2019 20:59 - 24 Nov 2019 21:02 #151143 by PCW
Replied by PCW on topic Calculating path length
Way points are just the commanded axis positions (available as hal pins)
sampled every servo period.
I suspect you could get the path length by using the exiting hal components:

ddt, hypot and integ

ddt to get the velocity per axis
hypot to get the scalar speed from the three Cartesian velocities
integ to integrate the speed to distance travelled
Last edit: 24 Nov 2019 21:02 by PCW.
The following user(s) said Thank You: Leon82

Please Log in or Create an account to join the conversation.

More
24 Nov 2019 21:35 #151145 by PCW
Replied by PCW on topic Calculating path length
Here's a basic example (no guarantees)

loadrt ddt count=3
loadrt hypot
loadrt integ

addf ddt.0 servo-thread
addf ddt.1 servo-thread
addf ddt.2 servo-thread
addf hypot.0 servo-thread
addf integ.0 servo-thread

net posx axis.x.pos-cmd ddt.0.in
net posy axis.y.pos-cmd ddt.1.in
net posz axis.z.pos-cmd ddt.2.in

net velx ddt.0.out hypot.0.in0
net vely ddt.1.out hypot.0.in1
net velz ddt.2.out hypot.0.in2

net speed hypot.0.out integ.0.in
net distance integ.0.out

Please Log in or Create an account to join the conversation.

More
24 Nov 2019 21:52 #151147 by An
Replied by An on topic Calculating path length
Ok thanks for taking the time. So I would just tie the output of net distance to the relevant joint pin within this Hal component and it would move that joint the appropriate distance for what the other joints are doing at that time? This question may give you an insight into my capabilities or lack there of...

Thanks

Please Log in or Create an account to join the conversation.

More
24 Nov 2019 22:04 #151148 by PCW
Replied by PCW on topic Calculating path length
Not sure I understand, the _signal_ distance is the accumulated distance traveled
you can use it as you wish (but in general you could not connect it to a joint since joints
are output pins from motion) You could connect this to a step generator position command
for example.

I just realized, this can be done much simpler since motion provides a velocity (well really speed) pin

loadrt integ

addf integ.0 servo-thread

net speed motion.current-vel integ.0.in
net distance integ.0.out

Please Log in or Create an account to join the conversation.

More
24 Nov 2019 23:39 #151160 by tommylight
Replied by tommylight on topic Calculating path length
Since i am also not getting what exactly you want to achieve, maybe this will help:
In axis GUI, open a file, got to file>properties
there it always has the total distance travelled for the cutting path, not the rapid travel or Z axis travel.
It will also have the time it takes to finish that job at the given (in gcode) feed rate, again sans the rapid travel or probing or anything else.

Please Log in or Create an account to join the conversation.

More
25 Nov 2019 01:37 #151184 by An
Replied by An on topic Calculating path length
Ahh right sorry, il try be more specific. I would like to take the path length as output by linuxcnc and use this to control another axis, say an extruder. This could be done at the cam level, in the post processor or at the Linuxcnc level, the later being the most accurate as it deals with the real path length after all traj functions etc are applied.

So in my mind this is how i thought i could do it;

Put a line of code in the kins file that would pull the relevant pos-> information. Store this and on the next thread subtract the new value from the old. The difference can then be used to calculate the path length in cartesian space. This value would be applied to the extrude axis resulting in the interpolated motion of the extrude axis and the tool tip. This could also feed the wire for a welder if that was useful....

Sorry if im not doing a good job at explaining!

Please Log in or Create an account to join the conversation.

More
25 Nov 2019 14:43 - 25 Nov 2019 14:47 #151225 by PCW
Replied by PCW on topic Calculating path length
If you are using the path length for running an extruder, you probably don't need anything other than
what LinuxCNC's motion already provides, that is motion.current-vel could be used to drive a a step
generator setup in velocity mode and you would get an extrusion rate proportional to velocity,

Practically speaking you would probably want to delay the motion relative to the velocity signal because of the
time lag inherent in extruders, and perhaps provide some velocity signal processing to account for
extruders characteristics.
Last edit: 25 Nov 2019 14:47 by PCW.

Please Log in or Create an account to join the conversation.

Time to create page: 0.105 seconds
Powered by Kunena Forum