LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org

Trajectory Planning

Trajectory planning, in general, is the means by which EMC follows the path specified by your G Code program, while still operating within the limits of your machinery. A G Code program can never be fully obeyed: for instance imagine you specify as a single-line program the move "G1X1F10". In reality, the whole move can't be made at F10, since the machine must accelerate from a stop, move toward X=1, and then decelerate to stop again. Sometimes part of the move is done at F10, but for many moves, especially short ones, the specified feed rate is never reached at all.

The basic acceleration and deceleration described above is not complex and there is no compromise to be made; in the INI file you specified machine constraints such as maximum axis velocity and axis acceleration and these must be obeyed by the trajectory planner.

Path Following

A less straightforward problem is that of path following. When you program a corner in G Code, the trajectory planner can do several things, all of which are right in some cases: it can decelerate to a stop exactly at the coordinates of the corner, and then accelerate in the new direction. It can also do what is called blending, which is to keep the feed rate up while going through the corner, making it necessary to round the corner off in order to obey machine constraints. You can see that there is a tradeoff here: you can slow down to get better path following, or keep the speed up and have worse path following. Depending on the particular cut, the material, the tooling, etc., the programmer may want to compromise differently.

G Code Commands

Previously in all versions of EMC, you could specify G64 or G61 in your G Code, which would turn blending on and off respectively. The amount of blending (and therefore the quality of the path following) was not directly controllable and was determined by machine constraint settings only. On low-speed machines that handle high acceleration, like mini mills, the results were quite good because very little blending is required on such a machine. On large heavy machines, though, the results were sometimes bad.

EMC2 is Better

Today with EMC2's new trajectory planner, the G Code programmer has complete control over the path following. The new trajectory planner still has exact stop mode (no blending at all, G61). This is where the similarities end. In continuous mode (G64) the planner will maintain the programmed feed rate as closely as possible, blending corners where necessary, but with the new requirement that at least some part of each programmed segment be followed (the old trajectory planner would often "blend away" entire program segments.)

The more important new feature is the G Code programmer's ability to specify how the above-mentioned compromise should be handled by the planner. Machinists are used to thinking in terms of dimension tolerances, so the planner in continuous mode (G64) now accepts a tolerance specification (Px.xxx) and follows the programmed path, diverging from it when necessary, but only by the specified tolerance. Like the exact stop (G61) and continuous (G64) commands, the tolerance command (G64 Px.xxx) can be used throughout the program to specify the path following appropriate for the particular cut.

Programming the Planner

The trajectory control commands are as follows:

G61 (exact stop mode)
G61 tells the planner to come to an exact stop at every segment's end. This ensures exact path following but the full stops can be harmful to the workpiece or the tooling, depending on the particular cut.

G64 (continuous mode)
G64 tells the planner to sacrifice path following accuracy in order to keep the feed rate up. This is necessary for some types of material or tooling where exact stops are harmful, and can work great as long as the programmer is careful to keep in mind that the tool's path will be somewhat more curvy than the program specifies.

G64 Px.xxx (blend tolerance mode)
G64 now takes a parameter specifying the path following tolerance to be obeyed during blending. If you are in inch mode and program G64 P0.05, you tell the planner that you want continuous feed, but at programmed corners you want it to slow down enough so that the tool path can stay within 0.05 inches of the programmed path. The exact amount of slowdown depends on the geometry of the programmed corner and the machine constraints, but the only thing the programmer needs to worry about is the tolerance. This gives the programmer complete control over the path following compromise. The blend tolerance can be changed throughout the program as necessary. Beware that a specification of G64 P0 has the same effect as G64 alone (above), which is necessary for backward compatibility for old G Code programs.

To better understand blend tolerance mode, consider the following picture. In it you can see the programmed path (dotted lines) and the path traversed with 3 different tolerance settings (the combination of gray and yellow lines). In yellow you can see the actual blending (or corner cutting) based on the blend tolerance setting. When the tolerance is smaller, the path is closer to the corner, but speed is also lower.




In order to test the new planner, jepler wrote a Python program that generated test ngc files which were intended to have pathological behaviors: large ratios between distances moved on different axes, reversals, changing from motion type to motion type on each move, changing the feedrate on each move, changing the arc plane for each move. The resulting ngc files were then run on stepper configurations with no headroom and sometimes with different maximums on each axis. This uncovered several constraint violations and blending bugs, all of which have now been fixed.

The above image shows one of the successfully-completed planner tests, running on a simulated XYZA machine.

Documenting the Trajectory Controller

An effort to understand the trajectory controller has resulted in simple tp notes.

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org
This page is read-only. Follow the BasicSteps to edit pages. | View other revisions
Last edited January 6, 2007 3:00 am by CPE-75-81-164-41.neb.res.rr.com (diff)
Published under a Creative Commons License