VRML Preparation for Robot Simulation

This tutorial explains how to use FreeCAD and the Robot Simulation Workbench to simulate the motions of 6-axis serial robot. The tutorial focuses on the creation of the vrml file used as visualization. The base of the vrml file is a FreeCAD model. The version of FreeCAD used is 0.11.4252ppa1 on Ubuntu 32bit.

Open a file or create one with FreeCAD
The tutorial is based on a STEP-file of a Stäubli TX40 (TX40-HB.stp). You can download the file from https://secure.staubli.com/Intranet_Applications/Robotics/Group/RobDoc.nsf/ea05b3f4b301f597c1256d5f005665e8/bc3707ec036c9f6bc12576c700327958/$FILE/page.html. However, though I still didn't have time to check this, the method should also apply to a model completely made in FreeCAD. After opening the file, you should obtain this:



Notice, that on import, the robot is made of 8 shapes, directly on the root of the document tree. The structure of the exported vrml file may change if groups are used. The shapes are ordered from the base to the tool. The last shape contains the axes of rotations of all robot axes. The correspondance shape name – part name is given by (as for now (March 2011) FreeCAD doesn't import the names included in STEP files):

For this import, change the “Display Mode” of each shape from “Flat Lines” to “Shaded” for the vrml export to look good. I also changed the colors to [245, 196, 0] to better correspond to Stäubli's yellow.

Measure geometric characteristics
In order to build the Denavit-Hartenberg table (see http://sourceforge.net/apps/mediawiki/free-cad/index.php?title=6-Axis_Robot) and prepare the vrml file, you need to get characteristics of the robot. For now, the measurement tool of FreeCAD is not ready, you can use the axes included in TX40_HB006 (the co-ordinates are indicated on the bottom left when you point an object with the mouse) or you have to use the Python console to get some information about the geometry. Note that the DH-table is only required if you need to use the inverse kinematics, i.e. get the Cartesian coordinates or drive the robot with Cartesian coordinates. The DH-table for this robot is the following (mm, deg and deg/s):

The csv file can be found here:.

Export to vrml
Export the document to a vrml file. The structure of the vrml file is the following:

Group { children Group { children [ Group { …        },         Group { …        },         Group { …        },         Group { …        },         Group { …        },         Group { …        },         Group { …        },         Group { …        } ]     } }
 * 1) VRML V2.0 utf8

You can notice that we have 8 independent groups corresponding to the 8 shapes. preparation of the vrml file All shapes in the vrml file are expressed in the base frame, independently from each other. For the Robot Simulation Workbench, we need to create a structure where a movement of a shape induces a movement of all shapes situated afterwards in the structure. The placement of the shapes will be relative to the preceding shape, so we need to include some translations from the absolute reference system to the relative one. The translations are described in the following picture:



With
 * A=(0, 0, 168)
 * B=(0, 107.8, 320)
 * C=(0, 104.15, 545)
 * D=(0, 35, 601)
 * E=(0, 35, 770)
 * F=(0, 35, 835).

Let's take the example of axis 4 between ELBOW and FOREARM, situated at D=(xd, yd, zd). The anchor for the FreeCAD axis is "DEF FREECAD_AXIS4 Transform { rotation 0 1 0 0 children [". This corresponds to a rotation about the y-axis. In the CAD model, the rotation is about the z-axis. Thus, we need to a rotation about the x-axis of $$\pi$$ before the FreeCAD axis definition and of $$-\pi$$ after it. Also, a translation of (-xd, -yd, -zd) is needed just before the Group corresponding to the definition of FOREARM to express it in the relative reference frame centered at D. This means that a translation of (xd, yd, zd) must be inserted before the first rotation. At the end, the vrml-file from the definition of ELBOW to the definition of FOREARM looks like this:

# ELBOW Group { … here comes the unmodified definition of ELBOW },      Transform { translation 0 35 601 rotation 1 0 0 1.5707963 children DEF FREECAD_AXIS4 Transform { rotation 0 1 0 0 children Transform { rotation 1 0 0 -1.5707963 children Transform { translation 0 -35 -601 children [ # FOREARM Group { ... here comes the unmodified definition of FOREARM }, At the end of the document, the appropriate closing brackets must be inserted: “ ]}}}},” for each of the 6 axes. The end of the document looks like this:

# TOOL FLANGE Group { ... here comes the unmodified definition of TOOL FLANGE },      Group { ... here comes the unmodified definition of TX40_HB007 } # the "]" was deleted from this line ]}}}},    ]}}}},     ]}}}},     ]}}}},     ]}}}},     ]}}}},     ] # this is the "]" that was deleted from the line above } }