We provide engine templates, also referred as Engine Communication Protocols, which implement most of the functionality needed to run simulations. These engines take care of setting up client and server instances, communication, sending control messages and performing data exchange. Only simulator-related glue code and functionality have to be added.
Currently available template engines:
A minimal working engine of any of the types mentioned above can be generated using a script that comes with NRP Core. The script is going to create the following components:
In most cases the only entities that will need further modifications are the server class and the datapack controller class, as they are the two classes that are going to directly interact with your simulator.
Please note that in order to use these engine your simulator has to provide a C/C++ API.
In order to generate a new engine, you will need to choose a name. This name will be used to generate all other names in the engine - classes, directories, modules etc. Ideally it should be a single word, for example the name of your simulator, and start with an uppercase letter.
We are going to create a gRPC engine called TestGrpcEngine
To generate the code of the new engine:
This command should create a new directory called test_grpc_engine. Move it to the top-level directory:
To compile the new engine, add the following line at the end of the top-level CMakeLists.txt and configure the project again:
Compile the code:
In order to verify that the newly created engine works, you can run the example experiment provided with the engine:
The steps to create the new engine in this case are very similar to those referred above. Just change the type to json when invoking the script:
In the case of a JSON based Engine, it will always used JsonDataPack, so there is no need to implement new types.
In the case of a gRPC based Engine, by default the new engine created by the script will only accept protobuf messages of the type EngineTest.TestPayload. As it names indicate, this is a message definition used for testing purposes. In order to extend the engine to accept other protobuf message definitions:
By default, the new engines will use the grpc engine schema and json engine schema respectively to validate the engine configuration from the experiment configuration file. See here for more details.
If your engine configuration requires additional parameters, you can create your own schema using the aforementioned schemas as a base. See Creating an Engine configuration schema for more details on how to do this.
The client class doesn't need any modifications in order to work.
In order to control the simulation, the following methods of the server class must be implemented:
DataPack controllers (DataPackController) are helper classes which facilitate data exchange between the simulator and the server part of the engine. They can be thought of as adaptors between data arriving from the engine client in form of protobuf objects (gRPC engine) or JSON objects (JSON engine), and internal data from the simulation.
The engines generated using the script provides a single datapack controller class, but more may be added if needed.
The following methods of the controller should be implemented: