Tutorial #4- Importing and Preparing Rigid Bodies

advertisement
Virtual Robot Experimentation Platform
Tutorial #4- Importing and Preparing
Rigid Bodies
Version 3.0.5
Landstown High School Governor’s STEM & Technology Academy
Robotics Pathway
Importing and preparing rigid bodies
tutorial
This tutorial will try to explain how meshes (rigid bodies) can be imported
and prepared for correct appearance and efficient simulation.
The V-REP CAD data, which is courtesy of Cubictek Corp., related to this
tutorial ("vehicle.obj") is located in V-REP's installation folder's "cadFiles"
folder.
Click [Menu bar --> File --> Import --> Mesh...] then select the file to
import.
Also refer to the section on how to import/export shapes.
A dialog pops open asking about mesh scaling and mesh orientation.
Click Ok.
A single simple shape was imported and is located in the middle of the
scene. The shape also appears in the scene hierarchy. Depending on how
the original CAD data was exported, the imported CAD data could be at a
different scale, different location, or even subdivided into several shapes.
The assigned color of imported 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 (one shape per wheel, etc.). This
means that we will have to divide the vehicle object ourselves:

select the object (just click on it in the scene or the scene
hierarchy),

then click [Menu bar --> Edit --> Grouping/Merging --> Divide
selected shapes].

Following is what you should have:

The original shape was divided into 7 sub-shapes (see also the
scene hierarchy).
o The shape division algorithm operates by grouping all
triangles that are linked by common vertices. As it seems,
the 3 rectangular shapes at the front of the vehicle are still
part of the vehicle body.

Let us manually extract those cuboids; deselect all objects by
pressing <ESC>

then select the vehicle body and click on the “Shape Edition” Icon

next click on the triangle edit mode. You can now see (and edit)
the triangles composing the selected shape.

Open the layer selection dialog and deactivate the first layer: now
only the triangles and the floor remain visible:
Switch to page 3 (by clicking the appropriate toolbar button) and come
closer with the camera using the fit-to-view toolbar button:
Select the front triangles of the vehicle with two consecutive shiftselections:
Switch back to page 1, and make sure that all triangles part of the cuboids
at the front of the vehicle are selected:

Then click the Extract shape button in the shape edit mode
dialog.
o This just added a new shape to the scene.

Press the delete key to delete the selected triangles,

and activate the first layer again:

the new shape becomes visible.

Leave the triangle edit mode.

This is what you should have:

Here again, the extracted shape has a random color.

The extracted shape itself could now be subdivided as we
previously did with the imported shape, but why should we?

Subdivision is only necessary if shapes are not rigidly fixed
together, or when shapes require different visual attributes (colors,
edges, etc.).

Select now the left wheel and enter the edge edit mode.

Deactivate layer 1.

To select edges, use the ctrl key combined with a mouse click.
o Make sure the automatic edge following mode is selected.

Then ctrl-select the edge as shown in yellow in following figure:

Then switch to the vertex edit mode and shift-select the vertex at
the center of the wheel.

Finally, switch to the triangle edit mode:

Now click Extract shape in the shape edit mode dialog,

then press the delete key to remove selected triangles.

Leave the triangle edit mode and apply changes.

Enable the first layer.

The wheel now is made-up by two shape objects.

Do the same for the right wheel.
Next, we will change colors of the various objects so as to have a nice
visual appearance.

Double-click any shape icon in the scene hierarchy.

The shape properties dialog opens.

While a shape is selected, click on the Adjust outside color
item in the dialog:
o this will allow you to adjust the various color components
of the outside faces of the selected shape.

For now, just adjust the ambient color component of your
shapes.

To transfer the color of one shape to another shape, select both
shapes and make sure the last selected shape (indicated with a
white bounding box) is the one you want to take the color from,
then simply click the Apply to selection button in the Colors
section of the shape dialog.

Feel free to adjust other visual parameters too. Once you
finished coloring, you might have following situation:

At this point, you could start grouping together all shapes that are
part of the same rigid entity (our vehicle has 3 rigid entities:
o
2 wheels and the rest).

There is however one intermediate step that is
required when you wish your shapes to be
dynamically simulated. Indeed, dynamics (collision
response, etc.) could directly operate on triangular
meshes (i.e. simple shapes), but in that case
calculations take much calculation time and results
are not always satisfying (unstable). Best is to use
exclusively pure shapes for dynamics calculations
(refer to the section on designing dynamic simulations
for more information): they perform much faster and
are more stable.
We will now prepare a simplified model that will be used only for
dynamics calculations.

Select the shape that represents the battery casing (in the middle
of the vehicle).

Enter the triangle edit mode,

disable the first layer

and select a few triangles that clearly delimit a rectangular
bounding box as in following figure:


Then click the Extract cuboid button in the shape edit dialog.
A new dialog pops open.
o Notice how the Create pure shape checkbox is selected,

and click ok.
o This just added a pure cuboid shape that encompasses the
selected triangles.

Leave the edit mode, and activate layer 1. You can now see the
cuboid that was added to the scene:

In the scene hierarchy, notice the cube-like icon of the pure shape
we just added.

Select it and observe in the shape dynamics properties dialog (click
Show dynamic properties dialog in the shape properties dialog)
how Static is unchecked, and Respondable is checked.
o This basically means that the shape will be falling and react
to collisions during simulation.

Now open the object common properties.
o While the pure shape is still selected, notice how all Object
special properties items are unchecked.

Now select the non-pure shape that represents the battery casing
and notice how most items in the Object special properties
section are checked.
o This means that for collision detection (collision detection is
different from collision response!), distance calculations,
vision sensor detection, or proximity sensor detection we will
use the detailed shape (the non-pure triangular mesh),
however for dynamics calculations, we will use an
approximate shape (the pure cuboid).

Now take the same approach for all other shapes in the scene as
you did with the battery casing.
o There is however no need to generate a pure shape for the
wheel's extracted inner parts. The pure sphere that you will
extract from the slider (the third contact point to the
ground) will require some vertical shifting in order to overlap
its non-pure counterpart (use the Coordinates and
transformation dialog for that).

Once all pure shapes were generated, select them all and assign
them to layer 9:

in the object common properties dialog, uncheck visibility layer 1

and check visibility layer 9,

then click Apply to selection.
o Since pure shapes are only functional, we just hide them in
layer 9.

Now you can easily toggle the view between visible and non-visible
parts of the scene with the invert button in the layer selection
dialog:
Note: There are times where the extraction of a pure shape is a little bit
more complicated. Consider following examples:
 a pure sub-element of a shape needs to be extracted; the shape's triangles
however appear to be too big to perform the operation. In that case, while in
triangle edit mode, click Subdivide largest triangles as often as required.
 a shape appears to be too complex to extract pure shapes. In that case you
can only approximate the complex shape with a series of pure primitives (refer to
the section on how to add primitive shapes), resizing, shifting and rotating them
until the approximation is good enough as illustrated in following figures:
Other times, it would just be too time-consuming to extract pure shapes,
or to arrange them appropriately. In that case, try using convex shapes
instead: indeed, convex shapes are not as efficient during collision
response calculation as pure shapes, they are however much better than
random shapes. Using the convex decomposition tool you can easily
optimize your dynamic content (notice the different shape icon for convex
shapes):
o The last step in this tutorial is to group shapes that belong to the
same rigid entity.
o Let's first start with the non-pure shapes.
o Select the white part of the left wheel,
o then the black part of the same wheel and click [Menu bar --> Edit
--> Grouping/Merging --> Group selected shapes].
o Do the same with the right wheel.
o Finally select all other simple non-pure shapes and group them too.
o The grouped shapes' visual attributes cannot be modified
anymore (unless they are ungrouped again).
o Now select the 3 grouped shapes and select [Menu bar --> Edit -->
Bounding box alignment --> Align selected shape's coordinate
frame with world].
o This nicely aligns the bounding boxes with the absolute
reference frame, but does not have any functional effect.
o Now we can group the pure shapes that belong to the vehicle body
in a similar way.
o However pure grouped shapes cannot have their bounding
box reoriented.
o Finally attach the non-pure shapes to their pure counterparts:
o select the left non-pure wheel, then the left pure wheel and click
[Menu bar --> Edit --> Make last selected object parent]
o (you can perform the same operation with a drag and drop
movement in the scene hierarchy).
o Do the same with the right wheel and then with the vehicle body.
o This is what you should have:
Note: Notice how the shapes are organized in the scene hierarchy.
o What is left for you to do is adjust each pure shape's mass,
moment of inertia, friction coefficient, respondable mask, etc.
o Make sure you read the section on how to design dynamic
simulations.
o And of course if you want your vehicle to be operational, you will
have to add joints, a control child script, etc.
o Make sure you also read the BubbleRob tutorial.
Download