How are the coordinate frames and D-H parameters determined in industry? Does one use the CAD drawing of the arm or physically take measurements of the actual arm?
The DH parameters need to be as accurate as possible, and that means using dimensions from CAD. However, sometimes this is still not accurate enough. (The robot might not match the CAD exactly for various reasons.) In this case, we turn to kinematic calibration.
Put simply, kinematic calibration is taking measurements of the arm and adjusting the DH parameters accordingly. Although, this must be done in a very controlled and precise manner. (We don't just use a tape measure on the arm for example).
This can take various forms. For example if you have a very precise jig, you can make the arm touch known points on the jig. Or if you have a high-DOF arm you can fix the end-effector and move the rest of the joints through the arm's null space. Or you can simply instruct the arm to move to various configurations and measure the end-effector pose with high precision external sensors. Then you typically have a large minimization problem to solve. You need to back out new DH parameters that are most likely to give you the measurements you have seen.
To better understand kinematic calibration, the clearest source of information I could find on the subject is in the book "Robotics: Modelling, Planning and Control" by Bruno Siciliano, Lorenzo Sciavicco, Luigi Villani, Giuseppe Oriolo, chapter 2.11. Which requires a description of the arm in DH parameters, multiplying out the kinematics equation, partial differentiation w.r.t. each DH parameter, then a least-squares fit (with the left pseudo-inverse), then iterate.
But I was never able to get this technique to work for me. What did work was using PoE (Product of Exponentials). In PoE, the kinematic parameters of the model vary smoothly with changes in joint axes and can handle kinematic singularities naturally. I followed this paper and was successful in kinematically calibrating my 7 DoF arm:
I. Chen, G. Yang, C. Tan, and S. Yeo, “Local POE model for robot kinematic calibration,” Mech. Mach. Theory, vol. 36, no. 11/12, pp. 1215– 1239, 2001.
If you are dealing with an (existing) industrial robot, all of its nominal dimentions and all axis to axis distances are specified in its manual (e.g. Kuka). All industrial robot manufacturers do this, without exception. All values in the DH table come from this table.
In most cases, positive and negative directions of the axes are defined in the manual and/or are also marked on the robot iself. This already defines the orientation and direction of all Z axes in the DH convention, you just figure out the rest (basically the one remainig possible rotation) by yourself and fill out the table.
These are obviusly nominal values, the real measurments of the robot include assembly and manufacturing tolerances, load and temperature effects. these are disregarded in the DH Table / Convention and are added as compensation odr calibration values later on.
CAD is used as a first estimate. Often the kinematics (coordinate frames) are part of the design specification, and you can use those numbers directly. Where they are not, all mechanical design CAD packages have tools included for measuring positions and angles in the model.
Where the first estimate is not accurate enough, a process called kinematic calibration is used. There are many techniques, and as Chuck mentions, it is often difficult or impossible to directly measure distances of interest. A web search on the topic will give you an introduction.