ros melodic library with custom message

Dependents:   Robot_team1_QEI_Douglas Robot_team1

Committer:
florine_van
Date:
Tue Dec 03 09:39:29 2019 +0000
Revision:
3:b964e3f71102
Parent:
0:020db18a476d
Clean code and remove unused lines

Who changed what in which revision?

UserRevisionLine numberNew contents of line
scarter1 0:020db18a476d 1 #ifndef _ROS_SERVICE_NodeletLoad_h
scarter1 0:020db18a476d 2 #define _ROS_SERVICE_NodeletLoad_h
scarter1 0:020db18a476d 3 #include <stdint.h>
scarter1 0:020db18a476d 4 #include <string.h>
scarter1 0:020db18a476d 5 #include <stdlib.h>
scarter1 0:020db18a476d 6 #include "ros/msg.h"
scarter1 0:020db18a476d 7
scarter1 0:020db18a476d 8 namespace nodelet
scarter1 0:020db18a476d 9 {
scarter1 0:020db18a476d 10
scarter1 0:020db18a476d 11 static const char NODELETLOAD[] = "nodelet/NodeletLoad";
scarter1 0:020db18a476d 12
scarter1 0:020db18a476d 13 class NodeletLoadRequest : public ros::Msg
scarter1 0:020db18a476d 14 {
scarter1 0:020db18a476d 15 public:
scarter1 0:020db18a476d 16 typedef const char* _name_type;
scarter1 0:020db18a476d 17 _name_type name;
scarter1 0:020db18a476d 18 typedef const char* _type_type;
scarter1 0:020db18a476d 19 _type_type type;
scarter1 0:020db18a476d 20 uint32_t remap_source_args_length;
scarter1 0:020db18a476d 21 typedef char* _remap_source_args_type;
scarter1 0:020db18a476d 22 _remap_source_args_type st_remap_source_args;
scarter1 0:020db18a476d 23 _remap_source_args_type * remap_source_args;
scarter1 0:020db18a476d 24 uint32_t remap_target_args_length;
scarter1 0:020db18a476d 25 typedef char* _remap_target_args_type;
scarter1 0:020db18a476d 26 _remap_target_args_type st_remap_target_args;
scarter1 0:020db18a476d 27 _remap_target_args_type * remap_target_args;
scarter1 0:020db18a476d 28 uint32_t my_argv_length;
scarter1 0:020db18a476d 29 typedef char* _my_argv_type;
scarter1 0:020db18a476d 30 _my_argv_type st_my_argv;
scarter1 0:020db18a476d 31 _my_argv_type * my_argv;
scarter1 0:020db18a476d 32 typedef const char* _bond_id_type;
scarter1 0:020db18a476d 33 _bond_id_type bond_id;
scarter1 0:020db18a476d 34
scarter1 0:020db18a476d 35 NodeletLoadRequest():
scarter1 0:020db18a476d 36 name(""),
scarter1 0:020db18a476d 37 type(""),
scarter1 0:020db18a476d 38 remap_source_args_length(0), remap_source_args(NULL),
scarter1 0:020db18a476d 39 remap_target_args_length(0), remap_target_args(NULL),
scarter1 0:020db18a476d 40 my_argv_length(0), my_argv(NULL),
scarter1 0:020db18a476d 41 bond_id("")
scarter1 0:020db18a476d 42 {
scarter1 0:020db18a476d 43 }
scarter1 0:020db18a476d 44
scarter1 0:020db18a476d 45 virtual int serialize(unsigned char *outbuffer) const
scarter1 0:020db18a476d 46 {
scarter1 0:020db18a476d 47 int offset = 0;
scarter1 0:020db18a476d 48 uint32_t length_name = strlen(this->name);
scarter1 0:020db18a476d 49 varToArr(outbuffer + offset, length_name);
scarter1 0:020db18a476d 50 offset += 4;
scarter1 0:020db18a476d 51 memcpy(outbuffer + offset, this->name, length_name);
scarter1 0:020db18a476d 52 offset += length_name;
scarter1 0:020db18a476d 53 uint32_t length_type = strlen(this->type);
scarter1 0:020db18a476d 54 varToArr(outbuffer + offset, length_type);
scarter1 0:020db18a476d 55 offset += 4;
scarter1 0:020db18a476d 56 memcpy(outbuffer + offset, this->type, length_type);
scarter1 0:020db18a476d 57 offset += length_type;
scarter1 0:020db18a476d 58 *(outbuffer + offset + 0) = (this->remap_source_args_length >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 59 *(outbuffer + offset + 1) = (this->remap_source_args_length >> (8 * 1)) & 0xFF;
scarter1 0:020db18a476d 60 *(outbuffer + offset + 2) = (this->remap_source_args_length >> (8 * 2)) & 0xFF;
scarter1 0:020db18a476d 61 *(outbuffer + offset + 3) = (this->remap_source_args_length >> (8 * 3)) & 0xFF;
scarter1 0:020db18a476d 62 offset += sizeof(this->remap_source_args_length);
scarter1 0:020db18a476d 63 for( uint32_t i = 0; i < remap_source_args_length; i++){
scarter1 0:020db18a476d 64 uint32_t length_remap_source_argsi = strlen(this->remap_source_args[i]);
scarter1 0:020db18a476d 65 varToArr(outbuffer + offset, length_remap_source_argsi);
scarter1 0:020db18a476d 66 offset += 4;
scarter1 0:020db18a476d 67 memcpy(outbuffer + offset, this->remap_source_args[i], length_remap_source_argsi);
scarter1 0:020db18a476d 68 offset += length_remap_source_argsi;
scarter1 0:020db18a476d 69 }
scarter1 0:020db18a476d 70 *(outbuffer + offset + 0) = (this->remap_target_args_length >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 71 *(outbuffer + offset + 1) = (this->remap_target_args_length >> (8 * 1)) & 0xFF;
scarter1 0:020db18a476d 72 *(outbuffer + offset + 2) = (this->remap_target_args_length >> (8 * 2)) & 0xFF;
scarter1 0:020db18a476d 73 *(outbuffer + offset + 3) = (this->remap_target_args_length >> (8 * 3)) & 0xFF;
scarter1 0:020db18a476d 74 offset += sizeof(this->remap_target_args_length);
scarter1 0:020db18a476d 75 for( uint32_t i = 0; i < remap_target_args_length; i++){
scarter1 0:020db18a476d 76 uint32_t length_remap_target_argsi = strlen(this->remap_target_args[i]);
scarter1 0:020db18a476d 77 varToArr(outbuffer + offset, length_remap_target_argsi);
scarter1 0:020db18a476d 78 offset += 4;
scarter1 0:020db18a476d 79 memcpy(outbuffer + offset, this->remap_target_args[i], length_remap_target_argsi);
scarter1 0:020db18a476d 80 offset += length_remap_target_argsi;
scarter1 0:020db18a476d 81 }
scarter1 0:020db18a476d 82 *(outbuffer + offset + 0) = (this->my_argv_length >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 83 *(outbuffer + offset + 1) = (this->my_argv_length >> (8 * 1)) & 0xFF;
scarter1 0:020db18a476d 84 *(outbuffer + offset + 2) = (this->my_argv_length >> (8 * 2)) & 0xFF;
scarter1 0:020db18a476d 85 *(outbuffer + offset + 3) = (this->my_argv_length >> (8 * 3)) & 0xFF;
scarter1 0:020db18a476d 86 offset += sizeof(this->my_argv_length);
scarter1 0:020db18a476d 87 for( uint32_t i = 0; i < my_argv_length; i++){
scarter1 0:020db18a476d 88 uint32_t length_my_argvi = strlen(this->my_argv[i]);
scarter1 0:020db18a476d 89 varToArr(outbuffer + offset, length_my_argvi);
scarter1 0:020db18a476d 90 offset += 4;
scarter1 0:020db18a476d 91 memcpy(outbuffer + offset, this->my_argv[i], length_my_argvi);
scarter1 0:020db18a476d 92 offset += length_my_argvi;
scarter1 0:020db18a476d 93 }
scarter1 0:020db18a476d 94 uint32_t length_bond_id = strlen(this->bond_id);
scarter1 0:020db18a476d 95 varToArr(outbuffer + offset, length_bond_id);
scarter1 0:020db18a476d 96 offset += 4;
scarter1 0:020db18a476d 97 memcpy(outbuffer + offset, this->bond_id, length_bond_id);
scarter1 0:020db18a476d 98 offset += length_bond_id;
scarter1 0:020db18a476d 99 return offset;
scarter1 0:020db18a476d 100 }
scarter1 0:020db18a476d 101
scarter1 0:020db18a476d 102 virtual int deserialize(unsigned char *inbuffer)
scarter1 0:020db18a476d 103 {
scarter1 0:020db18a476d 104 int offset = 0;
scarter1 0:020db18a476d 105 uint32_t length_name;
scarter1 0:020db18a476d 106 arrToVar(length_name, (inbuffer + offset));
scarter1 0:020db18a476d 107 offset += 4;
scarter1 0:020db18a476d 108 for(unsigned int k= offset; k< offset+length_name; ++k){
scarter1 0:020db18a476d 109 inbuffer[k-1]=inbuffer[k];
scarter1 0:020db18a476d 110 }
scarter1 0:020db18a476d 111 inbuffer[offset+length_name-1]=0;
scarter1 0:020db18a476d 112 this->name = (char *)(inbuffer + offset-1);
scarter1 0:020db18a476d 113 offset += length_name;
scarter1 0:020db18a476d 114 uint32_t length_type;
scarter1 0:020db18a476d 115 arrToVar(length_type, (inbuffer + offset));
scarter1 0:020db18a476d 116 offset += 4;
scarter1 0:020db18a476d 117 for(unsigned int k= offset; k< offset+length_type; ++k){
scarter1 0:020db18a476d 118 inbuffer[k-1]=inbuffer[k];
scarter1 0:020db18a476d 119 }
scarter1 0:020db18a476d 120 inbuffer[offset+length_type-1]=0;
scarter1 0:020db18a476d 121 this->type = (char *)(inbuffer + offset-1);
scarter1 0:020db18a476d 122 offset += length_type;
scarter1 0:020db18a476d 123 uint32_t remap_source_args_lengthT = ((uint32_t) (*(inbuffer + offset)));
scarter1 0:020db18a476d 124 remap_source_args_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
scarter1 0:020db18a476d 125 remap_source_args_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
scarter1 0:020db18a476d 126 remap_source_args_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
scarter1 0:020db18a476d 127 offset += sizeof(this->remap_source_args_length);
scarter1 0:020db18a476d 128 if(remap_source_args_lengthT > remap_source_args_length)
scarter1 0:020db18a476d 129 this->remap_source_args = (char**)realloc(this->remap_source_args, remap_source_args_lengthT * sizeof(char*));
scarter1 0:020db18a476d 130 remap_source_args_length = remap_source_args_lengthT;
scarter1 0:020db18a476d 131 for( uint32_t i = 0; i < remap_source_args_length; i++){
scarter1 0:020db18a476d 132 uint32_t length_st_remap_source_args;
scarter1 0:020db18a476d 133 arrToVar(length_st_remap_source_args, (inbuffer + offset));
scarter1 0:020db18a476d 134 offset += 4;
scarter1 0:020db18a476d 135 for(unsigned int k= offset; k< offset+length_st_remap_source_args; ++k){
scarter1 0:020db18a476d 136 inbuffer[k-1]=inbuffer[k];
scarter1 0:020db18a476d 137 }
scarter1 0:020db18a476d 138 inbuffer[offset+length_st_remap_source_args-1]=0;
scarter1 0:020db18a476d 139 this->st_remap_source_args = (char *)(inbuffer + offset-1);
scarter1 0:020db18a476d 140 offset += length_st_remap_source_args;
scarter1 0:020db18a476d 141 memcpy( &(this->remap_source_args[i]), &(this->st_remap_source_args), sizeof(char*));
scarter1 0:020db18a476d 142 }
scarter1 0:020db18a476d 143 uint32_t remap_target_args_lengthT = ((uint32_t) (*(inbuffer + offset)));
scarter1 0:020db18a476d 144 remap_target_args_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
scarter1 0:020db18a476d 145 remap_target_args_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
scarter1 0:020db18a476d 146 remap_target_args_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
scarter1 0:020db18a476d 147 offset += sizeof(this->remap_target_args_length);
scarter1 0:020db18a476d 148 if(remap_target_args_lengthT > remap_target_args_length)
scarter1 0:020db18a476d 149 this->remap_target_args = (char**)realloc(this->remap_target_args, remap_target_args_lengthT * sizeof(char*));
scarter1 0:020db18a476d 150 remap_target_args_length = remap_target_args_lengthT;
scarter1 0:020db18a476d 151 for( uint32_t i = 0; i < remap_target_args_length; i++){
scarter1 0:020db18a476d 152 uint32_t length_st_remap_target_args;
scarter1 0:020db18a476d 153 arrToVar(length_st_remap_target_args, (inbuffer + offset));
scarter1 0:020db18a476d 154 offset += 4;
scarter1 0:020db18a476d 155 for(unsigned int k= offset; k< offset+length_st_remap_target_args; ++k){
scarter1 0:020db18a476d 156 inbuffer[k-1]=inbuffer[k];
scarter1 0:020db18a476d 157 }
scarter1 0:020db18a476d 158 inbuffer[offset+length_st_remap_target_args-1]=0;
scarter1 0:020db18a476d 159 this->st_remap_target_args = (char *)(inbuffer + offset-1);
scarter1 0:020db18a476d 160 offset += length_st_remap_target_args;
scarter1 0:020db18a476d 161 memcpy( &(this->remap_target_args[i]), &(this->st_remap_target_args), sizeof(char*));
scarter1 0:020db18a476d 162 }
scarter1 0:020db18a476d 163 uint32_t my_argv_lengthT = ((uint32_t) (*(inbuffer + offset)));
scarter1 0:020db18a476d 164 my_argv_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
scarter1 0:020db18a476d 165 my_argv_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
scarter1 0:020db18a476d 166 my_argv_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
scarter1 0:020db18a476d 167 offset += sizeof(this->my_argv_length);
scarter1 0:020db18a476d 168 if(my_argv_lengthT > my_argv_length)
scarter1 0:020db18a476d 169 this->my_argv = (char**)realloc(this->my_argv, my_argv_lengthT * sizeof(char*));
scarter1 0:020db18a476d 170 my_argv_length = my_argv_lengthT;
scarter1 0:020db18a476d 171 for( uint32_t i = 0; i < my_argv_length; i++){
scarter1 0:020db18a476d 172 uint32_t length_st_my_argv;
scarter1 0:020db18a476d 173 arrToVar(length_st_my_argv, (inbuffer + offset));
scarter1 0:020db18a476d 174 offset += 4;
scarter1 0:020db18a476d 175 for(unsigned int k= offset; k< offset+length_st_my_argv; ++k){
scarter1 0:020db18a476d 176 inbuffer[k-1]=inbuffer[k];
scarter1 0:020db18a476d 177 }
scarter1 0:020db18a476d 178 inbuffer[offset+length_st_my_argv-1]=0;
scarter1 0:020db18a476d 179 this->st_my_argv = (char *)(inbuffer + offset-1);
scarter1 0:020db18a476d 180 offset += length_st_my_argv;
scarter1 0:020db18a476d 181 memcpy( &(this->my_argv[i]), &(this->st_my_argv), sizeof(char*));
scarter1 0:020db18a476d 182 }
scarter1 0:020db18a476d 183 uint32_t length_bond_id;
scarter1 0:020db18a476d 184 arrToVar(length_bond_id, (inbuffer + offset));
scarter1 0:020db18a476d 185 offset += 4;
scarter1 0:020db18a476d 186 for(unsigned int k= offset; k< offset+length_bond_id; ++k){
scarter1 0:020db18a476d 187 inbuffer[k-1]=inbuffer[k];
scarter1 0:020db18a476d 188 }
scarter1 0:020db18a476d 189 inbuffer[offset+length_bond_id-1]=0;
scarter1 0:020db18a476d 190 this->bond_id = (char *)(inbuffer + offset-1);
scarter1 0:020db18a476d 191 offset += length_bond_id;
scarter1 0:020db18a476d 192 return offset;
scarter1 0:020db18a476d 193 }
scarter1 0:020db18a476d 194
scarter1 0:020db18a476d 195 const char * getType(){ return NODELETLOAD; };
scarter1 0:020db18a476d 196 const char * getMD5(){ return "c6e28cc4d2e259249d96cfb50658fbec"; };
scarter1 0:020db18a476d 197
scarter1 0:020db18a476d 198 };
scarter1 0:020db18a476d 199
scarter1 0:020db18a476d 200 class NodeletLoadResponse : public ros::Msg
scarter1 0:020db18a476d 201 {
scarter1 0:020db18a476d 202 public:
scarter1 0:020db18a476d 203 typedef bool _success_type;
scarter1 0:020db18a476d 204 _success_type success;
scarter1 0:020db18a476d 205
scarter1 0:020db18a476d 206 NodeletLoadResponse():
scarter1 0:020db18a476d 207 success(0)
scarter1 0:020db18a476d 208 {
scarter1 0:020db18a476d 209 }
scarter1 0:020db18a476d 210
scarter1 0:020db18a476d 211 virtual int serialize(unsigned char *outbuffer) const
scarter1 0:020db18a476d 212 {
scarter1 0:020db18a476d 213 int offset = 0;
scarter1 0:020db18a476d 214 union {
scarter1 0:020db18a476d 215 bool real;
scarter1 0:020db18a476d 216 uint8_t base;
scarter1 0:020db18a476d 217 } u_success;
scarter1 0:020db18a476d 218 u_success.real = this->success;
scarter1 0:020db18a476d 219 *(outbuffer + offset + 0) = (u_success.base >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 220 offset += sizeof(this->success);
scarter1 0:020db18a476d 221 return offset;
scarter1 0:020db18a476d 222 }
scarter1 0:020db18a476d 223
scarter1 0:020db18a476d 224 virtual int deserialize(unsigned char *inbuffer)
scarter1 0:020db18a476d 225 {
scarter1 0:020db18a476d 226 int offset = 0;
scarter1 0:020db18a476d 227 union {
scarter1 0:020db18a476d 228 bool real;
scarter1 0:020db18a476d 229 uint8_t base;
scarter1 0:020db18a476d 230 } u_success;
scarter1 0:020db18a476d 231 u_success.base = 0;
scarter1 0:020db18a476d 232 u_success.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
scarter1 0:020db18a476d 233 this->success = u_success.real;
scarter1 0:020db18a476d 234 offset += sizeof(this->success);
scarter1 0:020db18a476d 235 return offset;
scarter1 0:020db18a476d 236 }
scarter1 0:020db18a476d 237
scarter1 0:020db18a476d 238 const char * getType(){ return NODELETLOAD; };
scarter1 0:020db18a476d 239 const char * getMD5(){ return "358e233cde0c8a8bcfea4ce193f8fc15"; };
scarter1 0:020db18a476d 240
scarter1 0:020db18a476d 241 };
scarter1 0:020db18a476d 242
scarter1 0:020db18a476d 243 class NodeletLoad {
scarter1 0:020db18a476d 244 public:
scarter1 0:020db18a476d 245 typedef NodeletLoadRequest Request;
scarter1 0:020db18a476d 246 typedef NodeletLoadResponse Response;
scarter1 0:020db18a476d 247 };
scarter1 0:020db18a476d 248
scarter1 0:020db18a476d 249 }
scarter1 0:020db18a476d 250 #endif