Event LoopΒΆ

The Event Loop implements soft real-time execution and asynchronous interaction between simulations in NRP-core. It executes a loop at a fixed frequency in which it processes incoming events from external processes, executes some predefined computations and sends out other events in response. The events accepted or sent by the Event Loop are always data messages in any of the supported communication protocols (eg. ROS, MQTT). In contrast with the FTILoop, the Event Loop allows to connect simulations or other processes asynchronously through this event processing mechanism and execute them under soft real-time constraints.

In a fully synchronous experiment, there are two kind of components : (1) a central process executing a FTILoop which mananages the Simulation Loop, i.e., the execution of Transceiver Functions, datapack send/get operations with engines, etc.; (2) Engine processes, which are synchronized by the former. When moving an existing experiment to a fully asynchronous setup, each of these two components are replaced by their asynchronous, real-time versions managed by an Event Loop, in a way which requires only few changes in code, mostly concentrated in the experiment configuration. The process of porting an experiment from synchronous to asynchronous is explained in this guide.

In order to connect Engine processes, the Event Loop uses a graph structure, the Computational Graph, which replaces and extends the Transceiver Functions used in FTILoop experiments. Its nodes are computational units which receive, process and send events. The edges in the graph represent connections between these nodes through which events can be exchanged. Edges are directed, meaning that a given connection allows to send events in only one direction. The nodes in the graph are executed in a specific order which ensures that each of them performs their computations on the latest available data. By instantiating and connecting nodes, users can specify which events the Event Loop should react to, how they should be processed and which events should be sent out in response. As said above, the Computational Graph replaces the Transceiver Functions when using the Event Loop. As explained in this page, it can also be used instead of Transceiver Functions in fully synchronous experiments using the FTILoop.

The next pages describe in more detail the elements and function of the Event Loop, the Computational Graph and how they can be used in NRP-core experiments:

Several example experiments using the Event Loop and the Computational Graph are available in the examples/event_loop_examples folder.

Related Pages: