SetModelConfiguration.h
Go to the documentation of this file.
00001 #ifndef _ROS_SERVICE_SetModelConfiguration_h
00002 #define _ROS_SERVICE_SetModelConfiguration_h
00003 #include <stdint.h>
00004 #include <string.h>
00005 #include <stdlib.h>
00006 #include "ros/msg.h"
00007 
00008 namespace gazebo_msgs
00009 {
00010 
00011 static const char SETMODELCONFIGURATION[] = "gazebo_msgs/SetModelConfiguration";
00012 
00013   class SetModelConfigurationRequest : public ros::Msg
00014   {
00015     public:
00016       const char* model_name;
00017       const char* urdf_param_name;
00018       uint8_t joint_names_length;
00019       char* st_joint_names;
00020       char* * joint_names;
00021       uint8_t joint_positions_length;
00022       float st_joint_positions;
00023       float * joint_positions;
00024 
00025     virtual int serialize(unsigned char *outbuffer) const
00026     {
00027       int offset = 0;
00028       uint32_t length_model_name = strlen(this->model_name);
00029       memcpy(outbuffer + offset, &length_model_name, sizeof(uint32_t));
00030       offset += 4;
00031       memcpy(outbuffer + offset, this->model_name, length_model_name);
00032       offset += length_model_name;
00033       uint32_t length_urdf_param_name = strlen(this->urdf_param_name);
00034       memcpy(outbuffer + offset, &length_urdf_param_name, sizeof(uint32_t));
00035       offset += 4;
00036       memcpy(outbuffer + offset, this->urdf_param_name, length_urdf_param_name);
00037       offset += length_urdf_param_name;
00038       *(outbuffer + offset++) = joint_names_length;
00039       *(outbuffer + offset++) = 0;
00040       *(outbuffer + offset++) = 0;
00041       *(outbuffer + offset++) = 0;
00042       for( uint8_t i = 0; i < joint_names_length; i++){
00043       uint32_t length_joint_namesi = strlen(this->joint_names[i]);
00044       memcpy(outbuffer + offset, &length_joint_namesi, sizeof(uint32_t));
00045       offset += 4;
00046       memcpy(outbuffer + offset, this->joint_names[i], length_joint_namesi);
00047       offset += length_joint_namesi;
00048       }
00049       *(outbuffer + offset++) = joint_positions_length;
00050       *(outbuffer + offset++) = 0;
00051       *(outbuffer + offset++) = 0;
00052       *(outbuffer + offset++) = 0;
00053       for( uint8_t i = 0; i < joint_positions_length; i++){
00054       int32_t * val_joint_positionsi = (int32_t *) &(this->joint_positions[i]);
00055       int32_t exp_joint_positionsi = (((*val_joint_positionsi)>>23)&255);
00056       if(exp_joint_positionsi != 0)
00057         exp_joint_positionsi += 1023-127;
00058       int32_t sig_joint_positionsi = *val_joint_positionsi;
00059       *(outbuffer + offset++) = 0;
00060       *(outbuffer + offset++) = 0;
00061       *(outbuffer + offset++) = 0;
00062       *(outbuffer + offset++) = (sig_joint_positionsi<<5) & 0xff;
00063       *(outbuffer + offset++) = (sig_joint_positionsi>>3) & 0xff;
00064       *(outbuffer + offset++) = (sig_joint_positionsi>>11) & 0xff;
00065       *(outbuffer + offset++) = ((exp_joint_positionsi<<4) & 0xF0) | ((sig_joint_positionsi>>19)&0x0F);
00066       *(outbuffer + offset++) = (exp_joint_positionsi>>4) & 0x7F;
00067       if(this->joint_positions[i] < 0) *(outbuffer + offset -1) |= 0x80;
00068       }
00069       return offset;
00070     }
00071 
00072     virtual int deserialize(unsigned char *inbuffer)
00073     {
00074       int offset = 0;
00075       uint32_t length_model_name;
00076       memcpy(&length_model_name, (inbuffer + offset), sizeof(uint32_t));
00077       offset += 4;
00078       for(unsigned int k= offset; k< offset+length_model_name; ++k){
00079           inbuffer[k-1]=inbuffer[k];
00080       }
00081       inbuffer[offset+length_model_name-1]=0;
00082       this->model_name = (char *)(inbuffer + offset-1);
00083       offset += length_model_name;
00084       uint32_t length_urdf_param_name;
00085       memcpy(&length_urdf_param_name, (inbuffer + offset), sizeof(uint32_t));
00086       offset += 4;
00087       for(unsigned int k= offset; k< offset+length_urdf_param_name; ++k){
00088           inbuffer[k-1]=inbuffer[k];
00089       }
00090       inbuffer[offset+length_urdf_param_name-1]=0;
00091       this->urdf_param_name = (char *)(inbuffer + offset-1);
00092       offset += length_urdf_param_name;
00093       uint8_t joint_names_lengthT = *(inbuffer + offset++);
00094       if(joint_names_lengthT > joint_names_length)
00095         this->joint_names = (char**)realloc(this->joint_names, joint_names_lengthT * sizeof(char*));
00096       offset += 3;
00097       joint_names_length = joint_names_lengthT;
00098       for( uint8_t i = 0; i < joint_names_length; i++){
00099       uint32_t length_st_joint_names;
00100       memcpy(&length_st_joint_names, (inbuffer + offset), sizeof(uint32_t));
00101       offset += 4;
00102       for(unsigned int k= offset; k< offset+length_st_joint_names; ++k){
00103           inbuffer[k-1]=inbuffer[k];
00104       }
00105       inbuffer[offset+length_st_joint_names-1]=0;
00106       this->st_joint_names = (char *)(inbuffer + offset-1);
00107       offset += length_st_joint_names;
00108         memcpy( &(this->joint_names[i]), &(this->st_joint_names), sizeof(char*));
00109       }
00110       uint8_t joint_positions_lengthT = *(inbuffer + offset++);
00111       if(joint_positions_lengthT > joint_positions_length)
00112         this->joint_positions = (float*)realloc(this->joint_positions, joint_positions_lengthT * sizeof(float));
00113       offset += 3;
00114       joint_positions_length = joint_positions_lengthT;
00115       for( uint8_t i = 0; i < joint_positions_length; i++){
00116       uint32_t * val_st_joint_positions = (uint32_t*) &(this->st_joint_positions);
00117       offset += 3;
00118       *val_st_joint_positions = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07);
00119       *val_st_joint_positions |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3;
00120       *val_st_joint_positions |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11;
00121       *val_st_joint_positions |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19;
00122       uint32_t exp_st_joint_positions = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4;
00123       exp_st_joint_positions |= ((uint32_t)(*(inbuffer + offset)) & 0x7f)<<4;
00124       if(exp_st_joint_positions !=0)
00125         *val_st_joint_positions |= ((exp_st_joint_positions)-1023+127)<<23;
00126       if( ((*(inbuffer+offset++)) & 0x80) > 0) this->st_joint_positions = -this->st_joint_positions;
00127         memcpy( &(this->joint_positions[i]), &(this->st_joint_positions), sizeof(float));
00128       }
00129      return offset;
00130     }
00131 
00132     const char * getType(){ return SETMODELCONFIGURATION; };
00133     const char * getMD5(){ return "160eae60f51fabff255480c70afa289f"; };
00134 
00135   };
00136 
00137   class SetModelConfigurationResponse : public ros::Msg
00138   {
00139     public:
00140       bool success;
00141       const char* status_message;
00142 
00143     virtual int serialize(unsigned char *outbuffer) const
00144     {
00145       int offset = 0;
00146       union {
00147         bool real;
00148         uint8_t base;
00149       } u_success;
00150       u_success.real = this->success;
00151       *(outbuffer + offset + 0) = (u_success.base >> (8 * 0)) & 0xFF;
00152       offset += sizeof(this->success);
00153       uint32_t length_status_message = strlen(this->status_message);
00154       memcpy(outbuffer + offset, &length_status_message, sizeof(uint32_t));
00155       offset += 4;
00156       memcpy(outbuffer + offset, this->status_message, length_status_message);
00157       offset += length_status_message;
00158       return offset;
00159     }
00160 
00161     virtual int deserialize(unsigned char *inbuffer)
00162     {
00163       int offset = 0;
00164       union {
00165         bool real;
00166         uint8_t base;
00167       } u_success;
00168       u_success.base = 0;
00169       u_success.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
00170       this->success = u_success.real;
00171       offset += sizeof(this->success);
00172       uint32_t length_status_message;
00173       memcpy(&length_status_message, (inbuffer + offset), sizeof(uint32_t));
00174       offset += 4;
00175       for(unsigned int k= offset; k< offset+length_status_message; ++k){
00176           inbuffer[k-1]=inbuffer[k];
00177       }
00178       inbuffer[offset+length_status_message-1]=0;
00179       this->status_message = (char *)(inbuffer + offset-1);
00180       offset += length_status_message;
00181      return offset;
00182     }
00183 
00184     const char * getType(){ return SETMODELCONFIGURATION; };
00185     const char * getMD5(){ return "2ec6f3eff0161f4257b808b12bc830c2"; };
00186 
00187   };
00188 
00189   class SetModelConfiguration {
00190     public:
00191     typedef SetModelConfigurationRequest Request;
00192     typedef SetModelConfigurationResponse Response;
00193   };
00194 
00195 }
00196 #endif


ric_mc
Author(s): RoboTiCan
autogenerated on Thu Aug 27 2015 14:39:50