NRP Core  1.4.1
EngineProtoWrapper Class Referenceabstract

Abstract class defining an interface to interact with an Engine with data exchange via protobuf messages. More...

#include <engine_proto_wrapper.h>

Inheritance diagram for EngineProtoWrapper:
NRPGazeboCommunicationController

Public Types

using mutex_t = std::timed_mutex
 
using lock_t = std::unique_lock< EngineProtoWrapper::mutex_t >
 

Public Member Functions

 EngineProtoWrapper ()=delete
 No dummy wrappers, only those with name. More...
 
 EngineProtoWrapper (const std::string &engineName, const std::string &protobufPluginsPath, const nlohmann::json &protobufPlugins)
 Constructor. More...
 
virtual ~EngineProtoWrapper ()=default
 Destructor. More...
 
void registerDataPack (const std::string &datapackName, ProtoDataPackController *interface)
 Registers a datapack controller with the given name in the engine. More...
 
unsigned getNumRegisteredDataPacks ()
 
std::vector< std::string > getNamesRegisteredDataPacks ()
 Get the names of registered datapacks. More...
 
const std::string & getEngineName ()
 Get the Engine name. More...
 
virtual bool initRunFlag () const =0
 Indicates if the simulation was initialized and is running. More...
 
virtual bool shutdownFlag () const =0
 Indicates if shutdown was requested by the client. More...
 
virtual void initialize (const nlohmann::json &data)=0
 Initializes the simulation. More...
 
virtual void reset ()=0
 Resets the simulation. More...
 
virtual void shutdown ()=0
 Shutdowns the simulation. More...
 
virtual SimulationTime runLoopStep (const SimulationTime timeStep)=0
 Runs a single simulation loop step. More...
 
void setDataPacks (const EngineGrpc::SetDataPacksRequest &data)
 
void setDataPack (const EngineGrpc::DataPackMessage &dataPack)
 
std::unique_ptr< gpb::Message > unpackFromAny (const gpb::Any &data)
 
virtual void getDataPacks (const EngineGrpc::GetDataPacksRequest &request, EngineGrpc::GetDataPacksReply *reply)
 
bool getDataPack (const std::string &name, EngineGrpc::DataPackMessage *dpMsg)
 
void setDataPackMessageData (gpb::Message *data, EngineGrpc::DataPackMessage *dpMsg)
 

Protected Member Functions

void clearRegisteredDataPacks ()
 
ProtoDataPackControllergetDataPackController (const std::string &datapackName)
 Returns the pointer to the DataPackController of the Data Pack with the specified name. More...
 

Protected Attributes

bool _handleDataPackMessage = false
 If true controllers are sent incoming DataPackMessages, if false only the contained data. More...
 
std::vector< std::unique_ptr< protobuf_ops::NRPProtobufOpsIface > > _protoOps
 
std::string _protoOpsStr = ""
 

Detailed Description

Abstract class defining an interface to interact with an Engine with data exchange via protobuf messages.

Derived classes are responsible for implementing simulation initialization, shutdown and run step methods.

Member Typedef Documentation

◆ lock_t

◆ mutex_t

using EngineProtoWrapper::mutex_t = std::timed_mutex

Constructor & Destructor Documentation

◆ EngineProtoWrapper() [1/2]

EngineProtoWrapper::EngineProtoWrapper ( )
delete

No dummy wrappers, only those with name.

◆ EngineProtoWrapper() [2/2]

EngineProtoWrapper::EngineProtoWrapper ( const std::string &  engineName,
const std::string &  protobufPluginsPath,
const nlohmann::json protobufPlugins 
)
inline

Constructor.

Parameters
[in]engineNameName of the simulation engine

◆ ~EngineProtoWrapper()

virtual EngineProtoWrapper::~EngineProtoWrapper ( )
virtualdefault

Destructor.

Member Function Documentation

◆ clearRegisteredDataPacks()

void EngineProtoWrapper::clearRegisteredDataPacks ( )
inlineprotected

◆ getDataPack()

bool EngineProtoWrapper::getDataPack ( const std::string &  name,
EngineGrpc::DataPackMessage *  dpMsg 
)
inline

◆ getDataPackController()

ProtoDataPackController* EngineProtoWrapper::getDataPackController ( const std::string &  datapackName)
inlineprotected

Returns the pointer to the DataPackController of the Data Pack with the specified name.

◆ getDataPacks()

virtual void EngineProtoWrapper::getDataPacks ( const EngineGrpc::GetDataPacksRequest &  request,
EngineGrpc::GetDataPacksReply *  reply 
)
inlinevirtual

◆ getEngineName()

const std::string& EngineProtoWrapper::getEngineName ( )
inline

Get the Engine name.

◆ getNamesRegisteredDataPacks()

std::vector<std::string> EngineProtoWrapper::getNamesRegisteredDataPacks ( )
inline

Get the names of registered datapacks.

◆ getNumRegisteredDataPacks()

unsigned EngineProtoWrapper::getNumRegisteredDataPacks ( )
inline

◆ initialize()

virtual void EngineProtoWrapper::initialize ( const nlohmann::json data)
pure virtual

Initializes the simulation.

Parameters
[in]dataSimulation configuration data
[in]datapackLock???

Implemented in NRPGazeboCommunicationController.

◆ initRunFlag()

virtual bool EngineProtoWrapper::initRunFlag ( ) const
pure virtual

Indicates if the simulation was initialized and is running.

Implemented in NRPGazeboCommunicationController.

◆ registerDataPack()

void EngineProtoWrapper::registerDataPack ( const std::string &  datapackName,
ProtoDataPackController interface 
)
inline

Registers a datapack controller with the given name in the engine.

Parameters
[in]datapackNameName of the datapack to be registered
[in]datapackControllerPointer to the datapack controller object that's supposed to be registered in the engine

◆ reset()

virtual void EngineProtoWrapper::reset ( )
pure virtual

Resets the simulation.

Implemented in NRPGazeboCommunicationController.

◆ runLoopStep()

virtual SimulationTime EngineProtoWrapper::runLoopStep ( const SimulationTime  timeStep)
pure virtual

Runs a single simulation loop step.

Parameters
[in]timeStepTime step by which the simulation should be advanced
Returns
Engine time after running the step

Implemented in NRPGazeboCommunicationController.

◆ setDataPack()

void EngineProtoWrapper::setDataPack ( const EngineGrpc::DataPackMessage &  dataPack)
inline

◆ setDataPackMessageData()

void EngineProtoWrapper::setDataPackMessageData ( gpb::Message *  data,
EngineGrpc::DataPackMessage *  dpMsg 
)
inline

◆ setDataPacks()

void EngineProtoWrapper::setDataPacks ( const EngineGrpc::SetDataPacksRequest &  data)
inline

◆ shutdown()

virtual void EngineProtoWrapper::shutdown ( )
pure virtual

Shutdowns the simulation.

Implemented in NRPGazeboCommunicationController.

◆ shutdownFlag()

virtual bool EngineProtoWrapper::shutdownFlag ( ) const
pure virtual

Indicates if shutdown was requested by the client.

Implemented in NRPGazeboCommunicationController.

◆ unpackFromAny()

std::unique_ptr<gpb::Message> EngineProtoWrapper::unpackFromAny ( const gpb::Any &  data)
inline

Member Data Documentation

◆ _handleDataPackMessage

bool EngineProtoWrapper::_handleDataPackMessage = false
protected

If true controllers are sent incoming DataPackMessages, if false only the contained data.

◆ _protoOps

std::vector<std::unique_ptr<protobuf_ops::NRPProtobufOpsIface> > EngineProtoWrapper::_protoOps
protected

◆ _protoOpsStr

std::string EngineProtoWrapper::_protoOpsStr = ""
protected

The documentation for this class was generated from the following file: