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.
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.
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.
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.
The trajectory control commands are as follows:
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.