Base class for all Engines. More...
#include <engine_client_interface.h>
Classes | |
class | EngineLauncher |
Class for launching engine. More... | |
Public Types | |
using | engine_t = ENGINE |
![]() | |
using | shared_ptr = std::shared_ptr< EngineClientInterface > |
using | const_shared_ptr = std::shared_ptr< const EngineClientInterface > |
using | unique_ptr = std::unique_ptr< EngineClientInterface > |
using | const_unique_ptr = std::unique_ptr< const EngineClientInterface > |
Public Member Functions | |
EngineClient (nlohmann::json &engineConfig, ProcessLauncherInterface::unique_ptr &&launcher) | |
Constructor. More... | |
~EngineClient () override=default | |
const std::string | engineName () const override final |
Get Engine Name. More... | |
SimulationTime | getEngineTimestep () const override final |
Get engine timestep. More... | |
const nlohmann::json & | engineConfig () const override final |
Get Engine Configuration. More... | |
nlohmann::json & | engineConfig () override final |
Get Engine Configuration. More... | |
const std::string | engineSchema () const override final |
Get json schema for this engine type. More... | |
SimulationTime | getEngineTime () const override |
Returns current engine (simulation) time. More... | |
void | runLoopStepAsync (SimulationTime timeStep) override |
Concrete implementation of EngineClientInterface::runLoopStepAsync() More... | |
void | runLoopStepAsyncGet (SimulationTime timeOut) override |
Concrete implementation of EngineClientInterface::runLoopStepAsyncGet() More... | |
![]() | |
EngineClientInterface (ProcessLauncherInterface::unique_ptr &&launcher) | |
virtual | ~EngineClientInterface () |
virtual const std::vector< std::string > | engineProcStartParams () const =0 |
Get all Engine Process Startup parameters. More... | |
virtual pid_t | launchEngine () |
Launch the engine. More... | |
virtual void | initialize ()=0 |
Initialize engine. More... | |
virtual void | reset ()=0 |
Reset engine. More... | |
virtual void | shutdown ()=0 |
Shutdown engine. More... | |
virtual void | sendDataPacksToEngine (const datapacks_set_t &dataPacks)=0 |
Sends datapacks to engine. More... | |
virtual datapacks_vector_t | getDataPacksFromEngine (const datapack_identifiers_set_t &datapackIdentifiers)=0 |
Gets requested datapacks from engine. More... | |
Protected Member Functions | |
virtual void | resetEngineTime () |
template<class T > | |
void | setDefaultProperty (std::string key, T value) |
Attempts to set a default value for a property in the engine configuration. If the property has been already set either in the engine configuration file or from the engine schema, its value is not overwritten. More... | |
virtual SimulationTime | runLoopStepCallback (SimulationTime timeStep)=0 |
Executes a single loop step. More... | |
Additional Inherited Members | |
![]() | |
ProcessLauncherInterface::unique_ptr | _process |
Process Launcher. Will be used to stop process at end. More... | |
Base class for all Engines.
ENGINE | Final derived engine class |
using EngineClient< ENGINE, SCHEMA >::engine_t = ENGINE |
|
inline |
Constructor.
engineConfig | Engine Configuration |
launcher | Process Forker |
|
overridedefault |
|
inlinefinaloverridevirtual |
Get Engine Configuration.
Implements EngineClientInterface.
|
inlinefinaloverridevirtual |
Get Engine Configuration.
Implements EngineClientInterface.
|
inlinefinaloverridevirtual |
|
inlinefinaloverridevirtual |
Get json schema for this engine type.
Implements EngineClientInterface.
|
inlineoverridevirtual |
Returns current engine (simulation) time.
The time is updated by EngineClient::runLoopStepAsyncGet() method.
Implements EngineClientInterface.
|
inlinefinaloverridevirtual |
|
inlineprotectedvirtual |
|
inlineoverridevirtual |
Concrete implementation of EngineClientInterface::runLoopStepAsync()
The function starts EngineClient::runLoopStepCallback() asynchronously using std::async. The callback function should be provided by concrete engine implementation. The result of the callback is going to be retrieved using an std::future object in EngineClient::runLoopStepAsyncGet().
[in] | timeStep | Requested duration of the simulation loop step. |
NRPException | If the future object is still valid (EngineClient::runLoopStepAsyncGet() was not called) |
Implements EngineClientInterface.
|
inlineoverridevirtual |
Concrete implementation of EngineClientInterface::runLoopStepAsyncGet()
The function should be called after EngineClient::runLoopStepAsync(). It will wait for the worker thread to finish and retrieve the results from the future object. The value returned by the future should be the simulation (engine) time after running the loop step. It will be saved in the engine object, and can be accessed with EngineClient::getEngineTime().
[in] | timeOut | Timeout of the loop step. If it's less or equal to 0, the function will wait indefinitely. |
NRPException | On timeout |
Implements EngineClientInterface.
|
protectedpure virtual |
Executes a single loop step.
This function is going to be called by runLoopStep using std::async. It will be executed by a worker thread, which allows for runLoopStepFunction from multiple engines to run simultaneously.
[in] | timeStep | A time step by which the simulation should be advanced |
Implemented in NestEngineServerNRPClient, EngineGrpcClient< ENGINE, SCHEMA >, EngineGrpcClient< PythonEngineGRPCNRPClient, PythonGrpcConfigConst::EngineSchema >, and EngineGrpcClient< GazeboEngineGrpcNRPClient, GazeboGrpcConfigConst::EngineSchema >.
|
inlineprotected |
Attempts to set a default value for a property in the engine configuration. If the property has been already set either in the engine configuration file or from the engine schema, its value is not overwritten.
key | Name of the property to be set |
value | Default value to set |