The objective of this tutorial is to demonstrate the procedure for creating an inverse kinematics path defined as a sequence of planes / coordinate systems. Unlike forward kinematics paths this process is more complicated but represents the majority of motion planning with robots. This because it is more intuitive to define a trajectory using Target frames in 3D rather joint angles is 6D.

## Preparation Work

Create a spline curve in Rhino and import it into Grasshopper. Divide the curve into planes whereby the X-axis is along the tangent, Y-axis points towards the center of curvature and Z-axis is the perpendicular to previous two also known as binormal vector. Extract the points and tangent vectors and create a sequence of normal planes along the curve (there is most likely a simpler way to this). In a Robot Motion Task pass the list of planes and an initial pose configuration as seen in the figure above. Use the rest of the motion display machinery as presented in previous tutorials.

## Inverse Kinematics Paths

There are two inverse kinematics paths both defined by (n) planes which need to be solved for and one of the available set of solutions selected (imagine an n by 8 matrix). The pose option selects the particular row of solutions which retain the same base, elbow and wrist symmetries. The different between a Planes path and a Linear path is the interpolation between interim targets. In the first case it occurs in joint space and in the later in Cartesian space. In both cases the mathematical mechanism used is linear interpolation but because operating in different space the results are dramatically different.

In the figures above it possible to observe the following:

- Both path types meet the Target planes (at the origins) and both paths generally deviate from the original Spline curve in the interim locations.
- The traces of the Plane-path on the right are smooth curves, resembling piece-wise arc curves, while on the left the traces between targets are linear segments, exactly like a polyline.
- Something peculiar happens to the robot flange when the path flips 90deg between the second and third plane seen above. This type of sudden axis rotation is not always easily traceable unless one looks carefully.

The first observation with regards to segmentation / approximation is common to all CNC equipment and in fact in all of computation. We need to quantize notionally smooth objects (curves) into finite elements (coordinate frames) up to an approximate tolerance. The higher the number of samples the better the approximation. But choosing the tolerance level is not a type of the more the merrier proposition. It is relevant to the application such for example a few millimeters in case of milling or almost irrelevant for pick and place applications. Using insanely fine segmentation will hit the mechanical limits of the machine as it will not be able to accelerate, maintain speed and decelerate properly. Using very coarse stepping may result to sudden joint twists and other physical related surprises.

Plane paths are provided for compatibility with other robots that natively support this mode of motion. The ABB robot and code generation process, seen in a later episode, emulates this mode by inverse kinematics solution within the controller and absolute joint motion instructions. Needless to say this half of both worlds approach (joints + matrices) leads more frequently to unhappy situations.

So the general recommendation is to either use full forward joint motion paths or full inverse kinematics linear motion paths.

Last but not least we’ve hit the first major conceptual nightmare of robot motion planning which is related to interpolation of rotations. In fact unline positions, there multiple ways to interpolate rotations, or points on the unit sphere that is, including by matrix elements, Euler angles and quaternions. Jeneratiff uses spherical linear interpolation of quaternions which may or not be how your robot does it as this is often not very well or at all documented.

Long story short, always pay attentions not only to where the Z-axis on the flange is pointing towards but also one more axis such as the Y-axis. The transition between plane axes needs to be consistent, small and preferably smooth. This will ensure that the motors will not abruptly accelerate to match large angular changes or get confused as for example there are two way to make a 180deg rotation. Using planes directly from splines is not a good strategy as the curvature often rapidly changes direction about inflection points which result to sudden joint flips.