template class EngineJSONNRPClient

Overview

NRP - Gazebo Communicator on the NRP side. Converts DataPackInterface classes from/to JSON objects. More…

#include <engine_json_nrp_client.h>

template <class ENGINE, const char* SCHEMA>
class EngineJSONNRPClient: public EngineClient {
public:
    // construction

    EngineJSONNRPClient(
        nlohmann::json& config,
        ProcessLauncherInterface::unique_ptr&& launcher
    );

    EngineJSONNRPClient(
        const std::string& serverAddress,
        nlohmann::json& config,
        ProcessLauncherInterface::unique_ptr&& launcher
    );

    // methods

    virtual pid_t launchEngine();
    virtual void sendDataPacksToEngine(const datapacks_set_t& dataPacks);
    virtual const std::vector<std::string> engineProcStartParams() const;
    virtual datapacks_vector_t getDataPacksFromEngine(const datapack_identifiers_set_t& datapackIdentifiers);
};

// direct descendants

template <class ENGINE, const char* SCHEMA>
class PythonEngineJSONNRPClientBase;

Inherited Members

public:
    // typedefs

    typedef std::shared_ptr<T> shared_ptr;
    typedef std::shared_ptr<const T> const_shared_ptr;
    typedef std::unique_ptr<T> unique_ptr;
    typedef std::unique_ptr<const T> const_unique_ptr;
    typedef ENGINE engine_t;

    // classes

    template <const char* ENGINE_TYPE>
    class EngineLauncher;

    // methods

    virtual const std::string engineName() const = 0;
    virtual const nlohmann::json& engineConfig() const = 0;
    virtual nlohmann::json& engineConfig() = 0;
    virtual const std::vector<std::string> engineProcStartParams() const = 0;
    virtual pid_t launchEngine();
    virtual void initialize() = 0;
    virtual void reset() = 0;
    virtual void shutdown() = 0;
    virtual SimulationTime getEngineTimestep() const = 0;
    virtual SimulationTime getEngineTime() const = 0;
    virtual const std::string engineSchema() const = 0;
    virtual void runLoopStepAsync(SimulationTime timeStep) = 0;
    virtual void runLoopStepAsyncGet(SimulationTime timeOut) = 0;
    virtual void sendDataPacksToEngine(const datapacks_set_t& dataPacks) = 0;
    virtual datapacks_vector_t getDataPacksFromEngine(const datapack_identifiers_set_t& datapackIdentifiers) = 0;
    virtual const std::string engineName() const;
    virtual SimulationTime getEngineTimestep() const;
    virtual const nlohmann::json& engineConfig() const;
    virtual nlohmann::json& engineConfig();
    virtual const std::string engineSchema() const;
    virtual SimulationTime getEngineTime() const;
    virtual void runLoopStepAsync(SimulationTime timeStep);
    virtual void runLoopStepAsyncGet(SimulationTime timeOut);

Detailed Documentation

NRP - Gazebo Communicator on the NRP side. Converts DataPackInterface classes from/to JSON objects.

Parameters:

ENGINE_INTERFACE

Class derived from GeneralInterface. Currently either PhysicsInterface or BrainInterface

Construction

EngineJSONNRPClient(
    nlohmann::json& config,
    ProcessLauncherInterface::unique_ptr&& launcher
)

Constructor.

Parameters:

config

Engine Config

launcher

Process launcher

EngineJSONNRPClient(
    const std::string& serverAddress,
    nlohmann::json& config,
    ProcessLauncherInterface::unique_ptr&& launcher
)

Constructor.

Parameters:

serverAddress

Server Address to send requests to

config

Engine Config

launcher

Process launcher

Methods

virtual pid_t launchEngine()

Launch the engine.

Returns:

Returns engine process ID on success, throws on failure

virtual void sendDataPacksToEngine(const datapacks_set_t& dataPacks)

Sends datapacks to engine.

Parameters:

datapacksArray

Array of datapacks that will be send to the engine

Throws

on error

Returns:

Returns SUCCESS if all datapacks could be handles, ERROR otherwise

virtual const std::vector<std::string> engineProcStartParams() const

Get all Engine Process Startup parameters.

virtual datapacks_vector_t getDataPacksFromEngine(const datapack_identifiers_set_t& datapackIdentifiers)

Gets requested datapacks from engine.

Parameters:

datapackNames

All requested datapack ids

Throws

on error

Returns:

Returns all requested datapacks