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