## 2 Virtual 3D Modeling of Articulated Mechanisms
### Modeling the Articulated Mechanism  
A typical articulated mechanism consists of a base (link 0) and a series of body links connected by joints. To describe this mechanism, we use different coordinate frames. Thus, every body links to an orthogonal coordinate system, which is fixed to the particular body link. There are two coordinate systems associated with every joint, which have common origins. One of these frames is fixed to the previous link, and the other to the next link (Figure 6a). The relative position of these frames can be described using a common joint axis and a rotation angle/translational displacement, by which one joint frame is displaced with respect to the other. Figure 6a shows the simple case of a revolute joint. To define the next link coordinate frame defined by the corresponding rotation matrix, we start from the current frame rotation matrix and use pre-transforms to transform it to overlap with the current joint frame fixed to the current link. These transforms usually consist of translations that move the origin of the current link frame to the origin of the joint frames and the rotation of the translated frames to align with the joint frame, which is fixed to the current frame. Next, a drive transform is applied; this typically consists of the rotation or translation of the other  
Figure 5: (**a**) The menus used to inert an element or attribute; (**b**) dialog window for selecting the element that will be inserted into the tree. Figure 6: (**a**) The coordinate frames associated with connected body links; (**b**) the XML segment describing the joint’s next link transform. joint frame around/along the joint axis. Finally, we apply the post-transform, which aligns the other joint frame with the next link body frame. These transforms can be succinctly described by the XML tree segment shown in Figure 6b. Figure 7 depicts the translation and rotation elements. They are used in Figure 6b to transform the previous link frame to the drive element, and produce drive elements for the next link frames. Often, transforms along the body links are much simpler. Thus, a joint coordinate frame fixed to the previous link can be used simultaneously as the link frame. In this case, pre- and/or post-transforms are not necessary (they are identity transforms); only the drive transform is needed. The <drive/> element represents the link driver, which can be real or virtual. In any case, it is defined by the type attribute, which can be one of the following driver types: prismatic_x, prismatic_y, prismatic_z, revolute_x, revolute_y, revolute_z, or spherical. The first six types correspond to joints with a single degree of freedom, and the last refers to rotation with three degrees of freedom about an axis through the center of the joint. After the rotation matrix of the next link frame is defined by the above transforms, we need to describe the geometry of the next link. We may use different geometric elements such as cuboids, cones, cylinders, and bodies of revolution for this purpose. All such elements are the children of the next joint, and thus they use as the reference frame the frame of the next body link, the id of which is defined by the link element in Figure 6b. Hence, all of these elements have to follow the link element. All of these elements have a unique id attribute, which is used to refer to them. There is a special element known as assembly. The geometric elements are added to it by referring to them by their ids. In this way, all of the subsequent body link geometric elements can be referred to as units according to the assembly id attribute. We can also use it to transform the position and orientation of the added elements with regard to the reference frame. The articulated mechanism's parts typically have complex shapes and are usually generated using 3D CAD software (e.g., SolidWorks, Catia, etc.) [84], from which they can be exported in the form of STL files. This is the case with many robots, including the Robotino.