How arguments are passed between builder and the simulator ?

There are lots of information expressed in Builder script that are not directly translatable in blender model. Here, we describe how the information are passed between the builder script and the simulator.

Properties

Some information are passed directly through the game engine property of each component. It includes stuff like classpath (what python class implements the logic of this component) or components properties (passed using the morse.builder.abstractcomponent.AbstractComponent.properties() method).

However, passing information through game engine properties has some limitations: it must be one of basic type (string, int, double, ...), and the range on int and double is limited by Blender. It is not good enough to translate more complex informations.

The component_config.py file

Information concerning scene configuration (i.e. which datastream handler for which component, which service for which component, ...) are passed through the file component_config.py stored in the blender scene. You can retrieve it using the Text Editor window in Blender.

This file contains a relatively complex python structure, encoding the configuration for the different part mentioned above. The file is automatically generated by the Builder using the method morse.builder.abstractcomponent.Configuration.write_config(). On the simulator side, the file is imported in morse.blender.main, and used to create the different internal structures (see Entry points of the simulation).

More precisely, the file contains four dictionaries:

  • component_datastream contains for each component the list of associated datastream handler. Each datastream handler is defined by a list of three elements:
    1. the middleware manager
    2. the specific datastream handler class
    3. a dictionary containing extra arguments for the datastream handler
  • component_modifier contains for each component the list of associated modifiers Each modifier is defined by a list of three elements:
    1. Its class
    2. the method name in the class
    3. a dictionary containing extra arguments for the modifier class
  • component_service contains for each component the list of associated service handler defined by its classpath.
  • component_overlays contains for each service handler and for component the list of associated overlays represented by their classpath.

Example

The scene

from morse.builder import *

robot = ATRV()

pose = Pose()
pose.add_stream('socket')
pose.alter('Noise')
robot.append(pose)

odometry = Odometry()
odometry.level("differential")
odometry.add_stream('socket')
robot.append(odometry)

waypoint = Waypoint()
waypoint.add_interface('socket')
robot.append(waypoint)

env = Environment('empty', fastmode=True)

Generated component_config.py

component_datastream = {
 "robot.waypoint": [
  [
   "morse.middleware.socket_datastream.Socket",
   "morse.middleware.socket_datastream.SocketReader",
   {}
  ]
 ],
 "robot.odometry": [
  [
   "morse.middleware.socket_datastream.Socket",
   "morse.middleware.socket_datastream.SocketPublisher",
   {}
  ]
 ],
 "robot.pose": [
  [
   "morse.middleware.socket_datastream.Socket",
   "morse.middleware.socket_datastream.SocketPublisher",
   {}
  ]
 ]
}
component_modifier = {
 "robot.pose": [
  [
   "morse.modifiers.pose_noise.MorsePoseNoiseClass",
   "noisify",
   {}
  ]
 ]
}
component_service = {
 "robot.waypoint": [
  "morse.middleware.socket_request_manager.SocketRequestManager"
 ]
}
overlays = {}

Table Of Contents

Previous topic

Adding a new robot

Next topic

Armatures creation

This Page