if you're a complete beginner to sofa in
soft robotics welcome this tutorial will
show you how to create very simple
scenes like the one here whilst also
walking you through the basics of object
modeling with sofa before we start I
just quickly address what this tutorial
will discuss and what it won't the focus
of this video is to help you to first of
all understand the interface of sofa the
general structure of a scene and then
the simulated objects components that
are coming to all the objects designed
and so far however I won't present the
modeling of a deformable material in
this first steps tutorial the specific
modeling associated with soft materials
will be presented in the tripod tutorial
video if you haven't done it already
download it and install the sofa
framework along with the esteli that is
the sofa template library make sure you
have the Esterly plugin it is not
mandatory to create sims foot sofa but
it includes many ready-to-use objects
that we call prefabricated objects or
simply prefabs like these ones they
allow to build things very quickly and
make it much easier to start with sofa
you can then run this first steps
tutorial and do it along with me on my
side I'll be using a computer running
Linux each scene is described in a text
file that is loaded by sofa in the
display window in the tutorial I write
all the things in Python but it's also
possible to write them in the XML or the
PSL languages the browser window on the
left that you can show or hide if you go
to help hide dog brother contains the
documentation of the scene that is here
description of the tutorial it also
contains some links to the plugins
documentation for example by clicking
here you can get more details about the
estate
let's start by setting up a simple scene
in this step I'll show you what the
general structure of the scene is for
this first scene will use prefabricated
objects the cube and floor objects that
are built-in in the esteli plugin and so
ready to use
let me explain a bit about the structure
ever seen a scene can actually be seen
as an ordered tree of nodes each node
being an object and containing one or
several components related to the
behavior of the object the very top node
of the Yeerk the first parent node is
called the root node a scene is written
in a Python file that contains the
description of the simulation it always
starts with a function create scene that
takes the root node a single parameter
in order to build a simulated cube we
are going to use the prefabricated
function cube the parameters names are
rather intuitive and so for this prefab
object you can define its name
translation rotation color and scale
parameters the same applies to the floor
prefab both objects must be imported
from the estelí rigid objects at the
beginning of each file using them I'm
also adding two behavior descriptions to
the scene through the functions main
header and contact header the main
header function defines gravity as the
main force exercised on the object when
placed in the root node the gravity
falls automatically applies to all the
nodes attached to it the contact header
function states how a contact between
the objects is handled here the cube and
the floor are not allowed to go through
one another when they collide so an
alarm distance and the contact distance
are defined in order to ensure that the
two objects won't collide also as I have
defined these behaviors in the root node
they will apply to all the child nodes
of the scene so to both the cube and the
floor here those behavior functions are
also imported from the Esteli
at the beginning of the code file you
can notice that I have said the gravity
force vector at 0 minus 981 0 the
gravity force on earth is of minus 9,81
m/s^2 when considering a vertical
ascending axis so in the scene - 981
corresponds to the gravity force
expressed in centimeters along the
second axis compared to it the cube
scale of 20 represents a cube of 20
centimeters side so in sofa the user
defines the scale of the objects through
the definition of the constants of the
simulation model with this our first
scene is ready for testing by clicking
on try design in sofa the scene is
directly loaded otherwise you can click
on write it yourself which opens a blank
scene that you can complete once you're
done writing the scene save it and go to
file reload or simply type ctrl R to
load the objected file in sofa this has
to be done at each scope change if you
want to reload the scene automatically
at each change it's also possible to
start the tutorial in the terminal with
the - I option once the scene is loaded
click on the animate button to run the
simulation so the cube falls until it's
at a close distance to the floor and
stops moving this corresponds well to
the real experiment of a cube falling
under gravity stop fire for so if you
want to reorient the viewpoints of the
scene you just need to click left and
drag the mouse pointer you can also
scroll the mouse wheel to zoom in and
out now there are two ways to modify the
scene at it first you can directly
modify the code for that right-click
anywhere in the graph panel and then
open file in editor
this opens the code file for example if
I want to change the cube color to blue
I can add the color parameter with the
value 0 0 1 I
the changes and reload the scene and now
the cube is blue speaking of colors you
can see there are 3d axis here that
shows the vectors after three directions
in space each of them in a specific
color well this helps to remember in
what order to write the components of
the vector you know the red green blue
color model well the values are given in
the same order the one for the red axis
first then the green axis and finally
the blue one let's say that now we want
to move the cube away from over the
floor so it can fall endlessly we'll use
the second technique to modify a scene
to do that in the graph panel expand the
cube menu and double-click on mechanical
object m-state the mechanical object
stores the properties of the object
including its orientation in space in
the window that appears go to the
transformation tab and the line
translation allows you to translate the
cube so 100 centimeters in the X
directions so the red vector should do
the trick now update and animate the
scene and you can see the de cube misses
the floor and modifying the scene with
this second technique doesn't change the
code though the changes are only saved
until you close the scene and that's it
for step one and now I'll explain more
in details how the prefab objects are
built so that you can then build your
own the objects in sofa are all designed
the same way with multiple models a
mechanical one for the computation of
the reaction of the object to the forces
that apply on it a visual one that
computes the 3d rendering in the
simulation window and a collision model
that computes how the objects interact
with each other in this second step
we'll see how the first two ones are
built so how to model a physical object
first create a node attached to the root
node by using the create child function
this node will contain the different
poems defining the physical object we
want to model then for each of the
models will create an object of the cube
with the function create object we'll
start with a mechanical model so as I
said in this introductory tutorial I
will only deal with rigid objects as all
the points of a rigid object are moving
together studying the movement of one
single point of it usually the center of
gravity is equivalent to studying the
movement of all the points the aim of
the simulation is to compute at each
time step the next position and velocity
of the center of gravity based on the
force that applied to it such as gravity
the center of gravity can move in the
three directions of space and rotate
around these three axes this means that
it has six degrees of freedom so the
mechanical model of a rigid object
consists of one point possessing six
degrees of freedom the object's
mechanical object in sofa stores all the
positions and velocities of the center
of gravity of the object for the
properties related to the mass
distribution inside the object that has
an impact on the position of the center
of gravity another object uniform mass
is added which as a thank suggests
implements a uniform distribution of
mass the positions and velocities are
computed thanks to a time integration
scheme and a solving method the time
integration scheme defines the system to
be solved at each time step of the
simulation there are several available
let's use the implicit alarm method the
solving method describes how to solve
the differential equations ruling the
movement of the object here again there
are different methods available and
we'll use the conjugate gradient one so
for such simple scenes it's not
essential which solving tools are used
but for some systems like very large
ones for example it can be important to
use specific methods this model alone is
enough to render simulation of the cubes
fall under gravity force
however as we want to visualize it in
the simulation window we'll also build a
visual model that will create let's say
a blue cube of 20 centimeters side the
visual model is defined in a new node in
the visual object is muddled with
graphic vectors the surface of the
object is discretized that is divided
into small surface elements connected
together by points the set of points
resulting from the discretization and
their connections to each other is
called the mesh so this is the mesh used
for the visual model of the cube the
outer surface of the cube has been split
into triangular elements this mesh is
described in an ash pile the SM cube 27
that obj file in order to use it we
create an object visual that plots the
graphic model with the open gia finally
we want that when the change in position
is computed for the mechanical object
the visual model is also moving
accordingly for that we build a
correspondence between the two models in
the form of the mapping tool called
rigid mapping now to two models for the
cube are ready so for a more interesting
scene I'm also adding the floor prefab
that I already used in the first scene
so I run the scene and I animated and
the cube fall's endlessly under the
gravity force you can see it even went
through the floor as if it were a ghost
but the reason for that is that we never
stated how the objects should interact
with each other for that we will need a
third model that is handling collision
this step focuses on the implementation
of a collision model for the cube so
that it doesn't go through the floor
anymore for that we create a child node
of the cube that I call cube collision
model there are different objects to
implement in order to describe the
collision model the collision occurs
when the outer surfaces of different
objects come in contact this means that
we need to describe the surface of the
cube object or to be more exact we are
going to describe the elements composing
the surface in our discretized model we
used to say mesh as for the visual model
that we load thanks to a mesh loader the
surface decomposed into triangular
elements also shows line elements and
points just as for the mechanical model
the positions and velocities of all the
surface elements at each time step are
sold in a mechanical object when a
collision occurs the object is submitted
to additional constraints the behavior
of the cube in such a situation is
described in an object that we are going
to add in the mechanical model of the
cube finally in order to build the
correspondence between this model and
the mechanical one we also add a mapping
with this we have defined the collision
model of the cube M the same model is
implemented by default in the prefabs so
the floor here already has its collision
model in order for the collisions to be
detected it's necessary to describe what
a collision is that is at which distance
from one another
we consider that the objects collide and
how the collisions are handled when they
occur this is what the contact header
object is doing at the collision
detection and handling rules apply for
all the objects in the scene it's placed
in the root node I defined it potential
collisions are looked for within an
alarm distance radius from the object
and if a collision situation is detected
the collision model computes the
behavior of the objects which are
stopped at a contact distance from each
other
I run the scene and now you can see that
the cube is stopped at a small distance
from the floor by zooming in you can
observe the small gap between the cube
and the floor that corresponds to the
contact distance so it can seem weird to
set a non zero value for the contact
distance but remember that in a
simulation both space and time are
discretized and not continuous so if the
objects move rather quickly towards each
other
and if the alarm and contact distances
are too small there is a risk that from
an instant to the next one that is
computed the objects have already
entered collision in such a case the
collision wouldn't be computed correctly
so if you've got this far with me
you now have three representations of
the same cube object a mechanical one a
visual one and a collision model
representation this multi model
representation is characteristic of sofa
along with the mapping functions to
build response between the
representations in the view panel you
can switch between the representations
that you want to display
with this scene we have produced a very
similar scene to the one in step 1
except that the cube is blue the only
drastic difference is the length of the
code so you can see just how interesting
the prefab objects are they allowed to
save a lot of time and make light our
codes
I'll finish this tutorial with a small
exercise now that you know how it's in
is built and how an object is
implemented I propose you to build
rapidly this thing and let's see how
short the code can be with the help of
prefabs you already know about these
lines so I won't comment about them and
I'll go directly to you the objects
first I define the floors the former
yellow one and also a smaller green one
that I put over the first one now for
the cubes the seven of them are pretty
similar they only differ in their
translation along the red axis for the
first component of the translation
vector and in color it's more efficient
to build all of them in a single loop
structure so starting from minus 210
centimeters I move them to the right of
70 centimeters each I also play with the
color vector and gradually change the
red and green proportions of the cube
for the collision model I rely on the
prefab function contact header and on
the built-in model in each object to
handle it automatically so let's now try
the scene all the collision situations
seem to be handled properly so the
parameters for the alarm and contact
distance seem to be adapted to DT that's
it for this first episode oriole I know
we haven't done anything on soft object
modeling yet but it's necessary to
introduce the general modeling method
using so fast it's very similar with
soft objects that just a bit more
complex as we also have to compute how
the objects reform through constraints
so I encourage you to pursue with the
next tutorial about our tripod soft
robot and if you have any questions or
suggestions you are invited to ask them
on our webpage and I hope to see you in
future tutorials