Setting up "modified" DenavitHartenberg (DH) parameters for
genserkins
1. Prelude
LinuxCNC supports a number of kinematics modules including one that supports a generalized set of serial kinematics commonly specified via DenavitHartenberg parameters.
This document illustrates a method to set up the DHparameters for a Mitsubishi RV6SDL in LinuxCNC using genserkins kinematics.
Note

This document does not cover the creation of a vismach model which, while certainly very useful, requires just as much careful modeling if it is to match the genserkins model derived in this document. 
Note

There may be errors and/or shortcomings — use at your own risk! 
2. General
With the proliferation of industrial robots comes an increased interest to control used robots with LinuxCNC. A common type of robot used in industry and manufacturing is the "serial manipulator" designed as a series of motorized joints connected by rigid links. Serial robots often have six joints as required for the six degrees of freedom needed to both position (XYZ) and orient (ABC or pitch, roll, yaw) an object in space. Often these robots have an arm structure that extends from a base to an endeffector.
Control of such a serial robot requires the calculation of the endeffector’s position and orientation in relation to a reference coordinate system when the joint angles are known (forward kinematics) and also the more complex reverse calculation of the required joint angles for a given endeffector position and orientation in relation to the reference coordinate system (inverse kinematics). The standard mathematical tools used for these calculations are matrices which are basically tables of parameters and formulas that make it easier to handle the rotations and translations involved in forward and inverse kinematics calculations.
Detailed familiarity with the math is not required for a serial robot since LinuxCNC provides a kinematics module that implements an algorithm called genserkins to calculate the forward and inverse kinematics for a generic serial robot. In order to control a specific serial robot, genserkins must be provided with data so that it can build a mathematical model of the robot’s mechanical structure and thus do the math.
The required data needs to be in a standardized form that has been introduced by Jacques Denavit and Richard Hartenberg back in the fifties and are called the DHParameters. Denavit and Hartenberg used four parameters to describe how one joint is linked to the next. These parameters describe basically two rotations (alpha and theta) and two translations (a and d).
3. Modified DHParameters
As is often the case, this "standard" has been modified by other authors who have introduced "modified DHparameters" and one must be very careful because genserkins uses "modified DHparameters" as described in the publication "Introduction to Robotics, Mechanics and Control" by John J. Craig. Beware there is a lot of information to be found on DHparameters but rarely does the author define which convention is actually used. In addition, some people have found it necessary to change the parameter named a to r and have thus added to the confusion. This document adheres to the convention in the above mentioned publication by Craig with the difference that joint and parameter enumeration begins with the number 0 in order to be consistent with genserkins and its HAL pins.
Standard and Modified DHParameters consist of four numeric values for each joint (a, d, alpha and theta) that describe how the coordinate system (CS) sitting in one joint has to be moved and rotated to be aligned with the next joint. Aligned means that the Zaxis of our CS coincides with the axis of rotation of the joint and points in the positive direction such that, using the right hand rule with the thumb pointing in the positive direction of the Zaxis, the fingers point in the positive direction of rotation of the joint. It becomes clear that in order to do this, one must decide on the positive directions of all joints before starting to derive the parameters!
The difference between "standard" and "modified" notations is in how the parameters are allocated to the links. Using the "standard" DHParameters in genserkins will not give the correct mathematical model.
4. Modified DHParameters as used in genserkins
Note that genserkins does not handle offsets to thetavalues — theta is the joint variable that is controlled by LinuxCNC. With the CS aligned with the joint, a rotation around its ZAxis is identical to the rotation commanded to that joint by LinuxCNC. This makes it impossible to define the 0° position of our robots joints arbitrarily.
The three configurable parameters are:

alpha : positive or negative rotation (in radians) around the Xaxis of the "current coordinate system"

a : positive distance, along X, between two joint axes specified in machine units (mm or inch) defined in the system’s ini file.

d : positive or negative length along Z (also in machine units)
The parameter sets are always derived in the same order and a set is completed by setting the dparameter. This does not leave the Zaxis of our CS aligned with the next joint! This may seem confusing but sticking to this rule will yield a working set of parameters. Once the dparameter is set, the Xaxis of ourCS needs to point to the axis of the next joint.
5. Numbering of joints and parameters
The first joint in LinuxCNC is joint0 (because in software counting starts with 0) while most publications start with the number 1. That goes for all the parameters as well. That is, numbering starts with a0, alpha0, d0 and ends with a5, alpha5 and d5. Keep this in mind when following a publication to set up genserkins parameters.
6. How to start
Convention is to start by placing the referenceCS in the base of the robot with it’s Zaxis coinciding with the axis of the first joint and its Xaxis pointing toward the next joint’s axis.
This will also result in the DRO values in LinuxCNC being referenced to that point. Having done so sets a0 and alpha0 to 0. The above mentioned publication (Craig) also sets d0 to 0, which is confusing when a displacement offset is needed in order to have the referenceCS at the bottom of the base. Setting d0 = to the displacement gives correct results. In this manner, the first set of parameters are alpha0 = 0, a0 = 0, d0 = displacement, and the Xaxis of the CS points to the axis of the next joint (joint1).
Derivation of the net set (alpha1, a1, d1) follows — always using the same sequence all the way to the sixth set (alpha5, a5, d5).
And thus, the TCPCS of the endeffector is sitting in the center of the hand flange.
7. Special cases
If the next jointaxis is parallel to the last then one could arbitrarily choose a value for the dparameter but there is no point in setting it other than 0.
8. Detailed Example (RV6SL)
Described below is a method to derive the required "modified DHparameters" for a Mitsubishi RV6SDL and how to set the parameters in the HAL file to be used with the genserkins kinematics in LinuxCNC. The necessary dimensions are best taken from a dimensional drawing provided by the manufacturer of the robot.
9. Credits
Thanks to user Aciera for all text and the graphics for the RV6SL robot!