NRP Core  1.4.1
NRPJSONCommunicationController Class Reference

Manages communication with the NRP. Uses a REST server to send/receive data. Singleton class. More...

#include <nrp_communication_controller.h>

Inheritance diagram for NRPJSONCommunicationController:
EngineJSONServer

Public Member Functions

 ~NRPJSONCommunicationController () override
 
 NRPJSONCommunicationController (const NRPJSONCommunicationController &other)=delete
 Delete for singleton. More...
 
NRPJSONCommunicationControlleroperator= (const NRPJSONCommunicationController &other)=delete
 Delete for singleton. More...
 
 NRPJSONCommunicationController (NRPJSONCommunicationController &&other)=delete
 Delete for singleton. More...
 
NRPJSONCommunicationController && operator= (NRPJSONCommunicationController &&other)=delete
 Delete for singleton. More...
 
void registerStepController (GazeboStepController *stepController)
 Register a step controller. More...
 
void registerSensorPlugin (gazebo::SensorPlugin *sensorPlugin)
 Register a sensor plugin. More...
 
void registerModelPlugin (gazebo::ModelPlugin *modelPlugin)
 Register a model plugin. More...
 
- Public Member Functions inherited from EngineJSONServer
 EngineJSONServer (const std::string &engineAddress, const std::string &engineName, const std::string &clientAddress)
 Constructor. Tries to bind to a port and register itself with clientAddress. More...
 
 EngineJSONServer ()=delete
 No dummy servers without name and address. More...
 
virtual ~EngineJSONServer ()
 
 EngineJSONServer (const EngineJSONServer &)=delete
 
EngineJSONServeroperator= (const EngineJSONServer &)=delete
 
bool isServerRunning () const
 Is the server running? More...
 
void startServerAsync ()
 Start the server in asynchronous mode. More...
 
void startServer ()
 Start the server synchronously. More...
 
void shutdownServer ()
 Stop running server. More...
 
uint16_t serverPort () const
 Get running server port. More...
 
std::string serverAddress () const
 Get server address. More...
 
void registerDataPack (const std::string &datapackName, JsonDataPackController *interface)
 Registers a datapack. More...
 
void registerDataPackNoLock (const std::string &datapackName, JsonDataPackController *interface)
 Registers a datapack. Skips locking the mutex. Should only be used if thread-safe access to _datapacksControllers can be guaranteed. More...
 
bool shutdownFlag ()
 Has a shutdown command been received? More...
 

Static Public Member Functions

static NRPJSONCommunicationControllergetInstance ()
 Get singleton instance. More...
 
static NRPJSONCommunicationControllerresetInstance (const std::string &serverURL, const std::string &engineName, const std::string &registrationURL)
 Reset server with the given server URL. More...
 
static std::string createDataPackName (const std::string &modelName, const std::string &objectName)
 Create datapack name from the given model and sensor/joint/link. More...
 

Additional Inherited Members

- Public Types inherited from EngineJSONServer
using mutex_t = std::timed_mutex
 
using lock_t = std::unique_lock< EngineJSONServer::mutex_t >
 
- Protected Member Functions inherited from EngineJSONServer
void clearRegisteredDataPacks ()
 Remove all registered datapacks. More...
 
virtual nlohmann::json getDataPackData (const nlohmann::json &reqData)
 Retrieves datapack data. Takes an array of datapack names for which to get data. More...
 
virtual void setDataPackData (const nlohmann::json &reqData)
 Set datapack data. More...
 
const std::string & getEngineName ()
 Get the Engine name. More...
 
- Protected Attributes inherited from EngineJSONServer
mutex_t _datapackLock
 Lock access to _datapacks to make execution thread-safe. More...
 
- Static Protected Attributes inherited from EngineJSONServer
static constexpr std::string_view GetDataPackInformationRoute = EngineJSONConfigConst::EngineServerGetDataPacksRoute
 
static constexpr std::string_view SetDataPackRoute = EngineJSONConfigConst::EngineServerSetDataPacksRoute
 
static constexpr std::string_view RunLoopStepRoute = EngineJSONConfigConst::EngineServerRunLoopStepRoute
 
static constexpr std::string_view InitializeRoute = EngineJSONConfigConst::EngineServerInitializeRoute
 
static constexpr std::string_view ResetRoute = EngineJSONConfigConst::EngineServerResetRoute
 
static constexpr std::string_view ShutdownRoute = EngineJSONConfigConst::EngineServerShutdownRoute
 

Detailed Description

Manages communication with the NRP. Uses a REST server to send/receive data. Singleton class.

Constructor & Destructor Documentation

◆ ~NRPJSONCommunicationController()

NRPJSONCommunicationController::~NRPJSONCommunicationController ( )
override

◆ NRPJSONCommunicationController() [1/2]

NRPJSONCommunicationController::NRPJSONCommunicationController ( const NRPJSONCommunicationController other)
delete

Delete for singleton.

◆ NRPJSONCommunicationController() [2/2]

NRPJSONCommunicationController::NRPJSONCommunicationController ( NRPJSONCommunicationController &&  other)
delete

Delete for singleton.

Member Function Documentation

◆ createDataPackName()

static std::string NRPJSONCommunicationController::createDataPackName ( const std::string &  modelName,
const std::string &  objectName 
)
inlinestatic

Create datapack name from the given model and sensor/joint/link.

Parameters
modelNameName of the parent model of the controlled object
objectNameName of the controlled object (sensor, joint, link, ...)
Returns
Returns datapack name

◆ getInstance()

NRPJSONCommunicationController & NRPJSONCommunicationController::getInstance ( )
static

Get singleton instance.

Returns
Gets instance of NRPJSONCommunicationController

◆ operator=() [1/2]

NRPJSONCommunicationController& NRPJSONCommunicationController::operator= ( const NRPJSONCommunicationController other)
delete

Delete for singleton.

◆ operator=() [2/2]

NRPJSONCommunicationController&& NRPJSONCommunicationController::operator= ( NRPJSONCommunicationController &&  other)
delete

Delete for singleton.

◆ registerModelPlugin()

void NRPJSONCommunicationController::registerModelPlugin ( gazebo::ModelPlugin *  modelPlugin)
inline

Register a model plugin.

Parameters
sensorPluginPointer to model plugin

◆ registerSensorPlugin()

void NRPJSONCommunicationController::registerSensorPlugin ( gazebo::SensorPlugin *  sensorPlugin)
inline

Register a sensor plugin.

Parameters
sensorPluginPointer to sensor plugin

◆ registerStepController()

void NRPJSONCommunicationController::registerStepController ( GazeboStepController stepController)

Register a step controller.

Parameters
stepControllerPointer to step controller

◆ resetInstance()

NRPJSONCommunicationController & NRPJSONCommunicationController::resetInstance ( const std::string &  serverURL,
const std::string &  engineName,
const std::string &  registrationURL 
)
static

Reset server with the given server URL.

Parameters
serverURLURL used by server
engineNameName of this engine
registrationURLURL used to register this engine server's URL
Returns
Returns reference to server instance

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