Vous êtes sur la page 1sur 10

Page 1 of 10

Inverse kinematics tutorial

This tutorial will try to explain how to use the inverse kinematics functionality, while building a 7 DoF redundant
manipulator. The V-REP CAD data related to this tutorial (“redundantManipulator.stl”) is located in V-REP’s inst
allation folder’s “cadFiles” folder. A V-REP model related to this tutorial can be found in V-REP’s installation fol
der’s “models” folder. Click [Menu bar  File Import Binary STL…] then select the file to import. Please also
refer to the section on how to import/export shapes. A dialog pops open asking about the import options. Keep
checkboxes unchecked, and the Scaling coefficient to 1.0. Then click “Ok”. A single simple shape was import
ed and is located in the middle of the scene. The shape also appears in the scene hierarchy view on the left ha
nd side of the main window. Depending on how the original CAD data was exported, the imported CAD data co
uld be at a different scale, different location, or even subdivided into several shapes. The assigned color of imp
orted shapes is random. Following figure shows the imported shape:

As you can see, the import operation has left us with a single shape, where we expected several shapes. This
means that we will have to divide the manipulator object ourselves: select the object (just click on it in the scen
e or the scene hierarchy view), then click [Menu bar  Edit  Grouping/Merging  Divide Selected Shapes].
Following is what you should have:

mk:@MSITStore:C:\Program%20Files\V-REP\V-REP%20EVALUATION\system\V... 16.11.2010
Page 2 of 10

The original shape was divided into several sub-shapes (see also the scene hierarchy view). The shape divisio
n algorithm operates by grouping all triangles that are linked by common vertices. Depending on how the origin
al geometry was created or exported, such a division procedure cannot be performed. In that case you will hav
e to manually extract shapes in the triangle edit mode.

Next, we will change colors of the various objects so as to have a nice visual appearance. First double-click a s
hape icon in the scene hierarchy view. The shape properties dialog opens. While a shape is selected, click on
Outside faces in the dialog: this will allow you to adjust the various color components of the outside faces of th
e selected shape. For now, just adjust the ambient color component of your shapes. To transfer the color of on
e shape to another shape, select both shapes and make sure the last selected shape (indicated with a white bo
unding box) is the one you want to take the color from, then simply click the Apply to selection button in the C
olors section of the shape properties dialog. Feel free to adjust other visual parameters too, like the Shading a
ngle parameter, the Edges width or the Edges color. Once you finished coloring, you might have following sit
uation:

In next step, we will add the 7 joints of the manipulator. One way of doing this is to add the joints into the scen
e, then specify their appropriate position and orientation (through the coordinates/transformation dialog). This is
however not possible, when you don’t know the exact joint positions as in our case, and so we will have to “extr
act” them from the shapes that we have:

Select all imported shapes and click [Menu bar  Edit  Bounding Box Alignment  Align Selected Shapes’
Coordinate Frame with World]. This operation guarantees that our bounding boxes are aligned with the absolut
e reference frame, and given the current manipulator configuration, represents the smallest bounding boxes. Cl

mk:@MSITStore:C:\Program%20Files\V-REP\V-REP%20EVALUATION\system\V... 16.11.2010
Page 3 of 10

ick [Menu bar  Add  Joint  Revolute] to insert a revolute joint into the scene. The default position is at
(0;0;0) and its default orientation is vertical, and so the joint is hidden by the manipulator’s base cylinder. While
the joint is still selected, <CTRL>-select the base cylinder, then open the coordinates/transformations dialog wit
h [Menu bar  Tools  Coordinates/Transformations] or by clicking the appropriate toolbar button. In that dial
og, click the Apply to selection button as in following figure:

This just positioned the joint at the exact same coordinates as the base cylinder (this operation however only sli
ghtly adjusted the joint’s vertical position since it was already almost in position). Now repeat the procedure for
all other joints in the manipulator (remember there should be a total of 7). All joints are in position now, howeve
r, some of them have the wrong orientation. Select all joints that should be aligned with the world’s Y-axis, then
enter (90,0,0) for the Alpha, Beta and Gamma items in the coordinates/transformations dialog, then click the r
elated Apply to selection button (below the Alpha, Beta and Gamma items). Next, select the joint that should
be aligned with the world’s X-axis, then enter (0,90,0) for the Alpha, Beta and Gamma items in the coordinate
s/transformations dialog. All joints have the right position and orientation now.

You can now adjust the joint sizes (check the Joint length and Joint diameter items) in the joint properties dia
log (that you can open by double-clicking a joint icon in the scene hierarchy view). Make sure that all joints are
clearly visible. This is what you should have:

The next step in this tutorial is to group shapes that belong to the same rigid entity. Select the 5 shapes that ar
e part of link 1 (the base cylinder being “link 0”), then click [Menu bar  Edit  Grouping/Merging  Group Sel

mk:@MSITStore:C:\Program%20Files\V-REP\V-REP%20EVALUATION\system\V... 16.11.2010
Page 4 of 10

ected Shapes]. Remember that once grouped, a shape’s visual attributes cannot be changed anymore, unless
it is again ungrouped. Once the shapes are grouped in a grouped shape, you could re-align its bounding box wi
th the world, but this step is not required (and has only a visual effect). Repeat the same procedure with all sha
pes that logically belong together. In this tutorial we will not actuate the gripper’s fingers, and so simply rigidly g
roup them with the last link. When all shapes that are meant to be grouped share the same visual attributes, try
merging them together instead ([Menu bar  Edit  Grouping/Merging  Merge Selected Shapes]).

At this point you can rename all objects in the scene in following way, when going from base to tip: “redundant
Rob_link0” – “redundantRob_joint1” – “redundantRob_link1” – “redundantRob_joint2”, etc. Just double-click an
object’s name in the scene hierarchy view to edit its name.

Now we can build the kinematic chain, going from tip to base: select object “redundantRob_link7”, then <CTRL
>-select object “redundantRob_joint7” and click [Menu bar  Edit  Make Last Selected Object Parent]. Next
do the same for object “redundantRob_joint7” and object “redundantRob_link6”. Continue in a same way until t
he whole kinematic chain of the manipulator was built. This is what you should have (notice the scene hierarch
y view’s structure):

Select all joints, then open the object common properties dialog with [Menu bar  Tools  Object Common Pr
operties], or by pressing the appropriate toolbar button. In the Visibility layers section, disable layer 2 and ena
ble layer 10, then click the related Apply to selection button. This just sent all joints to the visibility layer 10, ef
fectively making them invisible. Have a look at the layer selection dialog if you wish to temporarily enable/disabl
e some layers.

Next, add a dummy object with [Menu bar  Add  Dummy]. Rename it to “redundantRobot”, then make it par
ent of object “redundantRob_link0”. This will be the real base of our manipulator.

Now we will define an inverse kinematics task for the manipulator. In V-REP, an IK task requires specification o
f at least following elements:
1) A kinematic chain described with a “tip” dummy and a “base” object.
2) A “target” dummy that the “tip” dummy will be constrained to follow.

We already have the “base” object (object “redundantRobot”). Let’s add another dummy, rename it to “redunda
ntRob_tip” and set its position to (0.324,0,0.62) using the coordinates/transformations dialog. Next, attach the d
ummy to “redundantRob_link7” (select “redundantRob_tip”, then “redundantRob_link7”, then click [Menu bar 
Edit  Make Last Selected Object Parent]. Our “tip” dummy is ready!

Now let’s prepare the “target” dummy: copy and paste “redundantRob_tip” and rename the copy to “redundant
Rob_target”. The “target” dummy is ready. Next, we have to inform V-REP that “redundantRob_tip” and “redun
dantRob_target” are a “tip-target” pair for inverse kinematics resolution. Double-click the dummy icon of “redun
dantRob_tip” in the scene hierarchy view: this opens the dummy properties dialog. In the Dummy-dummy link
section, specify “redundantRob_target” as Linked dummy. Notice how both dummies got linked through a red
stippled line in the scene hierarchy view (the two dummies are also linked in the scene through a red line, but s
ince both dummies are coincident, the line cannot be seen). In the same dialog, Link type is already “IK, tip-tar
get”, which is the default value. This is what you should have by now:

mk:@MSITStore:C:\Program%20Files\V-REP\V-REP%20EVALUATION\system\V... 16.11.2010
Page 5 of 10

At this stage, all elements for the definition of the inverse kinematics task are ready, and we just need to regist
er the task as an “IK group”. Open the inverse kinematics dialog with [Menu bar  Tools  Inverse Kinematic
s] or by clicking the appropriate toolbar button, and click Add new IK group. A new item appears in the IK gro
ups list: “IK_Group”. While that item is selected, indicate further down “redundantRob_tip” in the drop-down bo
x that says - Select a tip -, and click Add new IK element. Then indicate “redundantRobot” as the Base. Finall
y, make sure that all items are checked in the Constraints section (check Alpha-Beta and Gamma). Indeed,
we want our “tip” dummy to follow our “target” dummy in position and orientation. You are free to check the ite
m Mechanism is redundant, but at this stage, it won’t make any difference since no joint limits or obstacle avo
idance parameters have been defined.

mk:@MSITStore:C:\Program%20Files\V-REP\V-REP%20EVALUATION\system\V... 16.11.2010
Page 6 of 10

Close the dialog. Our inverse kinematics task is ready! Let’s test it. Run the simulation, then select “redundant
Rob_target”, then disable the click-selection toolbar button:

Then select the object shifting toolbar button:

Now drag the object with the mouse: the manipulator should follow. Also try the object rotation toolbar button:

Switch back to the object shifting toolbar button, and try to drag the object as far as possible, and notice how th
e inverse kinematics task “breaks”. Indeed, this happens when a configuration is singular or not reachable, how
ever there are workarounds to this behavior: while the simulation is still running, re-open the inverse kinematics
dialog, select “IK Group” in the upper list, then specify “DLS” for the Calculation method item. Drag the object
out of reach and notice how the inverse kinematics resolution became “more stable”. Try adjusting the DLS da
mping item up and down. Basically, when damping is large, resolution becomes more stable but slower. Practi
cally, you can get the advantages of both resolution methods, all you need to do is define two identical “IK grou
ps”, where the first is not damped and the second is damped. Then, for the second “IK group”, you can specify
a conditional resolution (e.g. “Perform if previous IK group was performed and failed”). Now set back the Calcu
lation method item to “Pseudo inverse”.

Now select “redundantRob_tip” in the IK element tips section of the dialog, then try to disable some of the Co
nstraints items and notice how the manipulator behaves when the “redundantRob_target” object is dragged or
rotated. Once you experimentated enough, reset all Constraints items to “checked”, then stop the simulation.

What we will now do is add a way to easily manipulate the robot, without having to worry about breaking it by s
hifting the wrong objects around. We will therefore define it as a model. First, move “redundantRob_tip” and “re
dundantRob_target” to layer 11 to make both dummies invisible. Then shift-select all visible objects in the scen
e view, ctrl-click the object “redundantRobot” in the scene hierarchy view to remove it from the selection, then o
pen the object common properties dialog. Check the Select base of model instead item, then the related App

mk:@MSITStore:C:\Program%20Files\V-REP\V-REP%20EVALUATION\system\V... 16.11.2010
Page 7 of 10

ly to selection button. Clear the selection with <ESC>, then select “redundantRobot”. In the dummy properties
dialog, check the Dummy is model base item, then close the dialogs. Notice how a stippled bounding box no
w encompasses the whole manipulator:

Click any object on the manipulator and notice how the base dummy (“redundantRobot”) always gets selected i
nstead. Now open the coordinates/transformations dialog (make sure that “redundantRobot” is selected), and u
ncheck Along Z, About X and About Y in the Object Manipulation Mode Permissions section:

When you now try to shift or rotate the robot in the scene (using the object manipulation toolbar buttons), it will
always stay on the floor, and keep a proper orientation. Try it! (then make sure you reset it to its initial position/
orientation with the undo toolbar button).

mk:@MSITStore:C:\Program%20Files\V-REP\V-REP%20EVALUATION\system\V... 16.11.2010
Page 8 of 10

Next, let’s add a “manipulation sphere” that we will use to manipulate the robot’s gripper position/orientation. Cl
ick [Menu bar  Add  Primitive Shape  Sphere] to open the primitive shape dialog, indicate 0.05 for the X-
Size, Y-Size and Z-Size, then uncheck the Pure primitive (for dynamics) item and click OK. Adjust the newly
added sphere’s position to be the same as “redundantRob_target” (using the coordinates/transformations dialo
g). The sphere now appears at the tip of the manipulator. Rename the sphere to “redundantRob_manipSpher
e”, then make it parent of “redundantRob_target”. When you now run the simulation, you should be able to cha
nge the manipulator’s configuration by moving the manipulation sphere around. Stop the simulation again.

Let’s change a few other details. In the shape properties dialog, click Outside faces, then check the Transpar
ency item. Notice how the sphere appearance changed. Two other settings needs to be changed before the sp
here appears transparent: check the Backface culling item in the shape properties dialog, then in the object c
ommon properties dialog click Set to last pos. in the Rendering order section: our manipulation sphere now a
ppears transparent!

In the same dialog uncheck all items in the Object special properties section (this is because the manipulatio
n sphere doesn’t really belong to the manipulator, it is more of a user-interface element). Now make “redundant
Robot” parent of “redundantRob_manipSphere”:

In the final step of this tutorial, we will register a “collision object” that should detect collisions between the mani
pulator and its environment. What we want is for every single shape (except for the manipulation sphere) in the
manipulator to be able to detect a collision with the environment. Let’s first define a collection for our manipulat
or:

Open the collections dialog with [Menu bar  Tools  Collections] or by clicking the appropriate toolbar butto
n. Select “redundantRobot”, then click Add new collection. A new, empty collection was added. We now need
to define the collection content: click Tree (selection). Notice how the collection’s content changed. Now click
the newly added collection item: all objects composing the manipulator get a pink color in the scene! Rename t
he collection to “redundantRob”. This is what you should have:

mk:@MSITStore:C:\Program%20Files\V-REP\V-REP%20EVALUATION\system\V... 16.11.2010
Page 9 of 10

Now that the “redundantRob” collection is defined, we can register a collision object: open the collision detecti
on dialog with [Menu bar  Tools  Collisions] or by clicking the appropriate toolbar button, then specify “redu
ndantRob [Collection]” in the Check entity drop-down box. Finally click Add collision object and rename the
newly added collision object to “redundantRob”. Close the dialog.

Collapse the “redundantRobot” tree in the scene hierarchy view. Your redundant manipulator model is ready!

Run the simulation, and copy-paste a few times the manipulator. Shift/rotate the copies around, and change th
eir configurations by dragging their manipulation spheres. Notice how every robot instance is fully functional, a
nd how collisions are indicated with a color change. Open the inverse kinematics dialog, the collection dialog a
nd the collision detection dialog. Notice how the listed items have also been automatically duplicated. Stop the
simulation.

The procedure to register a minimum distance object is very similar to the collision object registration here abo
ve. All registered objects (collision detection, collections, IK groups, etc.) and all scene objects can be accesse
d through appropriate API calls. Additionally, they can be directly recorded and visualized by graph objects.

mk:@MSITStore:C:\Program%20Files\V-REP\V-REP%20EVALUATION\system\V... 16.11.2010
Page 10 of 10

mk:@MSITStore:C:\Program%20Files\V-REP\V-REP%20EVALUATION\system\V... 16.11.2010