Working towards recieving twists

Dependencies:   BufferedSerial

Fork of ros_lib_kinetic by Gary Servin

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ContactState.h Source File

ContactState.h

00001 #ifndef _ROS_gazebo_msgs_ContactState_h
00002 #define _ROS_gazebo_msgs_ContactState_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 #include "geometry_msgs/Wrench.h"
00009 #include "geometry_msgs/Vector3.h"
00010 
00011 namespace gazebo_msgs
00012 {
00013 
00014   class ContactState : public ros::Msg
00015   {
00016     public:
00017       typedef const char* _info_type;
00018       _info_type info;
00019       typedef const char* _collision1_name_type;
00020       _collision1_name_type collision1_name;
00021       typedef const char* _collision2_name_type;
00022       _collision2_name_type collision2_name;
00023       uint32_t wrenches_length;
00024       typedef geometry_msgs::Wrench _wrenches_type;
00025       _wrenches_type st_wrenches;
00026       _wrenches_type * wrenches;
00027       typedef geometry_msgs::Wrench _total_wrench_type;
00028       _total_wrench_type total_wrench;
00029       uint32_t contact_positions_length;
00030       typedef geometry_msgs::Vector3 _contact_positions_type;
00031       _contact_positions_type st_contact_positions;
00032       _contact_positions_type * contact_positions;
00033       uint32_t contact_normals_length;
00034       typedef geometry_msgs::Vector3 _contact_normals_type;
00035       _contact_normals_type st_contact_normals;
00036       _contact_normals_type * contact_normals;
00037       uint32_t depths_length;
00038       typedef double _depths_type;
00039       _depths_type st_depths;
00040       _depths_type * depths;
00041 
00042     ContactState():
00043       info(""),
00044       collision1_name(""),
00045       collision2_name(""),
00046       wrenches_length(0), wrenches(NULL),
00047       total_wrench(),
00048       contact_positions_length(0), contact_positions(NULL),
00049       contact_normals_length(0), contact_normals(NULL),
00050       depths_length(0), depths(NULL)
00051     {
00052     }
00053 
00054     virtual int serialize(unsigned char *outbuffer) const
00055     {
00056       int offset = 0;
00057       uint32_t length_info = strlen(this->info);
00058       varToArr(outbuffer + offset, length_info);
00059       offset += 4;
00060       memcpy(outbuffer + offset, this->info, length_info);
00061       offset += length_info;
00062       uint32_t length_collision1_name = strlen(this->collision1_name);
00063       varToArr(outbuffer + offset, length_collision1_name);
00064       offset += 4;
00065       memcpy(outbuffer + offset, this->collision1_name, length_collision1_name);
00066       offset += length_collision1_name;
00067       uint32_t length_collision2_name = strlen(this->collision2_name);
00068       varToArr(outbuffer + offset, length_collision2_name);
00069       offset += 4;
00070       memcpy(outbuffer + offset, this->collision2_name, length_collision2_name);
00071       offset += length_collision2_name;
00072       *(outbuffer + offset + 0) = (this->wrenches_length >> (8 * 0)) & 0xFF;
00073       *(outbuffer + offset + 1) = (this->wrenches_length >> (8 * 1)) & 0xFF;
00074       *(outbuffer + offset + 2) = (this->wrenches_length >> (8 * 2)) & 0xFF;
00075       *(outbuffer + offset + 3) = (this->wrenches_length >> (8 * 3)) & 0xFF;
00076       offset += sizeof(this->wrenches_length);
00077       for( uint32_t i = 0; i < wrenches_length; i++){
00078       offset += this->wrenches[i].serialize(outbuffer + offset);
00079       }
00080       offset += this->total_wrench.serialize(outbuffer + offset);
00081       *(outbuffer + offset + 0) = (this->contact_positions_length >> (8 * 0)) & 0xFF;
00082       *(outbuffer + offset + 1) = (this->contact_positions_length >> (8 * 1)) & 0xFF;
00083       *(outbuffer + offset + 2) = (this->contact_positions_length >> (8 * 2)) & 0xFF;
00084       *(outbuffer + offset + 3) = (this->contact_positions_length >> (8 * 3)) & 0xFF;
00085       offset += sizeof(this->contact_positions_length);
00086       for( uint32_t i = 0; i < contact_positions_length; i++){
00087       offset += this->contact_positions[i].serialize(outbuffer + offset);
00088       }
00089       *(outbuffer + offset + 0) = (this->contact_normals_length >> (8 * 0)) & 0xFF;
00090       *(outbuffer + offset + 1) = (this->contact_normals_length >> (8 * 1)) & 0xFF;
00091       *(outbuffer + offset + 2) = (this->contact_normals_length >> (8 * 2)) & 0xFF;
00092       *(outbuffer + offset + 3) = (this->contact_normals_length >> (8 * 3)) & 0xFF;
00093       offset += sizeof(this->contact_normals_length);
00094       for( uint32_t i = 0; i < contact_normals_length; i++){
00095       offset += this->contact_normals[i].serialize(outbuffer + offset);
00096       }
00097       *(outbuffer + offset + 0) = (this->depths_length >> (8 * 0)) & 0xFF;
00098       *(outbuffer + offset + 1) = (this->depths_length >> (8 * 1)) & 0xFF;
00099       *(outbuffer + offset + 2) = (this->depths_length >> (8 * 2)) & 0xFF;
00100       *(outbuffer + offset + 3) = (this->depths_length >> (8 * 3)) & 0xFF;
00101       offset += sizeof(this->depths_length);
00102       for( uint32_t i = 0; i < depths_length; i++){
00103       union {
00104         double real;
00105         uint64_t base;
00106       } u_depthsi;
00107       u_depthsi.real = this->depths[i];
00108       *(outbuffer + offset + 0) = (u_depthsi.base >> (8 * 0)) & 0xFF;
00109       *(outbuffer + offset + 1) = (u_depthsi.base >> (8 * 1)) & 0xFF;
00110       *(outbuffer + offset + 2) = (u_depthsi.base >> (8 * 2)) & 0xFF;
00111       *(outbuffer + offset + 3) = (u_depthsi.base >> (8 * 3)) & 0xFF;
00112       *(outbuffer + offset + 4) = (u_depthsi.base >> (8 * 4)) & 0xFF;
00113       *(outbuffer + offset + 5) = (u_depthsi.base >> (8 * 5)) & 0xFF;
00114       *(outbuffer + offset + 6) = (u_depthsi.base >> (8 * 6)) & 0xFF;
00115       *(outbuffer + offset + 7) = (u_depthsi.base >> (8 * 7)) & 0xFF;
00116       offset += sizeof(this->depths[i]);
00117       }
00118       return offset;
00119     }
00120 
00121     virtual int deserialize(unsigned char *inbuffer)
00122     {
00123       int offset = 0;
00124       uint32_t length_info;
00125       arrToVar(length_info, (inbuffer + offset));
00126       offset += 4;
00127       for(unsigned int k= offset; k< offset+length_info; ++k){
00128           inbuffer[k-1]=inbuffer[k];
00129       }
00130       inbuffer[offset+length_info-1]=0;
00131       this->info = (char *)(inbuffer + offset-1);
00132       offset += length_info;
00133       uint32_t length_collision1_name;
00134       arrToVar(length_collision1_name, (inbuffer + offset));
00135       offset += 4;
00136       for(unsigned int k= offset; k< offset+length_collision1_name; ++k){
00137           inbuffer[k-1]=inbuffer[k];
00138       }
00139       inbuffer[offset+length_collision1_name-1]=0;
00140       this->collision1_name = (char *)(inbuffer + offset-1);
00141       offset += length_collision1_name;
00142       uint32_t length_collision2_name;
00143       arrToVar(length_collision2_name, (inbuffer + offset));
00144       offset += 4;
00145       for(unsigned int k= offset; k< offset+length_collision2_name; ++k){
00146           inbuffer[k-1]=inbuffer[k];
00147       }
00148       inbuffer[offset+length_collision2_name-1]=0;
00149       this->collision2_name = (char *)(inbuffer + offset-1);
00150       offset += length_collision2_name;
00151       uint32_t wrenches_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00152       wrenches_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00153       wrenches_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00154       wrenches_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00155       offset += sizeof(this->wrenches_length);
00156       if(wrenches_lengthT > wrenches_length)
00157         this->wrenches = (geometry_msgs::Wrench*)realloc(this->wrenches, wrenches_lengthT * sizeof(geometry_msgs::Wrench));
00158       wrenches_length = wrenches_lengthT;
00159       for( uint32_t i = 0; i < wrenches_length; i++){
00160       offset += this->st_wrenches.deserialize(inbuffer + offset);
00161         memcpy( &(this->wrenches[i]), &(this->st_wrenches), sizeof(geometry_msgs::Wrench));
00162       }
00163       offset += this->total_wrench.deserialize(inbuffer + offset);
00164       uint32_t contact_positions_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00165       contact_positions_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00166       contact_positions_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00167       contact_positions_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00168       offset += sizeof(this->contact_positions_length);
00169       if(contact_positions_lengthT > contact_positions_length)
00170         this->contact_positions = (geometry_msgs::Vector3*)realloc(this->contact_positions, contact_positions_lengthT * sizeof(geometry_msgs::Vector3));
00171       contact_positions_length = contact_positions_lengthT;
00172       for( uint32_t i = 0; i < contact_positions_length; i++){
00173       offset += this->st_contact_positions.deserialize(inbuffer + offset);
00174         memcpy( &(this->contact_positions[i]), &(this->st_contact_positions), sizeof(geometry_msgs::Vector3));
00175       }
00176       uint32_t contact_normals_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00177       contact_normals_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00178       contact_normals_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00179       contact_normals_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00180       offset += sizeof(this->contact_normals_length);
00181       if(contact_normals_lengthT > contact_normals_length)
00182         this->contact_normals = (geometry_msgs::Vector3*)realloc(this->contact_normals, contact_normals_lengthT * sizeof(geometry_msgs::Vector3));
00183       contact_normals_length = contact_normals_lengthT;
00184       for( uint32_t i = 0; i < contact_normals_length; i++){
00185       offset += this->st_contact_normals.deserialize(inbuffer + offset);
00186         memcpy( &(this->contact_normals[i]), &(this->st_contact_normals), sizeof(geometry_msgs::Vector3));
00187       }
00188       uint32_t depths_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00189       depths_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00190       depths_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00191       depths_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00192       offset += sizeof(this->depths_length);
00193       if(depths_lengthT > depths_length)
00194         this->depths = (double*)realloc(this->depths, depths_lengthT * sizeof(double));
00195       depths_length = depths_lengthT;
00196       for( uint32_t i = 0; i < depths_length; i++){
00197       union {
00198         double real;
00199         uint64_t base;
00200       } u_st_depths;
00201       u_st_depths.base = 0;
00202       u_st_depths.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
00203       u_st_depths.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
00204       u_st_depths.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
00205       u_st_depths.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
00206       u_st_depths.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
00207       u_st_depths.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
00208       u_st_depths.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
00209       u_st_depths.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
00210       this->st_depths = u_st_depths.real;
00211       offset += sizeof(this->st_depths);
00212         memcpy( &(this->depths[i]), &(this->st_depths), sizeof(double));
00213       }
00214      return offset;
00215     }
00216 
00217     const char * getType(){ return "gazebo_msgs/ContactState"; };
00218     const char * getMD5(){ return "48c0ffb054b8c444f870cecea1ee50d9"; };
00219 
00220   };
00221 
00222 }
00223 #endif