ROSBridge.h 1.11 KB
Newer Older
Valentin Platzgummer's avatar
Valentin Platzgummer committed
1 2 3 4 5 6
#pragma once

#include "ros_bridge/rapidjson/include/rapidjson/document.h"
#include "ros_bridge/include/CasePacker.h"
#include "ros_bridge/include/TypeFactory.h"
#include "ros_bridge/include/JsonFactory.h"
Valentin Platzgummer's avatar
Valentin Platzgummer committed
7
#include "ros_bridge/include/TopicPublisher.h"
Valentin Platzgummer's avatar
Valentin Platzgummer committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#include "ros_bridge/include/Receiver.h"

#include <memory>
#include <tuple>

#include "boost/lockfree/queue.hpp"

namespace ROSBridge {
class ROSBridge
{
public:    
    typedef MessageTag Tag;
    typedef rapidjson::Document JsonDoc;
    typedef std::unique_ptr<JsonDoc> JsonDocUPtr;

    explicit ROSBridge();

    template<class T>
Valentin Platzgummer's avatar
Valentin Platzgummer committed
26 27
    void publish(T &msg, const std::string &topic){
        _topicPublisher.publish(msg, topic);
Valentin Platzgummer's avatar
Valentin Platzgummer committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
    }

    void start();
    void stop();
    bool messagesAvailable();
    bool showMessageTag(Tag &tag);
    template<class T>
    void receive(T &msg){
        _receiver.receive(msg);
    }

private:
    TypeFactory             _typeFactory;
    JsonFactory             _jsonFactory;
    CasePacker              _casePacker;
    RosbridgeWsClient       _rbc;
Valentin Platzgummer's avatar
Valentin Platzgummer committed
44
    ComPrivate::TopicPublisher _topicPublisher;
Valentin Platzgummer's avatar
Valentin Platzgummer committed
45 46 47 48
    ComPrivate::Receiver    _receiver;

};
}