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_smach_msgs_SmachContainerStructure_h
scarter1 0:020db18a476d 2 #define _ROS_smach_msgs_SmachContainerStructure_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 #include "std_msgs/Header.h"
scarter1 0:020db18a476d 9
scarter1 0:020db18a476d 10 namespace smach_msgs
scarter1 0:020db18a476d 11 {
scarter1 0:020db18a476d 12
scarter1 0:020db18a476d 13 class SmachContainerStructure : public ros::Msg
scarter1 0:020db18a476d 14 {
scarter1 0:020db18a476d 15 public:
scarter1 0:020db18a476d 16 typedef std_msgs::Header _header_type;
scarter1 0:020db18a476d 17 _header_type header;
scarter1 0:020db18a476d 18 typedef const char* _path_type;
scarter1 0:020db18a476d 19 _path_type path;
scarter1 0:020db18a476d 20 uint32_t children_length;
scarter1 0:020db18a476d 21 typedef char* _children_type;
scarter1 0:020db18a476d 22 _children_type st_children;
scarter1 0:020db18a476d 23 _children_type * children;
scarter1 0:020db18a476d 24 uint32_t internal_outcomes_length;
scarter1 0:020db18a476d 25 typedef char* _internal_outcomes_type;
scarter1 0:020db18a476d 26 _internal_outcomes_type st_internal_outcomes;
scarter1 0:020db18a476d 27 _internal_outcomes_type * internal_outcomes;
scarter1 0:020db18a476d 28 uint32_t outcomes_from_length;
scarter1 0:020db18a476d 29 typedef char* _outcomes_from_type;
scarter1 0:020db18a476d 30 _outcomes_from_type st_outcomes_from;
scarter1 0:020db18a476d 31 _outcomes_from_type * outcomes_from;
scarter1 0:020db18a476d 32 uint32_t outcomes_to_length;
scarter1 0:020db18a476d 33 typedef char* _outcomes_to_type;
scarter1 0:020db18a476d 34 _outcomes_to_type st_outcomes_to;
scarter1 0:020db18a476d 35 _outcomes_to_type * outcomes_to;
scarter1 0:020db18a476d 36 uint32_t container_outcomes_length;
scarter1 0:020db18a476d 37 typedef char* _container_outcomes_type;
scarter1 0:020db18a476d 38 _container_outcomes_type st_container_outcomes;
scarter1 0:020db18a476d 39 _container_outcomes_type * container_outcomes;
scarter1 0:020db18a476d 40
scarter1 0:020db18a476d 41 SmachContainerStructure():
scarter1 0:020db18a476d 42 header(),
scarter1 0:020db18a476d 43 path(""),
scarter1 0:020db18a476d 44 children_length(0), children(NULL),
scarter1 0:020db18a476d 45 internal_outcomes_length(0), internal_outcomes(NULL),
scarter1 0:020db18a476d 46 outcomes_from_length(0), outcomes_from(NULL),
scarter1 0:020db18a476d 47 outcomes_to_length(0), outcomes_to(NULL),
scarter1 0:020db18a476d 48 container_outcomes_length(0), container_outcomes(NULL)
scarter1 0:020db18a476d 49 {
scarter1 0:020db18a476d 50 }
scarter1 0:020db18a476d 51
scarter1 0:020db18a476d 52 virtual int serialize(unsigned char *outbuffer) const
scarter1 0:020db18a476d 53 {
scarter1 0:020db18a476d 54 int offset = 0;
scarter1 0:020db18a476d 55 offset += this->header.serialize(outbuffer + offset);
scarter1 0:020db18a476d 56 uint32_t length_path = strlen(this->path);
scarter1 0:020db18a476d 57 varToArr(outbuffer + offset, length_path);
scarter1 0:020db18a476d 58 offset += 4;
scarter1 0:020db18a476d 59 memcpy(outbuffer + offset, this->path, length_path);
scarter1 0:020db18a476d 60 offset += length_path;
scarter1 0:020db18a476d 61 *(outbuffer + offset + 0) = (this->children_length >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 62 *(outbuffer + offset + 1) = (this->children_length >> (8 * 1)) & 0xFF;
scarter1 0:020db18a476d 63 *(outbuffer + offset + 2) = (this->children_length >> (8 * 2)) & 0xFF;
scarter1 0:020db18a476d 64 *(outbuffer + offset + 3) = (this->children_length >> (8 * 3)) & 0xFF;
scarter1 0:020db18a476d 65 offset += sizeof(this->children_length);
scarter1 0:020db18a476d 66 for( uint32_t i = 0; i < children_length; i++){
scarter1 0:020db18a476d 67 uint32_t length_childreni = strlen(this->children[i]);
scarter1 0:020db18a476d 68 varToArr(outbuffer + offset, length_childreni);
scarter1 0:020db18a476d 69 offset += 4;
scarter1 0:020db18a476d 70 memcpy(outbuffer + offset, this->children[i], length_childreni);
scarter1 0:020db18a476d 71 offset += length_childreni;
scarter1 0:020db18a476d 72 }
scarter1 0:020db18a476d 73 *(outbuffer + offset + 0) = (this->internal_outcomes_length >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 74 *(outbuffer + offset + 1) = (this->internal_outcomes_length >> (8 * 1)) & 0xFF;
scarter1 0:020db18a476d 75 *(outbuffer + offset + 2) = (this->internal_outcomes_length >> (8 * 2)) & 0xFF;
scarter1 0:020db18a476d 76 *(outbuffer + offset + 3) = (this->internal_outcomes_length >> (8 * 3)) & 0xFF;
scarter1 0:020db18a476d 77 offset += sizeof(this->internal_outcomes_length);
scarter1 0:020db18a476d 78 for( uint32_t i = 0; i < internal_outcomes_length; i++){
scarter1 0:020db18a476d 79 uint32_t length_internal_outcomesi = strlen(this->internal_outcomes[i]);
scarter1 0:020db18a476d 80 varToArr(outbuffer + offset, length_internal_outcomesi);
scarter1 0:020db18a476d 81 offset += 4;
scarter1 0:020db18a476d 82 memcpy(outbuffer + offset, this->internal_outcomes[i], length_internal_outcomesi);
scarter1 0:020db18a476d 83 offset += length_internal_outcomesi;
scarter1 0:020db18a476d 84 }
scarter1 0:020db18a476d 85 *(outbuffer + offset + 0) = (this->outcomes_from_length >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 86 *(outbuffer + offset + 1) = (this->outcomes_from_length >> (8 * 1)) & 0xFF;
scarter1 0:020db18a476d 87 *(outbuffer + offset + 2) = (this->outcomes_from_length >> (8 * 2)) & 0xFF;
scarter1 0:020db18a476d 88 *(outbuffer + offset + 3) = (this->outcomes_from_length >> (8 * 3)) & 0xFF;
scarter1 0:020db18a476d 89 offset += sizeof(this->outcomes_from_length);
scarter1 0:020db18a476d 90 for( uint32_t i = 0; i < outcomes_from_length; i++){
scarter1 0:020db18a476d 91 uint32_t length_outcomes_fromi = strlen(this->outcomes_from[i]);
scarter1 0:020db18a476d 92 varToArr(outbuffer + offset, length_outcomes_fromi);
scarter1 0:020db18a476d 93 offset += 4;
scarter1 0:020db18a476d 94 memcpy(outbuffer + offset, this->outcomes_from[i], length_outcomes_fromi);
scarter1 0:020db18a476d 95 offset += length_outcomes_fromi;
scarter1 0:020db18a476d 96 }
scarter1 0:020db18a476d 97 *(outbuffer + offset + 0) = (this->outcomes_to_length >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 98 *(outbuffer + offset + 1) = (this->outcomes_to_length >> (8 * 1)) & 0xFF;
scarter1 0:020db18a476d 99 *(outbuffer + offset + 2) = (this->outcomes_to_length >> (8 * 2)) & 0xFF;
scarter1 0:020db18a476d 100 *(outbuffer + offset + 3) = (this->outcomes_to_length >> (8 * 3)) & 0xFF;
scarter1 0:020db18a476d 101 offset += sizeof(this->outcomes_to_length);
scarter1 0:020db18a476d 102 for( uint32_t i = 0; i < outcomes_to_length; i++){
scarter1 0:020db18a476d 103 uint32_t length_outcomes_toi = strlen(this->outcomes_to[i]);
scarter1 0:020db18a476d 104 varToArr(outbuffer + offset, length_outcomes_toi);
scarter1 0:020db18a476d 105 offset += 4;
scarter1 0:020db18a476d 106 memcpy(outbuffer + offset, this->outcomes_to[i], length_outcomes_toi);
scarter1 0:020db18a476d 107 offset += length_outcomes_toi;
scarter1 0:020db18a476d 108 }
scarter1 0:020db18a476d 109 *(outbuffer + offset + 0) = (this->container_outcomes_length >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 110 *(outbuffer + offset + 1) = (this->container_outcomes_length >> (8 * 1)) & 0xFF;
scarter1 0:020db18a476d 111 *(outbuffer + offset + 2) = (this->container_outcomes_length >> (8 * 2)) & 0xFF;
scarter1 0:020db18a476d 112 *(outbuffer + offset + 3) = (this->container_outcomes_length >> (8 * 3)) & 0xFF;
scarter1 0:020db18a476d 113 offset += sizeof(this->container_outcomes_length);
scarter1 0:020db18a476d 114 for( uint32_t i = 0; i < container_outcomes_length; i++){
scarter1 0:020db18a476d 115 uint32_t length_container_outcomesi = strlen(this->container_outcomes[i]);
scarter1 0:020db18a476d 116 varToArr(outbuffer + offset, length_container_outcomesi);
scarter1 0:020db18a476d 117 offset += 4;
scarter1 0:020db18a476d 118 memcpy(outbuffer + offset, this->container_outcomes[i], length_container_outcomesi);
scarter1 0:020db18a476d 119 offset += length_container_outcomesi;
scarter1 0:020db18a476d 120 }
scarter1 0:020db18a476d 121 return offset;
scarter1 0:020db18a476d 122 }
scarter1 0:020db18a476d 123
scarter1 0:020db18a476d 124 virtual int deserialize(unsigned char *inbuffer)
scarter1 0:020db18a476d 125 {
scarter1 0:020db18a476d 126 int offset = 0;
scarter1 0:020db18a476d 127 offset += this->header.deserialize(inbuffer + offset);
scarter1 0:020db18a476d 128 uint32_t length_path;
scarter1 0:020db18a476d 129 arrToVar(length_path, (inbuffer + offset));
scarter1 0:020db18a476d 130 offset += 4;
scarter1 0:020db18a476d 131 for(unsigned int k= offset; k< offset+length_path; ++k){
scarter1 0:020db18a476d 132 inbuffer[k-1]=inbuffer[k];
scarter1 0:020db18a476d 133 }
scarter1 0:020db18a476d 134 inbuffer[offset+length_path-1]=0;
scarter1 0:020db18a476d 135 this->path = (char *)(inbuffer + offset-1);
scarter1 0:020db18a476d 136 offset += length_path;
scarter1 0:020db18a476d 137 uint32_t children_lengthT = ((uint32_t) (*(inbuffer + offset)));
scarter1 0:020db18a476d 138 children_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
scarter1 0:020db18a476d 139 children_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
scarter1 0:020db18a476d 140 children_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
scarter1 0:020db18a476d 141 offset += sizeof(this->children_length);
scarter1 0:020db18a476d 142 if(children_lengthT > children_length)
scarter1 0:020db18a476d 143 this->children = (char**)realloc(this->children, children_lengthT * sizeof(char*));
scarter1 0:020db18a476d 144 children_length = children_lengthT;
scarter1 0:020db18a476d 145 for( uint32_t i = 0; i < children_length; i++){
scarter1 0:020db18a476d 146 uint32_t length_st_children;
scarter1 0:020db18a476d 147 arrToVar(length_st_children, (inbuffer + offset));
scarter1 0:020db18a476d 148 offset += 4;
scarter1 0:020db18a476d 149 for(unsigned int k= offset; k< offset+length_st_children; ++k){
scarter1 0:020db18a476d 150 inbuffer[k-1]=inbuffer[k];
scarter1 0:020db18a476d 151 }
scarter1 0:020db18a476d 152 inbuffer[offset+length_st_children-1]=0;
scarter1 0:020db18a476d 153 this->st_children = (char *)(inbuffer + offset-1);
scarter1 0:020db18a476d 154 offset += length_st_children;
scarter1 0:020db18a476d 155 memcpy( &(this->children[i]), &(this->st_children), sizeof(char*));
scarter1 0:020db18a476d 156 }
scarter1 0:020db18a476d 157 uint32_t internal_outcomes_lengthT = ((uint32_t) (*(inbuffer + offset)));
scarter1 0:020db18a476d 158 internal_outcomes_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
scarter1 0:020db18a476d 159 internal_outcomes_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
scarter1 0:020db18a476d 160 internal_outcomes_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
scarter1 0:020db18a476d 161 offset += sizeof(this->internal_outcomes_length);
scarter1 0:020db18a476d 162 if(internal_outcomes_lengthT > internal_outcomes_length)
scarter1 0:020db18a476d 163 this->internal_outcomes = (char**)realloc(this->internal_outcomes, internal_outcomes_lengthT * sizeof(char*));
scarter1 0:020db18a476d 164 internal_outcomes_length = internal_outcomes_lengthT;
scarter1 0:020db18a476d 165 for( uint32_t i = 0; i < internal_outcomes_length; i++){
scarter1 0:020db18a476d 166 uint32_t length_st_internal_outcomes;
scarter1 0:020db18a476d 167 arrToVar(length_st_internal_outcomes, (inbuffer + offset));
scarter1 0:020db18a476d 168 offset += 4;
scarter1 0:020db18a476d 169 for(unsigned int k= offset; k< offset+length_st_internal_outcomes; ++k){
scarter1 0:020db18a476d 170 inbuffer[k-1]=inbuffer[k];
scarter1 0:020db18a476d 171 }
scarter1 0:020db18a476d 172 inbuffer[offset+length_st_internal_outcomes-1]=0;
scarter1 0:020db18a476d 173 this->st_internal_outcomes = (char *)(inbuffer + offset-1);
scarter1 0:020db18a476d 174 offset += length_st_internal_outcomes;
scarter1 0:020db18a476d 175 memcpy( &(this->internal_outcomes[i]), &(this->st_internal_outcomes), sizeof(char*));
scarter1 0:020db18a476d 176 }
scarter1 0:020db18a476d 177 uint32_t outcomes_from_lengthT = ((uint32_t) (*(inbuffer + offset)));
scarter1 0:020db18a476d 178 outcomes_from_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
scarter1 0:020db18a476d 179 outcomes_from_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
scarter1 0:020db18a476d 180 outcomes_from_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
scarter1 0:020db18a476d 181 offset += sizeof(this->outcomes_from_length);
scarter1 0:020db18a476d 182 if(outcomes_from_lengthT > outcomes_from_length)
scarter1 0:020db18a476d 183 this->outcomes_from = (char**)realloc(this->outcomes_from, outcomes_from_lengthT * sizeof(char*));
scarter1 0:020db18a476d 184 outcomes_from_length = outcomes_from_lengthT;
scarter1 0:020db18a476d 185 for( uint32_t i = 0; i < outcomes_from_length; i++){
scarter1 0:020db18a476d 186 uint32_t length_st_outcomes_from;
scarter1 0:020db18a476d 187 arrToVar(length_st_outcomes_from, (inbuffer + offset));
scarter1 0:020db18a476d 188 offset += 4;
scarter1 0:020db18a476d 189 for(unsigned int k= offset; k< offset+length_st_outcomes_from; ++k){
scarter1 0:020db18a476d 190 inbuffer[k-1]=inbuffer[k];
scarter1 0:020db18a476d 191 }
scarter1 0:020db18a476d 192 inbuffer[offset+length_st_outcomes_from-1]=0;
scarter1 0:020db18a476d 193 this->st_outcomes_from = (char *)(inbuffer + offset-1);
scarter1 0:020db18a476d 194 offset += length_st_outcomes_from;
scarter1 0:020db18a476d 195 memcpy( &(this->outcomes_from[i]), &(this->st_outcomes_from), sizeof(char*));
scarter1 0:020db18a476d 196 }
scarter1 0:020db18a476d 197 uint32_t outcomes_to_lengthT = ((uint32_t) (*(inbuffer + offset)));
scarter1 0:020db18a476d 198 outcomes_to_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
scarter1 0:020db18a476d 199 outcomes_to_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
scarter1 0:020db18a476d 200 outcomes_to_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
scarter1 0:020db18a476d 201 offset += sizeof(this->outcomes_to_length);
scarter1 0:020db18a476d 202 if(outcomes_to_lengthT > outcomes_to_length)
scarter1 0:020db18a476d 203 this->outcomes_to = (char**)realloc(this->outcomes_to, outcomes_to_lengthT * sizeof(char*));
scarter1 0:020db18a476d 204 outcomes_to_length = outcomes_to_lengthT;
scarter1 0:020db18a476d 205 for( uint32_t i = 0; i < outcomes_to_length; i++){
scarter1 0:020db18a476d 206 uint32_t length_st_outcomes_to;
scarter1 0:020db18a476d 207 arrToVar(length_st_outcomes_to, (inbuffer + offset));
scarter1 0:020db18a476d 208 offset += 4;
scarter1 0:020db18a476d 209 for(unsigned int k= offset; k< offset+length_st_outcomes_to; ++k){
scarter1 0:020db18a476d 210 inbuffer[k-1]=inbuffer[k];
scarter1 0:020db18a476d 211 }
scarter1 0:020db18a476d 212 inbuffer[offset+length_st_outcomes_to-1]=0;
scarter1 0:020db18a476d 213 this->st_outcomes_to = (char *)(inbuffer + offset-1);
scarter1 0:020db18a476d 214 offset += length_st_outcomes_to;
scarter1 0:020db18a476d 215 memcpy( &(this->outcomes_to[i]), &(this->st_outcomes_to), sizeof(char*));
scarter1 0:020db18a476d 216 }
scarter1 0:020db18a476d 217 uint32_t container_outcomes_lengthT = ((uint32_t) (*(inbuffer + offset)));
scarter1 0:020db18a476d 218 container_outcomes_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
scarter1 0:020db18a476d 219 container_outcomes_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
scarter1 0:020db18a476d 220 container_outcomes_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
scarter1 0:020db18a476d 221 offset += sizeof(this->container_outcomes_length);
scarter1 0:020db18a476d 222 if(container_outcomes_lengthT > container_outcomes_length)
scarter1 0:020db18a476d 223 this->container_outcomes = (char**)realloc(this->container_outcomes, container_outcomes_lengthT * sizeof(char*));
scarter1 0:020db18a476d 224 container_outcomes_length = container_outcomes_lengthT;
scarter1 0:020db18a476d 225 for( uint32_t i = 0; i < container_outcomes_length; i++){
scarter1 0:020db18a476d 226 uint32_t length_st_container_outcomes;
scarter1 0:020db18a476d 227 arrToVar(length_st_container_outcomes, (inbuffer + offset));
scarter1 0:020db18a476d 228 offset += 4;
scarter1 0:020db18a476d 229 for(unsigned int k= offset; k< offset+length_st_container_outcomes; ++k){
scarter1 0:020db18a476d 230 inbuffer[k-1]=inbuffer[k];
scarter1 0:020db18a476d 231 }
scarter1 0:020db18a476d 232 inbuffer[offset+length_st_container_outcomes-1]=0;
scarter1 0:020db18a476d 233 this->st_container_outcomes = (char *)(inbuffer + offset-1);
scarter1 0:020db18a476d 234 offset += length_st_container_outcomes;
scarter1 0:020db18a476d 235 memcpy( &(this->container_outcomes[i]), &(this->st_container_outcomes), sizeof(char*));
scarter1 0:020db18a476d 236 }
scarter1 0:020db18a476d 237 return offset;
scarter1 0:020db18a476d 238 }
scarter1 0:020db18a476d 239
scarter1 0:020db18a476d 240 const char * getType(){ return "smach_msgs/SmachContainerStructure"; };
scarter1 0:020db18a476d 241 const char * getMD5(){ return "3d3d1e0d0f99779ee9e58101a5dcf7ea"; };
scarter1 0:020db18a476d 242
scarter1 0:020db18a476d 243 };
scarter1 0:020db18a476d 244
scarter1 0:020db18a476d 245 }
scarter1 0:020db18a476d 246 #endif