Gary Servin / ros_lib_indigo

Dependencies:   BufferedSerial

Dependents:   rosserial_mbed_hello_world_publisher rtos_base_control rosserial_mbed_F64MA ROS-RTOS ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SetModelConfiguration.h Source File

SetModelConfiguration.h

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       double st_joint_positions;
00023       double * joint_positions;
00024 
00025     SetModelConfigurationRequest():
00026       model_name(""),
00027       urdf_param_name(""),
00028       joint_names_length(0), joint_names(NULL),
00029       joint_positions_length(0), joint_positions(NULL)
00030     {
00031     }
00032 
00033     virtual int serialize(unsigned char *outbuffer) const
00034     {
00035       int offset = 0;
00036       uint32_t length_model_name = strlen(this->model_name);
00037       memcpy(outbuffer + offset, &length_model_name, sizeof(uint32_t));
00038       offset += 4;
00039       memcpy(outbuffer + offset, this->model_name, length_model_name);
00040       offset += length_model_name;
00041       uint32_t length_urdf_param_name = strlen(this->urdf_param_name);
00042       memcpy(outbuffer + offset, &length_urdf_param_name, sizeof(uint32_t));
00043       offset += 4;
00044       memcpy(outbuffer + offset, this->urdf_param_name, length_urdf_param_name);
00045       offset += length_urdf_param_name;
00046       *(outbuffer + offset++) = joint_names_length;
00047       *(outbuffer + offset++) = 0;
00048       *(outbuffer + offset++) = 0;
00049       *(outbuffer + offset++) = 0;
00050       for( uint8_t i = 0; i < joint_names_length; i++){
00051       uint32_t length_joint_namesi = strlen(this->joint_names[i]);
00052       memcpy(outbuffer + offset, &length_joint_namesi, sizeof(uint32_t));
00053       offset += 4;
00054       memcpy(outbuffer + offset, this->joint_names[i], length_joint_namesi);
00055       offset += length_joint_namesi;
00056       }
00057       *(outbuffer + offset++) = joint_positions_length;
00058       *(outbuffer + offset++) = 0;
00059       *(outbuffer + offset++) = 0;
00060       *(outbuffer + offset++) = 0;
00061       for( uint8_t i = 0; i < joint_positions_length; i++){
00062       union {
00063         double real;
00064         uint64_t base;
00065       } u_joint_positionsi;
00066       u_joint_positionsi.real = this->joint_positions[i];
00067       *(outbuffer + offset + 0) = (u_joint_positionsi.base >> (8 * 0)) & 0xFF;
00068       *(outbuffer + offset + 1) = (u_joint_positionsi.base >> (8 * 1)) & 0xFF;
00069       *(outbuffer + offset + 2) = (u_joint_positionsi.base >> (8 * 2)) & 0xFF;
00070       *(outbuffer + offset + 3) = (u_joint_positionsi.base >> (8 * 3)) & 0xFF;
00071       *(outbuffer + offset + 4) = (u_joint_positionsi.base >> (8 * 4)) & 0xFF;
00072       *(outbuffer + offset + 5) = (u_joint_positionsi.base >> (8 * 5)) & 0xFF;
00073       *(outbuffer + offset + 6) = (u_joint_positionsi.base >> (8 * 6)) & 0xFF;
00074       *(outbuffer + offset + 7) = (u_joint_positionsi.base >> (8 * 7)) & 0xFF;
00075       offset += sizeof(this->joint_positions[i]);
00076       }
00077       return offset;
00078     }
00079 
00080     virtual int deserialize(unsigned char *inbuffer)
00081     {
00082       int offset = 0;
00083       uint32_t length_model_name;
00084       memcpy(&length_model_name, (inbuffer + offset), sizeof(uint32_t));
00085       offset += 4;
00086       for(unsigned int k= offset; k< offset+length_model_name; ++k){
00087           inbuffer[k-1]=inbuffer[k];
00088       }
00089       inbuffer[offset+length_model_name-1]=0;
00090       this->model_name = (char *)(inbuffer + offset-1);
00091       offset += length_model_name;
00092       uint32_t length_urdf_param_name;
00093       memcpy(&length_urdf_param_name, (inbuffer + offset), sizeof(uint32_t));
00094       offset += 4;
00095       for(unsigned int k= offset; k< offset+length_urdf_param_name; ++k){
00096           inbuffer[k-1]=inbuffer[k];
00097       }
00098       inbuffer[offset+length_urdf_param_name-1]=0;
00099       this->urdf_param_name = (char *)(inbuffer + offset-1);
00100       offset += length_urdf_param_name;
00101       uint8_t joint_names_lengthT = *(inbuffer + offset++);
00102       if(joint_names_lengthT > joint_names_length)
00103         this->joint_names = (char**)realloc(this->joint_names, joint_names_lengthT * sizeof(char*));
00104       offset += 3;
00105       joint_names_length = joint_names_lengthT;
00106       for( uint8_t i = 0; i < joint_names_length; i++){
00107       uint32_t length_st_joint_names;
00108       memcpy(&length_st_joint_names, (inbuffer + offset), sizeof(uint32_t));
00109       offset += 4;
00110       for(unsigned int k= offset; k< offset+length_st_joint_names; ++k){
00111           inbuffer[k-1]=inbuffer[k];
00112       }
00113       inbuffer[offset+length_st_joint_names-1]=0;
00114       this->st_joint_names = (char *)(inbuffer + offset-1);
00115       offset += length_st_joint_names;
00116         memcpy( &(this->joint_names[i]), &(this->st_joint_names), sizeof(char*));
00117       }
00118       uint8_t joint_positions_lengthT = *(inbuffer + offset++);
00119       if(joint_positions_lengthT > joint_positions_length)
00120         this->joint_positions = (double*)realloc(this->joint_positions, joint_positions_lengthT * sizeof(double));
00121       offset += 3;
00122       joint_positions_length = joint_positions_lengthT;
00123       for( uint8_t i = 0; i < joint_positions_length; i++){
00124       union {
00125         double real;
00126         uint64_t base;
00127       } u_st_joint_positions;
00128       u_st_joint_positions.base = 0;
00129       u_st_joint_positions.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
00130       u_st_joint_positions.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
00131       u_st_joint_positions.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
00132       u_st_joint_positions.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
00133       u_st_joint_positions.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
00134       u_st_joint_positions.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
00135       u_st_joint_positions.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
00136       u_st_joint_positions.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
00137       this->st_joint_positions = u_st_joint_positions.real;
00138       offset += sizeof(this->st_joint_positions);
00139         memcpy( &(this->joint_positions[i]), &(this->st_joint_positions), sizeof(double));
00140       }
00141      return offset;
00142     }
00143 
00144     const char * getType(){ return SETMODELCONFIGURATION; };
00145     const char * getMD5(){ return "160eae60f51fabff255480c70afa289f"; };
00146 
00147   };
00148 
00149   class SetModelConfigurationResponse : public ros::Msg
00150   {
00151     public:
00152       bool success;
00153       const char* status_message;
00154 
00155     SetModelConfigurationResponse():
00156       success(0),
00157       status_message("")
00158     {
00159     }
00160 
00161     virtual int serialize(unsigned char *outbuffer) const
00162     {
00163       int offset = 0;
00164       union {
00165         bool real;
00166         uint8_t base;
00167       } u_success;
00168       u_success.real = this->success;
00169       *(outbuffer + offset + 0) = (u_success.base >> (8 * 0)) & 0xFF;
00170       offset += sizeof(this->success);
00171       uint32_t length_status_message = strlen(this->status_message);
00172       memcpy(outbuffer + offset, &length_status_message, sizeof(uint32_t));
00173       offset += 4;
00174       memcpy(outbuffer + offset, this->status_message, length_status_message);
00175       offset += length_status_message;
00176       return offset;
00177     }
00178 
00179     virtual int deserialize(unsigned char *inbuffer)
00180     {
00181       int offset = 0;
00182       union {
00183         bool real;
00184         uint8_t base;
00185       } u_success;
00186       u_success.base = 0;
00187       u_success.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
00188       this->success = u_success.real;
00189       offset += sizeof(this->success);
00190       uint32_t length_status_message;
00191       memcpy(&length_status_message, (inbuffer + offset), sizeof(uint32_t));
00192       offset += 4;
00193       for(unsigned int k= offset; k< offset+length_status_message; ++k){
00194           inbuffer[k-1]=inbuffer[k];
00195       }
00196       inbuffer[offset+length_status_message-1]=0;
00197       this->status_message = (char *)(inbuffer + offset-1);
00198       offset += length_status_message;
00199      return offset;
00200     }
00201 
00202     const char * getType(){ return SETMODELCONFIGURATION; };
00203     const char * getMD5(){ return "2ec6f3eff0161f4257b808b12bc830c2"; };
00204 
00205   };
00206 
00207   class SetModelConfiguration {
00208     public:
00209     typedef SetModelConfigurationRequest Request;
00210     typedef SetModelConfigurationResponse Response;
00211   };
00212 
00213 }
00214 #endif