added 1 custom message

Dependencies:   BufferedSerial

Fork of ros_lib_kinetic by Gary Servin

Committer:
randalthor
Date:
Fri May 19 08:59:12 2017 +0000
Revision:
2:af816ffd33df
Parent:
0:9e9b7db60fd5
custom message mobile robot added for ITU cyber physical lab

Who changed what in which revision?

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