### Kuka|prc and Planes

The software Kuka|prc is a plug-in to Grasshopper to control a Kuka industrial robot. PRC stands for Procedural Robot Control.Kuka|prc moves the robot using planes. You can think of a plane as an X, Y, Z axis system and an origin. You can roughly think of this as being similar to the CPlane in Rhino. You can re-orient the CPlane so it is rotated to align differently. You can also move the origin of the plane so the 0,0,0 point is somewhere else in world space. Planes in use with PRC are like that. There are X, Y and Z axes, which all are perpendicular to one another, and which can be oriented any way you wish. And you can move the origin of the plane to any location you choose.

The great thing, because it is so elegant, is that the robot will follow the planes wherever you place them - within reason. You can move a plane outside the reach of the robot and it, of course, can't get there. And robots have limits to the joint motion. So some points are unreachable. But within the joint limits, if the robot can physically reach a location, putting a plane there in virtual space will make the robot move there, and face the direction of the plane.

### A Simple Example

Moving the robot to a single point in space, facing a required direction, is the simplest motion we can make. The coordinate system of the tool is aligned with the plane. The point to move to is the origin of the plane.Here's a simple Grasshopper definition to do this:

The robot code is the standard we always use. You can read more about that set up in Robot Programming with Kuka|prc V3. In the configuration above the tool of the robot has the Z axis coming out from the center of the tool tip.

The plane to move to is created using the XY Plane component. This plane faces upward. Note that a Point component is wired into the origin of the plane. This lets you easily move the origin by dragging the Gumball widget in the viewport. (Note: When you assign the point, choose Coordinate from the command line menu. Use of Coordinate is what enables the Gumballs to work. If you aren't seeing the Gumballs after you select the Point component use the Grasshopper pull-down menu Display > Gumballs.)

The XY Plane is wired into the Plane socket of the LIN Movement component. This component generates the command to move to the point.

What happens is the tool axis is aligned with the plane. You can see that below - the robot moves from the Start Point to the plane we defined. Since the plane's Z axis is up, the robot faces upward:

If you wanted the robot to face downward you'd need to invert the Z axis of the target plane. You can do that with the Adjust Plane component. Note in the example below the Normal of the plane is set to the Unit Z component and the Factor of Unit Z is set to -1. That makes the Z vector point downward.

Now when the robot faces this plane it points down:

### List of Procedurally Generate Points (follow a Sine Wave)

In this example the robot moves between a series of points. The points are generated with the math function sine. Here's the bit of the definition which generates those points:A series of values are generated using the Series component. These are values for the X coordinate of the point. The X values are run through the Sine component. This generate the Y values. Those are wired into the Construct Point component to generate the full 3D point (Z defaults to 0).

Next these points need to be scaled up from very small to the size need to move the robot between them. They also need to be moved to a position the robot can reach. Here's that bit of the definition:

The Scale component is used to scale the points. Since they are generated starting at the origin, 0,0 is left as the default center to scale about. That way they simply move away from the center as they scale up. Next the points are moved to a position within range of the robot. This is done by the Move component. It takes the geometry to move (the list of points) and a vector to translate with. The vector is constructed using the Vector 2 Pt component. It generate a vector between the two specified points. The first is the origin (set as the value in socket A) and the second is a point the user can control. That let's the user simply select the Point component and drag that point in the viewport to place the sine curve wherever desired.

Next the points are converted to planes. This is done in the same way as the previous example, having the robot face downward by reversing the Z axis of the plane to point down using Adjust Plane with a negative Z axis. Then the planes are wired into the Linear Movement component to generate the list of linear motion commands.

Finally, the movement command list is wired into the Kuka Core component to simulate the motion and generate the code.

The result is the robot moves in straight lines between the points on the parametric sine curve.

### Using Data Trees to Traverse between Planes

The next example is a definition to draw a Voronoi diagram. Let's say for the sake of example into a clay surface. The robot end-effector is a "pin tool" - a needle point tool to scratch into the surface. The definition is fairly simple. The key to it is the Safe Plane component of Kuka|prc. It allows the robot to move up between etching each curve into the surface.Here's a Voronoi diagram draw over the points which generate it. That set of points is generated randomly in this example. For each point there is a corresponding region consisting of all points closer to that point than to any other. The diagram is the boundaries of those regions.

Here's an image showing the robot traversing between drawing the curves:

Looking at the definition, first up is to generate the curves of the diagram. Here's that bit:

The Voronoi component on the right takes a set of points as input. These are generated randomly in a rectangular region using the Pop2D component. Voronoi also takes a rectangular boundary for the cells as well as a plane. The rectangular region is generated by the Rectangle component. As we've seen several times before, the plane has a Point as input. This is the origin of the plane and the user can drag that points around in the viewport to locate the diagram to proximity of the robot.

Next up is converting the points to planes. This is similar to what was covered above with one important difference. The Voronoi diagram is a set of curves (a list of them in Grasshopper). The first thing we need to is generate the points at the corners of each curve. This is done with the Control Points component. For each input curve it will output the control points.

**Very important to note here is that the output of Control Points is a**You can see it is a data tree by the wire - it is shown as a dashed line. It's called a data tree because that's an easy way to visualize it - each curve is a branch in a tree. Each branch contains the points for that

*data tree*.*one curve*. The next branch has the points for that next curve.

As before the points are wired into a XY Plane component which is inverted using Adjust Plane.

The planes are wired into the Linear Movement component as before. The new part is the use of the Safe Plane component. It takes the motion commands as input. For each branch of the tree it generates additional movement commands to move above the first point in the branch and above the last points in the branch. It moves up to a specified "safe plane". This is a plane the user defines above the height of the diagram points. That essentially lifts the tool out of the work and above it to traverse over to the next curve to draw:

The key is that it does this independently for each branch in the data tree. Since each branch contains all the points to draw a single Voronoi cell, lifting up after and above the next point works perfectly.

Here again is the image showing the traverses (light gray) above the cells in the diagram: