To be able to create new middleware bindings for MORSE, it is necessary to understand the concept of hooks, which describes how data can be accessed from the MORSE components and passed to the middleware bindings.
The easiest way to add middleware communications to MORSE is to take a look at the existing modules, copy one of them, and modify it according to your requirements.
Probably the best example for this (at the same time simple and complete) is the YARP middleware.
If you have a few different messages to decode / encode, it is possible to implement everything in the single file ${middleware}_mw.py. This is normally the case when you want to transmit data of the basic types: integer, float, string, boolean.
The register_component method must make sure to assign the correct function to the MORSE component, depending on the type of component and the data to be transmitted.
For more specific data types that require a special encoding / decoding, it is preferable to split each processing in a separate file. For this purpose, you need to create a directory $MORSE_SRC/src/morse/${middleware}. Each file will implement a special processing for a given type of message. These files need to implement at least two different methods:
As an example, look at the file $MORSE_SRC/src/morse/middleware/yarp/sick.py. The methods implemented here convert the list of lists stored in local_data of the sick sensor into a yarp bottle with a series of nested bottles for each point, each bottle containing three double variables, for the x, y and z coordinates.
When you write a method which serializes the component output, you must not modify the associated component. You are allowed to make computations to adapt the internal MORSE data structure (local_data) to the needs of your specific middleware (it is the main goal of this layer in fact). If you feel that some sensor / actuator requires more information, you must add (propose a patch, or inherit and extend) it at the sensor level and not at the middleware level, so every potential user can profit from it (and not only people using this specific middleware).