snake.h 3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#ifndef SNAKE_H
#define SNAKE_H

#include <vector>

#include "rapidjson/include/rapidjson/document.h"
#include "rapidjson/include/rapidjson/writer.h"
#include "rapidjson/include/rapidjson/stringbuffer.h"
#include "rapidjson/include/rapidjson/ostreamwrapper.h"

using namespace std;

// C++ implementation of ROS messages in json representation to communicate with rosbridge.
namespace rosbridge_msgs {

    // C++ representation of ros::Time  with fromJson and toJson functions for rosbridge.
    // fromJson not yet implemented.
    class Time{
    public:
        Time();
        Time(uint32_t secs, uint32_t nsecs);

23
        bool toJson(rapidjson::Document &doc, rapidjson::Document::AllocatorType &allocator);
24 25 26 27 28 29 30 31 32 33

        uint32_t secs;
        uint32_t nsecs;
    };

    // C++ representation of std_msgs/Header  with fromJson and toJson functions for rosbridge.
    // fromJson not yet implemented.
    class Header{
    public:
        Header();
34
        Header(uint32_t seq, const Time &stamp, std::string frame_id);
35

36
        bool toJson(rapidjson::Document &doc, rapidjson::Document::AllocatorType &allocator);
37 38 39 40 41 42 43 44 45 46 47 48 49

        uint32_t    seq;
        Time        stamp;
        std::string frame_id;
    };

    // C++ representation of geometry_msgs/Point32 with fromJson and toJson functions for rosbridge.
    // fromJson not yet implemented.
    class Point32{
    public:
        Point32();
        Point32(_Float32 x, _Float32 y, _Float32 z);

50
        bool toJson(rapidjson::Document &doc, rapidjson::Document::AllocatorType &allocator);
51 52 53 54 55 56 57 58 59 60 61

        _Float32 x;
        _Float32 y;
        _Float32 z;
    };

    // C++ representation of geometry_msgs/Polygon with fromJson and toJson functions for rosbridge.
    // fromJson not yet implemented.
    class Polygon{
    public:
        Polygon();
62
        Polygon(const std::vector<Point32> &points);
63

64
        bool toJson(rapidjson::Document &doc, rapidjson::Document::AllocatorType &allocator);
65 66 67 68 69 70 71 72 73

        std::vector<Point32> points;
    };

    // C++ representation of geometry_msgs/PolygonStamped with fromJson and toJson functions for rosbridge.
    // fromJson not yet implemented.
    class PolygonStamped{
    public:
        PolygonStamped();
74
        PolygonStamped(const Header &header, const Polygon &polygon);
75

76
        bool toJson(rapidjson::Document &doc, rapidjson::Document::AllocatorType &allocator);
77 78 79 80 81 82 83 84 85 86

        Header header;
        Polygon polygon;
    };

    // C++ representation of jsk_recognition_msgs/PolygonArray with fromJson and toJson functions for rosbridge.
    // fromJson not yet implemented.
    class PolygonArray{
    public:
        PolygonArray();
87
        PolygonArray(const Header &header, const std::vector<PolygonStamped> &polygons, const std::vector<uint32_t> &labels, const std::vector<_Float32> &likelihood);
88

89
        bool toJson(rapidjson::Document &doc, rapidjson::Document::AllocatorType &allocator);
90 91

        Header header;
92
        std::vector<PolygonStamped> polygons;
93 94 95 96 97 98
        std::vector<uint32_t> labels;
        std::vector<_Float32> likelihood;
    };
}

#endif // SNAKE_H