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_SetLightProperties_h
scarter1 0:020db18a476d 2 #define _ROS_SERVICE_SetLightProperties_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 #include "std_msgs/ColorRGBA.h"
scarter1 0:020db18a476d 8
scarter1 0:020db18a476d 9 namespace gazebo_msgs
scarter1 0:020db18a476d 10 {
scarter1 0:020db18a476d 11
scarter1 0:020db18a476d 12 static const char SETLIGHTPROPERTIES[] = "gazebo_msgs/SetLightProperties";
scarter1 0:020db18a476d 13
scarter1 0:020db18a476d 14 class SetLightPropertiesRequest : public ros::Msg
scarter1 0:020db18a476d 15 {
scarter1 0:020db18a476d 16 public:
scarter1 0:020db18a476d 17 typedef const char* _light_name_type;
scarter1 0:020db18a476d 18 _light_name_type light_name;
scarter1 0:020db18a476d 19 typedef std_msgs::ColorRGBA _diffuse_type;
scarter1 0:020db18a476d 20 _diffuse_type diffuse;
scarter1 0:020db18a476d 21 typedef double _attenuation_constant_type;
scarter1 0:020db18a476d 22 _attenuation_constant_type attenuation_constant;
scarter1 0:020db18a476d 23 typedef double _attenuation_linear_type;
scarter1 0:020db18a476d 24 _attenuation_linear_type attenuation_linear;
scarter1 0:020db18a476d 25 typedef double _attenuation_quadratic_type;
scarter1 0:020db18a476d 26 _attenuation_quadratic_type attenuation_quadratic;
scarter1 0:020db18a476d 27
scarter1 0:020db18a476d 28 SetLightPropertiesRequest():
scarter1 0:020db18a476d 29 light_name(""),
scarter1 0:020db18a476d 30 diffuse(),
scarter1 0:020db18a476d 31 attenuation_constant(0),
scarter1 0:020db18a476d 32 attenuation_linear(0),
scarter1 0:020db18a476d 33 attenuation_quadratic(0)
scarter1 0:020db18a476d 34 {
scarter1 0:020db18a476d 35 }
scarter1 0:020db18a476d 36
scarter1 0:020db18a476d 37 virtual int serialize(unsigned char *outbuffer) const
scarter1 0:020db18a476d 38 {
scarter1 0:020db18a476d 39 int offset = 0;
scarter1 0:020db18a476d 40 uint32_t length_light_name = strlen(this->light_name);
scarter1 0:020db18a476d 41 varToArr(outbuffer + offset, length_light_name);
scarter1 0:020db18a476d 42 offset += 4;
scarter1 0:020db18a476d 43 memcpy(outbuffer + offset, this->light_name, length_light_name);
scarter1 0:020db18a476d 44 offset += length_light_name;
scarter1 0:020db18a476d 45 offset += this->diffuse.serialize(outbuffer + offset);
scarter1 0:020db18a476d 46 union {
scarter1 0:020db18a476d 47 double real;
scarter1 0:020db18a476d 48 uint64_t base;
scarter1 0:020db18a476d 49 } u_attenuation_constant;
scarter1 0:020db18a476d 50 u_attenuation_constant.real = this->attenuation_constant;
scarter1 0:020db18a476d 51 *(outbuffer + offset + 0) = (u_attenuation_constant.base >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 52 *(outbuffer + offset + 1) = (u_attenuation_constant.base >> (8 * 1)) & 0xFF;
scarter1 0:020db18a476d 53 *(outbuffer + offset + 2) = (u_attenuation_constant.base >> (8 * 2)) & 0xFF;
scarter1 0:020db18a476d 54 *(outbuffer + offset + 3) = (u_attenuation_constant.base >> (8 * 3)) & 0xFF;
scarter1 0:020db18a476d 55 *(outbuffer + offset + 4) = (u_attenuation_constant.base >> (8 * 4)) & 0xFF;
scarter1 0:020db18a476d 56 *(outbuffer + offset + 5) = (u_attenuation_constant.base >> (8 * 5)) & 0xFF;
scarter1 0:020db18a476d 57 *(outbuffer + offset + 6) = (u_attenuation_constant.base >> (8 * 6)) & 0xFF;
scarter1 0:020db18a476d 58 *(outbuffer + offset + 7) = (u_attenuation_constant.base >> (8 * 7)) & 0xFF;
scarter1 0:020db18a476d 59 offset += sizeof(this->attenuation_constant);
scarter1 0:020db18a476d 60 union {
scarter1 0:020db18a476d 61 double real;
scarter1 0:020db18a476d 62 uint64_t base;
scarter1 0:020db18a476d 63 } u_attenuation_linear;
scarter1 0:020db18a476d 64 u_attenuation_linear.real = this->attenuation_linear;
scarter1 0:020db18a476d 65 *(outbuffer + offset + 0) = (u_attenuation_linear.base >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 66 *(outbuffer + offset + 1) = (u_attenuation_linear.base >> (8 * 1)) & 0xFF;
scarter1 0:020db18a476d 67 *(outbuffer + offset + 2) = (u_attenuation_linear.base >> (8 * 2)) & 0xFF;
scarter1 0:020db18a476d 68 *(outbuffer + offset + 3) = (u_attenuation_linear.base >> (8 * 3)) & 0xFF;
scarter1 0:020db18a476d 69 *(outbuffer + offset + 4) = (u_attenuation_linear.base >> (8 * 4)) & 0xFF;
scarter1 0:020db18a476d 70 *(outbuffer + offset + 5) = (u_attenuation_linear.base >> (8 * 5)) & 0xFF;
scarter1 0:020db18a476d 71 *(outbuffer + offset + 6) = (u_attenuation_linear.base >> (8 * 6)) & 0xFF;
scarter1 0:020db18a476d 72 *(outbuffer + offset + 7) = (u_attenuation_linear.base >> (8 * 7)) & 0xFF;
scarter1 0:020db18a476d 73 offset += sizeof(this->attenuation_linear);
scarter1 0:020db18a476d 74 union {
scarter1 0:020db18a476d 75 double real;
scarter1 0:020db18a476d 76 uint64_t base;
scarter1 0:020db18a476d 77 } u_attenuation_quadratic;
scarter1 0:020db18a476d 78 u_attenuation_quadratic.real = this->attenuation_quadratic;
scarter1 0:020db18a476d 79 *(outbuffer + offset + 0) = (u_attenuation_quadratic.base >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 80 *(outbuffer + offset + 1) = (u_attenuation_quadratic.base >> (8 * 1)) & 0xFF;
scarter1 0:020db18a476d 81 *(outbuffer + offset + 2) = (u_attenuation_quadratic.base >> (8 * 2)) & 0xFF;
scarter1 0:020db18a476d 82 *(outbuffer + offset + 3) = (u_attenuation_quadratic.base >> (8 * 3)) & 0xFF;
scarter1 0:020db18a476d 83 *(outbuffer + offset + 4) = (u_attenuation_quadratic.base >> (8 * 4)) & 0xFF;
scarter1 0:020db18a476d 84 *(outbuffer + offset + 5) = (u_attenuation_quadratic.base >> (8 * 5)) & 0xFF;
scarter1 0:020db18a476d 85 *(outbuffer + offset + 6) = (u_attenuation_quadratic.base >> (8 * 6)) & 0xFF;
scarter1 0:020db18a476d 86 *(outbuffer + offset + 7) = (u_attenuation_quadratic.base >> (8 * 7)) & 0xFF;
scarter1 0:020db18a476d 87 offset += sizeof(this->attenuation_quadratic);
scarter1 0:020db18a476d 88 return offset;
scarter1 0:020db18a476d 89 }
scarter1 0:020db18a476d 90
scarter1 0:020db18a476d 91 virtual int deserialize(unsigned char *inbuffer)
scarter1 0:020db18a476d 92 {
scarter1 0:020db18a476d 93 int offset = 0;
scarter1 0:020db18a476d 94 uint32_t length_light_name;
scarter1 0:020db18a476d 95 arrToVar(length_light_name, (inbuffer + offset));
scarter1 0:020db18a476d 96 offset += 4;
scarter1 0:020db18a476d 97 for(unsigned int k= offset; k< offset+length_light_name; ++k){
scarter1 0:020db18a476d 98 inbuffer[k-1]=inbuffer[k];
scarter1 0:020db18a476d 99 }
scarter1 0:020db18a476d 100 inbuffer[offset+length_light_name-1]=0;
scarter1 0:020db18a476d 101 this->light_name = (char *)(inbuffer + offset-1);
scarter1 0:020db18a476d 102 offset += length_light_name;
scarter1 0:020db18a476d 103 offset += this->diffuse.deserialize(inbuffer + offset);
scarter1 0:020db18a476d 104 union {
scarter1 0:020db18a476d 105 double real;
scarter1 0:020db18a476d 106 uint64_t base;
scarter1 0:020db18a476d 107 } u_attenuation_constant;
scarter1 0:020db18a476d 108 u_attenuation_constant.base = 0;
scarter1 0:020db18a476d 109 u_attenuation_constant.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
scarter1 0:020db18a476d 110 u_attenuation_constant.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
scarter1 0:020db18a476d 111 u_attenuation_constant.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
scarter1 0:020db18a476d 112 u_attenuation_constant.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
scarter1 0:020db18a476d 113 u_attenuation_constant.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
scarter1 0:020db18a476d 114 u_attenuation_constant.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
scarter1 0:020db18a476d 115 u_attenuation_constant.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
scarter1 0:020db18a476d 116 u_attenuation_constant.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
scarter1 0:020db18a476d 117 this->attenuation_constant = u_attenuation_constant.real;
scarter1 0:020db18a476d 118 offset += sizeof(this->attenuation_constant);
scarter1 0:020db18a476d 119 union {
scarter1 0:020db18a476d 120 double real;
scarter1 0:020db18a476d 121 uint64_t base;
scarter1 0:020db18a476d 122 } u_attenuation_linear;
scarter1 0:020db18a476d 123 u_attenuation_linear.base = 0;
scarter1 0:020db18a476d 124 u_attenuation_linear.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
scarter1 0:020db18a476d 125 u_attenuation_linear.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
scarter1 0:020db18a476d 126 u_attenuation_linear.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
scarter1 0:020db18a476d 127 u_attenuation_linear.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
scarter1 0:020db18a476d 128 u_attenuation_linear.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
scarter1 0:020db18a476d 129 u_attenuation_linear.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
scarter1 0:020db18a476d 130 u_attenuation_linear.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
scarter1 0:020db18a476d 131 u_attenuation_linear.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
scarter1 0:020db18a476d 132 this->attenuation_linear = u_attenuation_linear.real;
scarter1 0:020db18a476d 133 offset += sizeof(this->attenuation_linear);
scarter1 0:020db18a476d 134 union {
scarter1 0:020db18a476d 135 double real;
scarter1 0:020db18a476d 136 uint64_t base;
scarter1 0:020db18a476d 137 } u_attenuation_quadratic;
scarter1 0:020db18a476d 138 u_attenuation_quadratic.base = 0;
scarter1 0:020db18a476d 139 u_attenuation_quadratic.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
scarter1 0:020db18a476d 140 u_attenuation_quadratic.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
scarter1 0:020db18a476d 141 u_attenuation_quadratic.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
scarter1 0:020db18a476d 142 u_attenuation_quadratic.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
scarter1 0:020db18a476d 143 u_attenuation_quadratic.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
scarter1 0:020db18a476d 144 u_attenuation_quadratic.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
scarter1 0:020db18a476d 145 u_attenuation_quadratic.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
scarter1 0:020db18a476d 146 u_attenuation_quadratic.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
scarter1 0:020db18a476d 147 this->attenuation_quadratic = u_attenuation_quadratic.real;
scarter1 0:020db18a476d 148 offset += sizeof(this->attenuation_quadratic);
scarter1 0:020db18a476d 149 return offset;
scarter1 0:020db18a476d 150 }
scarter1 0:020db18a476d 151
scarter1 0:020db18a476d 152 const char * getType(){ return SETLIGHTPROPERTIES; };
scarter1 0:020db18a476d 153 const char * getMD5(){ return "73ad1ac5e9e312ddf7c74f38ad843f34"; };
scarter1 0:020db18a476d 154
scarter1 0:020db18a476d 155 };
scarter1 0:020db18a476d 156
scarter1 0:020db18a476d 157 class SetLightPropertiesResponse : public ros::Msg
scarter1 0:020db18a476d 158 {
scarter1 0:020db18a476d 159 public:
scarter1 0:020db18a476d 160 typedef bool _success_type;
scarter1 0:020db18a476d 161 _success_type success;
scarter1 0:020db18a476d 162 typedef const char* _status_message_type;
scarter1 0:020db18a476d 163 _status_message_type status_message;
scarter1 0:020db18a476d 164
scarter1 0:020db18a476d 165 SetLightPropertiesResponse():
scarter1 0:020db18a476d 166 success(0),
scarter1 0:020db18a476d 167 status_message("")
scarter1 0:020db18a476d 168 {
scarter1 0:020db18a476d 169 }
scarter1 0:020db18a476d 170
scarter1 0:020db18a476d 171 virtual int serialize(unsigned char *outbuffer) const
scarter1 0:020db18a476d 172 {
scarter1 0:020db18a476d 173 int offset = 0;
scarter1 0:020db18a476d 174 union {
scarter1 0:020db18a476d 175 bool real;
scarter1 0:020db18a476d 176 uint8_t base;
scarter1 0:020db18a476d 177 } u_success;
scarter1 0:020db18a476d 178 u_success.real = this->success;
scarter1 0:020db18a476d 179 *(outbuffer + offset + 0) = (u_success.base >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 180 offset += sizeof(this->success);
scarter1 0:020db18a476d 181 uint32_t length_status_message = strlen(this->status_message);
scarter1 0:020db18a476d 182 varToArr(outbuffer + offset, length_status_message);
scarter1 0:020db18a476d 183 offset += 4;
scarter1 0:020db18a476d 184 memcpy(outbuffer + offset, this->status_message, length_status_message);
scarter1 0:020db18a476d 185 offset += length_status_message;
scarter1 0:020db18a476d 186 return offset;
scarter1 0:020db18a476d 187 }
scarter1 0:020db18a476d 188
scarter1 0:020db18a476d 189 virtual int deserialize(unsigned char *inbuffer)
scarter1 0:020db18a476d 190 {
scarter1 0:020db18a476d 191 int offset = 0;
scarter1 0:020db18a476d 192 union {
scarter1 0:020db18a476d 193 bool real;
scarter1 0:020db18a476d 194 uint8_t base;
scarter1 0:020db18a476d 195 } u_success;
scarter1 0:020db18a476d 196 u_success.base = 0;
scarter1 0:020db18a476d 197 u_success.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
scarter1 0:020db18a476d 198 this->success = u_success.real;
scarter1 0:020db18a476d 199 offset += sizeof(this->success);
scarter1 0:020db18a476d 200 uint32_t length_status_message;
scarter1 0:020db18a476d 201 arrToVar(length_status_message, (inbuffer + offset));
scarter1 0:020db18a476d 202 offset += 4;
scarter1 0:020db18a476d 203 for(unsigned int k= offset; k< offset+length_status_message; ++k){
scarter1 0:020db18a476d 204 inbuffer[k-1]=inbuffer[k];
scarter1 0:020db18a476d 205 }
scarter1 0:020db18a476d 206 inbuffer[offset+length_status_message-1]=0;
scarter1 0:020db18a476d 207 this->status_message = (char *)(inbuffer + offset-1);
scarter1 0:020db18a476d 208 offset += length_status_message;
scarter1 0:020db18a476d 209 return offset;
scarter1 0:020db18a476d 210 }
scarter1 0:020db18a476d 211
scarter1 0:020db18a476d 212 const char * getType(){ return SETLIGHTPROPERTIES; };
scarter1 0:020db18a476d 213 const char * getMD5(){ return "2ec6f3eff0161f4257b808b12bc830c2"; };
scarter1 0:020db18a476d 214
scarter1 0:020db18a476d 215 };
scarter1 0:020db18a476d 216
scarter1 0:020db18a476d 217 class SetLightProperties {
scarter1 0:020db18a476d 218 public:
scarter1 0:020db18a476d 219 typedef SetLightPropertiesRequest Request;
scarter1 0:020db18a476d 220 typedef SetLightPropertiesResponse Response;
scarter1 0:020db18a476d 221 };
scarter1 0:020db18a476d 222
scarter1 0:020db18a476d 223 }
scarter1 0:020db18a476d 224 #endif