class NRPGRPCCommunicationController

Overview

Manages communication with the NRP. Uses a GRPC server to send/receive data. More…

#include <nrp_communication_controller.h>

class NRPGRPCCommunicationController: public EngineGrpcServer {
public:
    // construction

    NRPGRPCCommunicationController(const NRPGRPCCommunicationController& other);
    NRPGRPCCommunicationController(NRPGRPCCommunicationController&& other);

    // methods

    NRPGRPCCommunicationController& operator = (const NRPGRPCCommunicationController& other);
    NRPGRPCCommunicationController&& operator = (NRPGRPCCommunicationController&& other);
    void registerStepController(GazeboStepController* stepController);
    void registerSensorPlugin(gazebo::SensorPlugin* sensorPlugin);
    void registerModelPlugin(gazebo::ModelPlugin* modelPlugin);
    static NRPGRPCCommunicationController& getInstance();

    static NRPGRPCCommunicationController& resetInstance(
        const std::string& serverURL,
        const std::string& engineName,
        const std::string& protobufPluginsPath,
        const nlohmann::json& protobufPlugins
    );

    static std::string createDataPackName(
        const std::string& modelName,
        const std::string& objectName
    );
};

Inherited Members

public:
    // typedefs

    typedef std::timed_mutex mutex_t;
    typedef std::unique_lock<EngineGrpcServer::mutex_t> lock_t;

    // methods

    void startServer();
    void startServerAsync();
    void shutdownServer();
    bool isServerRunning() const;
    const std::string serverAddress() const;

    void registerDataPack(
        const std::string& datapackName,
        ProtoDataPackController* interface
    );

    void registerDataPackNoLock(
        const std::string& datapackName,
        ProtoDataPackController* interface
    );

    unsigned getNumRegisteredDataPacks();
    const std::string& getEngineName();

Detailed Documentation

Manages communication with the NRP. Uses a GRPC server to send/receive data.

Construction

NRPGRPCCommunicationController(const NRPGRPCCommunicationController& other)

Delete for singleton.

NRPGRPCCommunicationController(NRPGRPCCommunicationController&& other)

Delete for singleton.

Methods

NRPGRPCCommunicationController& operator = (const NRPGRPCCommunicationController& other)

Delete for singleton.

NRPGRPCCommunicationController&& operator = (NRPGRPCCommunicationController&& other)

Delete for singleton.

void registerStepController(GazeboStepController* stepController)

Register a step controller.

Parameters:

stepController

Pointer to step controller

void registerSensorPlugin(gazebo::SensorPlugin* sensorPlugin)

Register a sensor plugin.

Parameters:

sensorPlugin

Pointer to sensor plugin

void registerModelPlugin(gazebo::ModelPlugin* modelPlugin)

Register a model plugin.

Parameters:

sensorPlugin

Pointer to model plugin

static NRPGRPCCommunicationController& getInstance()

Get singleton instance.

Returns:

Gets instance of NRPGRPCCommunicationController

static NRPGRPCCommunicationController& resetInstance(
    const std::string& serverURL,
    const std::string& engineName,
    const std::string& protobufPluginsPath,
    const nlohmann::json& protobufPlugins
)

Reset server with the given server URL.

Parameters:

serverURL

URL used by server

engineName

Name of this engine

Returns:

Returns reference to server instance

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

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

Parameters:

modelName

Name of the parent model of the controlled object

objectName

Name of the controlled object (sensor, joint, link, …)

Returns:

Returns datapack name