2013 - CoppeliaSim IROS
2013 - CoppeliaSim IROS
2013 - CoppeliaSim IROS
Simulation Framework
Eric Rohmer, Surya P. N. Singh and Marc Freese1
Abstract— From exploring planets to cleaning homes, the There are currently several robot simulation platforms
reach and versatility of robotics is vast. The integration of available, for instance Open HRP [1], Gazebo [2] or Webots
actuation, sensing and control makes robotics systems [3]. While some offer competing functionality, many fail in
powerful, but complicates their simulation. This paper offering a large and complementary palette of programming
introduces a versatile, scalable, yet powerful general-purpose techniques, and their simulation models and controllers are
robot simulation framework called V-REP. only partially portable: models, controllers and other
The paper discusses the utility of a portable and flexible functionality are clearly distinct, and thus need separate
simulation framework that allows for direct incorporation of handling. For example, controller recompilation on a
various control techniques. This renders simulations and different hardware or platform is often necessary, or the
simulation models more accessible to a general-public, by simulation model and controller need to be carefully matched
reducing the simulation model deployment complexity. It also
since they represent at least two distinct files, and when
increases productivity by offering built-in and ready-to-use
functionalities, as well as a multitude of programming
scaling is supported, it is done via relatively obscure hard-
approaches. wired mechanisms.
This allows for a multitude of applications including rapid The Virtual Robot Experimentation Platform [4] (main
algorithm development, system verification, rapid prototyping, user interface shown in Fig. 1) – or simply V-REP simulator
and deployment for cases such as safety/remote monitoring, – is the result of an effort trying to council all requirements
training and education, hardware control, and factory into a versatile and scalable simulation framework. Next to
automation simulation. offering the traditional approaches also found in other
simulators, V-REP adds several additional approaches.
I. INTRODUCTION Section II of this paper describes V-REP’s control
architecture, in which the various possible controller types
The exponential increase in processing power of are explained, in particular embedded scripts. That is, they
computers (not to mention 3D graphics hardware) along with can be an integral part of a simulation model, thus extremely
the plethora of open software and hardware standards has portable and scalable. Section III discusses the overall offered
drastically changed the landscape in the field of (3D) robotics simulation functionality, and its integration into simulation
simulation. Not only has this enabled more complexity on the models, also for the sake of portability. Finally, section IV
desktop, but conversely it has provided the ability to run examines three practical V-REP simulation models and their
simulations (in real-time) with hardware in-the-loop, or to implementation, as an illustration of this paper’s content.
have mobile/embedded systems controlled from a simulation
framework.
While it is possible to assemble a simulator from the
various kinematics, physics and graphics libraries, the
architecture and control methodology are crucial to
determining how these elements interact and thus the overall
performance and accuracy of the system. A robust systems
approach advocates for a versatile, scalable and fine-grained
simulation strategy.
Practically, a general-purpose robot simulator has to
provide multitude tools and functionalities simultaneously,
while abstracting the underlying robotic systems and their
complexity since system specificities cannot be foreseen.
Additionally, one wants a flexible controller approach that
can be portable and easily coded (and maintained), Figure 1. An example V-REP simulation scene showing the diversity of
generalizable to various models, and scalable (i.e. simulation robot types that may be simulated simultaneously
entities should handle multiple models, controllers or any
other functionality).
II. SIMULATION CONTROLLERS
1
Corresponding author: [email protected] If one wants to build complex simulation scenarios, then
Eric Rohmer is a lecturer at the State University of Campinas, Brasil there is almost no escape from a distributed control
Surya Singh is a lecturer at the University of Queensland, Australia framework. It simplifies the task by partitioning control
Marc Freese is CEO of Coppelia Robotics, Switzerland. entities, it speeds-up simulation by distributing the CPU load
over several cores or several machines, and it allows a
simulation model be controlled by native code execution. The most common implementations of the above
There are however simulation requirements that should not techniques (i.e., using external executables or plug-ins) have
be forgotten in pursuit of that goal. as a direct consequence poor portability and poor scaling of
One of the most important and often neglected aspect is simulation models: indeed, since the control code is not
the flexibility, portability and scalability of the simulation attached to its respective simulation model, it will have to be
model: how easy is it to adjust its control code(s)? How distributed/compiled/installed separately. This increases
many files have to be distributed in order to run the same compatibility problems across platforms, as well as
simulation model on another machine? Will it require conflict/dependency issues with other libraries. Flexibility is
also reduced, since one would have to recompile and reload
recompilation on other platforms? How many versions of the
an executable/plug-in for each small code modification.
same controller are in circulation? Can various versions
Model duplication, as in a multi-robot simulation scenario,
operate side-by-side? Can a simulation model easily be will have to be supported via hard-wired mechanisms that
instantiated several times, without losing functionality? launch new control instances for each simulation model
Other simulation control requirements are linked to the instance.
simulation loop. Some elements, especially the low-level
controls such as real-time motion level controllers, require B. V-REP Implementation
synchronization with the simulation loop. (i.e. executed at
V-REP allows the user to choose among various
the same moment at each simulation pass).
programming techniques simultaneously (Table 1) and even
The importance of providing synchronous/asynchronous,
symbiotically (Fig. 2):
external/embedded, native/non-native distributed control
techniques in robotics simulations is discussed hereafter. • Embedded scripts. This represents the most
powerful and distinctive feature of V-REP. The main
A. Overview of Common Techniques simulation loop is a simple Lua [5] script (called
The execution of the control code of a simulation or a “main script”), part of a given simulation scene, that
simulation model is handled using the following three handles general functionality (e.g. it will call distinct
techniques: functions to handle kinematics or dynamics, for
instance). The main script is also in charge of calling
• The control code is executed on another machine.
child scripts in a cascaded way (with respect to the
This could represent a distinct machine or a robot,
scene hierarchy). A child script, unlike the main
connected to the simulator machine via a specific
script, is attached to a specific object in the
network (e.g. socket, serial port, etc.). The main
simulation scene, and handles a particular part of the
advantage of this approach is the originality of the
simulation. It is an integral part of its scene object,
controller (the control code can be native and running
and will be duplicated and serialized, together with it.
on the original hardware). Another advantage is the
As such, it represents a perfectly portable and
reduced computing load on the simulation machine.
scalable control element: there is one single file
On the other hand, this approach imposes serious
containing the model definition together with its
limitations in regards to synchronization with the
control or functionality, there is no compatibility
simulation loop, and the communication delay/lag
issue across platforms, no need for explicit
dictated by the network.
compilation, no conflict among several versions of
• The control code is executed on the same machine, the same model, model instantiation is implicit, etc.
but in another process (or another thread) than Child scripts can be executed in a threaded and non-
the simulation loop. Here also, we can benefit from threaded fashion. The threaded version of child
a reduced, or rather balanced load on the CPU cores, scripts still keeps the advantages of the technique
but this comes accompanied with a lack of described in point 3 of section II, A: indeed, V-
synchronization with the simulation loop. And most REP’s thread scheduler handles threads in a way that
of the time, it comes in pair with a communication makes them behave and appear as coroutines, which
lag or thread switching delay (many resources allow to precisely control the time at which the
require locking before access, or some algorithms thread execution is switched back and forth,
aren't reentrant). This control technique is often effectively allowing for an excellent synchronization
implemented via external executables or plug-ins with the main script or other child scripts.
loaded by the simulator. Additionally, each thread can programmatically
request being set into a free-running mode (i.e.
• The control code is executed on the same machine allowing them to temporarily behave as real threads).
and in the same thread as the simulation loop. The Embedded scripts can also be seen as a “glue
main advantage of this approach is the inherent component”, that binds the various supported
synchronization with the simulation loop, and the programming techniques around V-REP: child
absence of any execution, communication or thread scripts can register ROS publishers/subscribers, they
switching lag or delay. This however is only made can open and handle communication lines (e.g.
possible with an increased load on the simulation socket or serial port), launch executables,
loop CPU core. This control technique is often load/unload plug-ins, or start remote API server
implemented via plug-ins loaded by the simulator. services (see point 4 hereafter). Embedded scripts
include also callback scripts, used as low-level
customized joint controllers for instance. The functions, with two exceptions however: remote API
functionality of embedded scripts can be extended by functions accept an additional argument which is the
the user via two mechanisms: with Lua extension operation mode, and return a same error code. The
libraries, or with custom Lua functions registered operation mode allows calling functions as blocking
through a plug-in. (will wait until the server replies), or non-blocking
(will read streamed commands from a buffer, or
• Add-ons. In a similar way as embedded scripts, add- start/stop a streaming service on the server side). The
on are supported in V-REP via Lua scripts. They can ease of use of the remote API, its availability on all
be used as stand-alone functions (convenient for platforms, and its small footprint, makes it an
writing importers/exporters), or as regularly executed interesting alternative to the ROS interface (see next
code (convenient as a lightweight simulator item).
customization method).
• ROS [6] nodes. V-REP implements a ROS node
• Plug-ins. Plug-ins are used in V-REP as a convenient with a plug-in which allows ROS to call V-REP
simulator customization tool. They can register commands via ROS services, or stream data via ROS
custom Lua commands, allowing the execution of publishers/subscribers. Publishers/subscribers can be
fast callback functions from within an embedded enabled with a service call, and also directly enabled
script. They can also extend the functionality of a from within V-REP, via an embedded script
particular simulation model or object. Often they also command.
implement specific importers/exporters, or offer an
interface to a specific hardware. The remote API
interface as well as the ROS interface (see next
items) are implemented via plug-ins.