Trajectory Planner Smoothing Noisy GCode

From Dynomotion

Jump to: navigation, search

GCode consisting of very short vectors and without enough digits of precision can result in GCode with sharp angles along the contour that aren't always obvious.  Here is an example of a path only ~ 0.02 inches long specified over 90 GCode Blocks:

G01 F100.0
X2.4343 Y0.0289 Z0.0646
X2.4343 Y0.0289 Z0.0655
X2.4344 Y0.0289 Z0.0665
X2.4344 Y0.0289 Z0.0671
X2.4345 Y0.0290 Z0.0679
X2.4345 Y0.0290 Z0.0686
X2.4346 Y0.0290 Z0.0694
X2.4347 Y0.0291 Z0.0702
X2.4347 Y0.0291 Z0.0708
X2.4348 Y0.0292 Z0.0715
X2.4349 Y0.0292 Z0.0720
X2.4349 Y0.0292 Z0.0726
X2.4350 Y0.0293 Z0.0734
X2.4351 Y0.0293 Z0.0739
X2.4352 Y0.0294 Z0.0743
X2.4353 Y0.0294 Z0.0748
X2.4353 Y0.0295 Z0.0752
X2.4354 Y0.0294 Z0.0756
X2.4355 Y0.0294 Z0.0760
X2.4355 Y0.0296 Z0.0764
X2.4356 Y0.0296 Z0.0768
X2.4357 Y0.0297 Z0.0772
X2.4357 Y0.0297 Z0.0775
X2.4359 Y0.0298 Z0.0782
X2.4360 Y0.0299 Z0.0789
X2.4362 Y0.0299 Z0.0795
X2.4363 Y0.0300 Z0.0801
X2.4364 Y0.0301 Z0.0807
X2.4366 Y0.0302 Z0.0812
X2.4367 Y0.0303 Z0.0818
X2.4369 Y0.0303 Z0.0823
X2.4370 Y0.0304 Z0.0828
X2.4371 Y0.0305 Z0.0833
X2.4373 Y0.0306 Z0.0838
X2.4374 Y0.0307 Z0.0842
X2.4376 Y0.0307 Z0.0847
X2.4377 Y0.0308 Z0.0851
X2.4378 Y0.0309 Z0.0855
X2.4380 Y0.0310 Z0.0860
X2.4381 Y0.0311 Z0.0864
X2.4383 Y0.0311 Z0.0868
X2.4384 Y0.0312 Z0.0872
X2.4385 Y0.0313 Z0.0875
X2.4387 Y0.0314 Z0.0879
X2.4388 Y0.0315 Z0.0883
X2.4390 Y0.0315 Z0.0886
X2.4391 Y0.0316 Z0.0890
X2.4392 Y0.0317 Z0.0893
X2.4394 Y0.0318 Z0.0897
X2.4395 Y0.0319 Z0.0900
X2.4396 Y0.0319 Z0.0903
X2.4398 Y0.0320 Z0.0907
X2.4401 Y0.0322 Z0.0913
X2.4403 Y0.0323 Z0.0919
X2.4406 Y0.0325 Z0.0925
X2.4409 Y0.0327 Z0.0930
X2.4412 Y0.0328 Z0.0936
X2.4415 Y0.0330 Z0.0941
X2.4417 Y0.0331 Z0.0947
X2.4420 Y0.0333 Z0.0952
X2.4423 Y0.0334 Z0.0957
X2.4426 Y0.0336 Z0.0962
X2.4429 Y0.0338 Z0.0966
X2.4431 Y0.0339 Z0.0971
X2.4434 Y0.0341 Z0.0975
X2.4437 Y0.0342 Z0.0980
X2.4440 Y0.0344 Z0.0984
X2.4442 Y0.0346 Z0.0989
X2.4445 Y0.0347 Z0.0993
X2.4448 Y0.0349 Z0.0997
X2.4451 Y0.0350 Z0.1001
X2.4454 Y0.0352 Z0.1005
X2.4456 Y0.0353 Z0.1009
X2.4459 Y0.0355 Z0.1012
X2.4462 Y0.0357 Z0.1016
X2.4465 Y0.0358 Z0.1020
X2.4468 Y0.0360 Z0.1023
X2.4470 Y0.0361 Z0.1027
X2.4473 Y0.0363 Z0.1030
X2.4476 Y0.0364 Z0.1034
X2.4479 Y0.0366 Z0.1037
X2.4482 Y0.0368 Z0.1040
X2.4484 Y0.0369 Z0.1044
X2.4487 Y0.0371 Z0.1047
X2.4493 Y0.0374 Z0.1053
X2.4498 Y0.0377 Z0.1059
X2.4504 Y0.0380 Z0.1064
X2.4509 Y0.0383 Z0.1070
X2.4515 Y0.0386 Z0.1075

The 3D XYZ Segment lengths are very short and plotted here:

GCode Block Lengths.png

The XYZ deltas show significant qunatization errors caused by being so small and only the 4 decimals of precision.

XYZ Deltas.png

XY View of the 3D Path.  Grid spacing is 0.0001 which is the resolution of the GCode.  Notice the Quantization to the grid points causes 90 degree angles in some cases because the vector lengths are so small.

GCode XY Path.png

Here is an extreme zoom in of the GCode plotted in simulation mode which performs no Trajectory Planning or smoothing.  Note the "zig-zag" motion along the path.

GCode Noisy Path.png

These Trajectory Planner settings shown have too small of allowed Collinear Tolerance to allow the Trajectory Planner to smooth the path.  A very small or zero tolerance forces the Trajectory Planner to closely follow the originally specified GCode path.  Because the resulting path is not smooth and angles > than the specified Break Angle limit of 15 degrees remain, exact stops occur at some points along the path.

TP Small BreakAngle Small Collinear Settings.png

Here the Collinear Tolerance has been increased to 0.0005 inches to allow more smoothing and the Break Angle has been increased to 60 degrees to avoid exact stops.  The resulting motion is now smooth without stops.

TP Good Settings.png