Calculating path length

More
6 years 11 months ago #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
6 years 11 months ago #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
6 years 11 months ago #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
6 years 11 months ago - 6 years 11 months ago #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: 6 years 11 months ago by PCW.
The following user(s) said Thank You: Leon82

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

More
6 years 11 months ago #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
6 years 11 months ago #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.

Time to create page: 0.217 seconds
Powered by Kunena Forum