AliEmad2002 / CNC

PCB printer CNC SW
GNU General Public License v3.0
0 stars 0 forks source link

Trajectory planning #7

Open AliEmad2002 opened 1 year ago

AliEmad2002 commented 1 year ago

To take things step by step, the following notes assume 0 jerk. Jerk is to be added when these are done. image Edited: θ is the tail-tail angle between the two vectors.

Moving G-code functions G0, G1 has only one speed related parameter, that is maximum feedrate. While in between line segments, speed should change according to the motion profile. Therefore, trajectory planning algorithm is needed.

Knowing that when wanting to move from point A to point B, given an initial speed Vi, final speed Vf and acceleration a, controller can easily apply the motion equation: V^2= Vi^2 + 2ax to get the speed at every segment of the line AB.

Vi is easy to get, as it is Vf of the previous movement. The thing we want to do is to find Vf of the movement AB.

Let Vb be the final speed at point B.

Let a point C be the next point to go to. This Vb is going to depend on the angle between lines AB, BC.

Notice that the more Vb is, the more the curvature error term ε is going to be.

We now need a function to estimate Vf at point, simplest assumption is: *Vf= Vmax cos(θ/2)**.

One other thing that should be considered, is that the output of the previous function can not be directly taken and used. It should be first checked such that machine can accelerate / decelerate to the following Vf, if it can’t, current Vf must be clamped.

AliEmad2002 commented 1 year ago

Flowchart of the "plan_trajectory()" function: image

AliEmad2002 commented 1 year ago

Speed estimation is not right!

Check the implementation.

AliEmad2002 commented 1 year ago

Wrong θ was used. now corrected and running right.

AliEmad2002 commented 1 year ago