Community:Science/Robotics/SimulatorSoftwareArchitecture

提供: wiki
移動先: 案内検索

OpenRobot Simulator: software architecture

Code generation: Processing of the components at run-time

The envisioned process follows these steps:

  1. Building of the simulation scenario by drag&drop of components and linking of models (cf GPS example).
  2. "Baking" of the simulation: once the scene is ready, we bake it. The user decide which middleware he wants to use, and the simulator iterate through all existing components in the scene, and call the Genom ("Module GENeratOr", see below) application to "instantiate" each component with the middleware. The output of this step is a Python script per component (or maybe a single big Python script - not decided yet).
  3. The GameEngine is started, with each component associated with its generated execution script. At each iteration of the GameEngine main loop, each script for each component is called and reads or outputs what it need, according what was initially declared in the description file (cf component description file).

Templates

Since we want the simulator to interact with the rest of the world without making any assumption on which protocol or transport the simulator users will use, we describe the components behaviour through its formal description, the .gen file.

But we need at some point to convert this description into an actual implementation relying on actual protocols and transports (we'll call it simply "communication middlewares").

Genom makes this transformation thanks templates. A template holds the structure of a module for a pair (programming language, middleware) (for instance, the structure of a ROS module coded in Java, the structure of a OpenRTM module coded in C, the structure of a YARP module coded in Python, etc.).

This diagram summarizes the whole process:

Overview of the Genom3 processing architecture

Below a pseudo example of a YARP/Python template: each statement within < > is interpreted by the module generator and replaced with data coming from both the .gen file and the codels.

Pseudo_YARP_Python_template
---------------------------

import yarp

<? for p in ports>
   self._yarpPorts["<? echo p.name>"] = yarp.BufferedPortBottle()

   self._yarpPorts["<? echo p.name>"].open(<? echo p.name>)

   def <? echo p.name>_execution():
      <? echo p.codel>
<? end for>

...You can understand it a bit like HTML + PHP programming.

This example doesn't reflect, however, the actual syntax of template (which relies on more powerful, TCL-based, statements).

In the case of the simulation in Blender, templates must generate Python code (since it's what is executed in the GameEngine at runtime). So, in principle, one just needs to write a new "Python_myMiddleware" template for the simulator to support a new middleware (assuming, of course, that the middleware can be adressed in Python, but it's pretty easy to generate Python bindings for most C/C++ code).