ros melodic library with custom message

Dependents:   Robot_team1_QEI_Douglas Robot_team1

Committer:
scarter1
Date:
Wed Oct 30 14:59:49 2019 +0000
Revision:
0:020db18a476d
melodic library;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
scarter1 0:020db18a476d 1 #ifndef _ROS_rosserial_msgs_TopicInfo_h
scarter1 0:020db18a476d 2 #define _ROS_rosserial_msgs_TopicInfo_h
scarter1 0:020db18a476d 3
scarter1 0:020db18a476d 4 #include <stdint.h>
scarter1 0:020db18a476d 5 #include <string.h>
scarter1 0:020db18a476d 6 #include <stdlib.h>
scarter1 0:020db18a476d 7 #include "ros/msg.h"
scarter1 0:020db18a476d 8
scarter1 0:020db18a476d 9 namespace rosserial_msgs
scarter1 0:020db18a476d 10 {
scarter1 0:020db18a476d 11
scarter1 0:020db18a476d 12 class TopicInfo : public ros::Msg
scarter1 0:020db18a476d 13 {
scarter1 0:020db18a476d 14 public:
scarter1 0:020db18a476d 15 typedef uint16_t _topic_id_type;
scarter1 0:020db18a476d 16 _topic_id_type topic_id;
scarter1 0:020db18a476d 17 typedef const char* _topic_name_type;
scarter1 0:020db18a476d 18 _topic_name_type topic_name;
scarter1 0:020db18a476d 19 typedef const char* _message_type_type;
scarter1 0:020db18a476d 20 _message_type_type message_type;
scarter1 0:020db18a476d 21 typedef const char* _md5sum_type;
scarter1 0:020db18a476d 22 _md5sum_type md5sum;
scarter1 0:020db18a476d 23 typedef int32_t _buffer_size_type;
scarter1 0:020db18a476d 24 _buffer_size_type buffer_size;
scarter1 0:020db18a476d 25 enum { ID_PUBLISHER = 0 };
scarter1 0:020db18a476d 26 enum { ID_SUBSCRIBER = 1 };
scarter1 0:020db18a476d 27 enum { ID_SERVICE_SERVER = 2 };
scarter1 0:020db18a476d 28 enum { ID_SERVICE_CLIENT = 4 };
scarter1 0:020db18a476d 29 enum { ID_PARAMETER_REQUEST = 6 };
scarter1 0:020db18a476d 30 enum { ID_LOG = 7 };
scarter1 0:020db18a476d 31 enum { ID_TIME = 10 };
scarter1 0:020db18a476d 32 enum { ID_TX_STOP = 11 };
scarter1 0:020db18a476d 33
scarter1 0:020db18a476d 34 TopicInfo():
scarter1 0:020db18a476d 35 topic_id(0),
scarter1 0:020db18a476d 36 topic_name(""),
scarter1 0:020db18a476d 37 message_type(""),
scarter1 0:020db18a476d 38 md5sum(""),
scarter1 0:020db18a476d 39 buffer_size(0)
scarter1 0:020db18a476d 40 {
scarter1 0:020db18a476d 41 }
scarter1 0:020db18a476d 42
scarter1 0:020db18a476d 43 virtual int serialize(unsigned char *outbuffer) const
scarter1 0:020db18a476d 44 {
scarter1 0:020db18a476d 45 int offset = 0;
scarter1 0:020db18a476d 46 *(outbuffer + offset + 0) = (this->topic_id >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 47 *(outbuffer + offset + 1) = (this->topic_id >> (8 * 1)) & 0xFF;
scarter1 0:020db18a476d 48 offset += sizeof(this->topic_id);
scarter1 0:020db18a476d 49 uint32_t length_topic_name = strlen(this->topic_name);
scarter1 0:020db18a476d 50 varToArr(outbuffer + offset, length_topic_name);
scarter1 0:020db18a476d 51 offset += 4;
scarter1 0:020db18a476d 52 memcpy(outbuffer + offset, this->topic_name, length_topic_name);
scarter1 0:020db18a476d 53 offset += length_topic_name;
scarter1 0:020db18a476d 54 uint32_t length_message_type = strlen(this->message_type);
scarter1 0:020db18a476d 55 varToArr(outbuffer + offset, length_message_type);
scarter1 0:020db18a476d 56 offset += 4;
scarter1 0:020db18a476d 57 memcpy(outbuffer + offset, this->message_type, length_message_type);
scarter1 0:020db18a476d 58 offset += length_message_type;
scarter1 0:020db18a476d 59 uint32_t length_md5sum = strlen(this->md5sum);
scarter1 0:020db18a476d 60 varToArr(outbuffer + offset, length_md5sum);
scarter1 0:020db18a476d 61 offset += 4;
scarter1 0:020db18a476d 62 memcpy(outbuffer + offset, this->md5sum, length_md5sum);
scarter1 0:020db18a476d 63 offset += length_md5sum;
scarter1 0:020db18a476d 64 union {
scarter1 0:020db18a476d 65 int32_t real;
scarter1 0:020db18a476d 66 uint32_t base;
scarter1 0:020db18a476d 67 } u_buffer_size;
scarter1 0:020db18a476d 68 u_buffer_size.real = this->buffer_size;
scarter1 0:020db18a476d 69 *(outbuffer + offset + 0) = (u_buffer_size.base >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 70 *(outbuffer + offset + 1) = (u_buffer_size.base >> (8 * 1)) & 0xFF;
scarter1 0:020db18a476d 71 *(outbuffer + offset + 2) = (u_buffer_size.base >> (8 * 2)) & 0xFF;
scarter1 0:020db18a476d 72 *(outbuffer + offset + 3) = (u_buffer_size.base >> (8 * 3)) & 0xFF;
scarter1 0:020db18a476d 73 offset += sizeof(this->buffer_size);
scarter1 0:020db18a476d 74 return offset;
scarter1 0:020db18a476d 75 }
scarter1 0:020db18a476d 76
scarter1 0:020db18a476d 77 virtual int deserialize(unsigned char *inbuffer)
scarter1 0:020db18a476d 78 {
scarter1 0:020db18a476d 79 int offset = 0;
scarter1 0:020db18a476d 80 this->topic_id = ((uint16_t) (*(inbuffer + offset)));
scarter1 0:020db18a476d 81 this->topic_id |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
scarter1 0:020db18a476d 82 offset += sizeof(this->topic_id);
scarter1 0:020db18a476d 83 uint32_t length_topic_name;
scarter1 0:020db18a476d 84 arrToVar(length_topic_name, (inbuffer + offset));
scarter1 0:020db18a476d 85 offset += 4;
scarter1 0:020db18a476d 86 for(unsigned int k= offset; k< offset+length_topic_name; ++k){
scarter1 0:020db18a476d 87 inbuffer[k-1]=inbuffer[k];
scarter1 0:020db18a476d 88 }
scarter1 0:020db18a476d 89 inbuffer[offset+length_topic_name-1]=0;
scarter1 0:020db18a476d 90 this->topic_name = (char *)(inbuffer + offset-1);
scarter1 0:020db18a476d 91 offset += length_topic_name;
scarter1 0:020db18a476d 92 uint32_t length_message_type;
scarter1 0:020db18a476d 93 arrToVar(length_message_type, (inbuffer + offset));
scarter1 0:020db18a476d 94 offset += 4;
scarter1 0:020db18a476d 95 for(unsigned int k= offset; k< offset+length_message_type; ++k){
scarter1 0:020db18a476d 96 inbuffer[k-1]=inbuffer[k];
scarter1 0:020db18a476d 97 }
scarter1 0:020db18a476d 98 inbuffer[offset+length_message_type-1]=0;
scarter1 0:020db18a476d 99 this->message_type = (char *)(inbuffer + offset-1);
scarter1 0:020db18a476d 100 offset += length_message_type;
scarter1 0:020db18a476d 101 uint32_t length_md5sum;
scarter1 0:020db18a476d 102 arrToVar(length_md5sum, (inbuffer + offset));
scarter1 0:020db18a476d 103 offset += 4;
scarter1 0:020db18a476d 104 for(unsigned int k= offset; k< offset+length_md5sum; ++k){
scarter1 0:020db18a476d 105 inbuffer[k-1]=inbuffer[k];
scarter1 0:020db18a476d 106 }
scarter1 0:020db18a476d 107 inbuffer[offset+length_md5sum-1]=0;
scarter1 0:020db18a476d 108 this->md5sum = (char *)(inbuffer + offset-1);
scarter1 0:020db18a476d 109 offset += length_md5sum;
scarter1 0:020db18a476d 110 union {
scarter1 0:020db18a476d 111 int32_t real;
scarter1 0:020db18a476d 112 uint32_t base;
scarter1 0:020db18a476d 113 } u_buffer_size;
scarter1 0:020db18a476d 114 u_buffer_size.base = 0;
scarter1 0:020db18a476d 115 u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
scarter1 0:020db18a476d 116 u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
scarter1 0:020db18a476d 117 u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
scarter1 0:020db18a476d 118 u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
scarter1 0:020db18a476d 119 this->buffer_size = u_buffer_size.real;
scarter1 0:020db18a476d 120 offset += sizeof(this->buffer_size);
scarter1 0:020db18a476d 121 return offset;
scarter1 0:020db18a476d 122 }
scarter1 0:020db18a476d 123
scarter1 0:020db18a476d 124 const char * getType(){ return "rosserial_msgs/TopicInfo"; };
scarter1 0:020db18a476d 125 const char * getMD5(){ return "0ad51f88fc44892f8c10684077646005"; };
scarter1 0:020db18a476d 126
scarter1 0:020db18a476d 127 };
scarter1 0:020db18a476d 128
scarter1 0:020db18a476d 129 }
scarter1 0:020db18a476d 130 #endif