Just changed OUTPUT_SIZE and INPUT_SIZE in ros/node_handle.h

Dependencies:   BufferedSerial

Dependents:   WRS2020_mecanum_node

Committer:
sgrsn
Date:
Mon Nov 02 09:00:01 2020 +0000
Revision:
2:5d429be7d0aa
Parent:
0:04ac6be8229a
Change INPUT_SIZE and OUTPUT_SIZE on node_handle.h to pub sub

Who changed what in which revision?

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