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 InteractiveMarkerInit.h Source File

InteractiveMarkerInit.h

00001 #ifndef _ROS_visualization_msgs_InteractiveMarkerInit_h
00002 #define _ROS_visualization_msgs_InteractiveMarkerInit_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 #include "visualization_msgs/InteractiveMarker.h"
00009 
00010 namespace visualization_msgs
00011 {
00012 
00013   class InteractiveMarkerInit : public ros::Msg
00014   {
00015     public:
00016       typedef const char* _server_id_type;
00017       _server_id_type server_id;
00018       typedef uint64_t _seq_num_type;
00019       _seq_num_type seq_num;
00020       uint32_t markers_length;
00021       typedef visualization_msgs::InteractiveMarker _markers_type;
00022       _markers_type st_markers;
00023       _markers_type * markers;
00024 
00025     InteractiveMarkerInit():
00026       server_id(""),
00027       seq_num(0),
00028       markers_length(0), markers(NULL)
00029     {
00030     }
00031 
00032     virtual int serialize(unsigned char *outbuffer) const
00033     {
00034       int offset = 0;
00035       uint32_t length_server_id = strlen(this->server_id);
00036       varToArr(outbuffer + offset, length_server_id);
00037       offset += 4;
00038       memcpy(outbuffer + offset, this->server_id, length_server_id);
00039       offset += length_server_id;
00040       union {
00041         uint64_t real;
00042         uint32_t base;
00043       } u_seq_num;
00044       u_seq_num.real = this->seq_num;
00045       *(outbuffer + offset + 0) = (u_seq_num.base >> (8 * 0)) & 0xFF;
00046       *(outbuffer + offset + 1) = (u_seq_num.base >> (8 * 1)) & 0xFF;
00047       *(outbuffer + offset + 2) = (u_seq_num.base >> (8 * 2)) & 0xFF;
00048       *(outbuffer + offset + 3) = (u_seq_num.base >> (8 * 3)) & 0xFF;
00049       offset += sizeof(this->seq_num);
00050       *(outbuffer + offset + 0) = (this->markers_length >> (8 * 0)) & 0xFF;
00051       *(outbuffer + offset + 1) = (this->markers_length >> (8 * 1)) & 0xFF;
00052       *(outbuffer + offset + 2) = (this->markers_length >> (8 * 2)) & 0xFF;
00053       *(outbuffer + offset + 3) = (this->markers_length >> (8 * 3)) & 0xFF;
00054       offset += sizeof(this->markers_length);
00055       for( uint32_t i = 0; i < markers_length; i++){
00056       offset += this->markers[i].serialize(outbuffer + offset);
00057       }
00058       return offset;
00059     }
00060 
00061     virtual int deserialize(unsigned char *inbuffer)
00062     {
00063       int offset = 0;
00064       uint32_t length_server_id;
00065       arrToVar(length_server_id, (inbuffer + offset));
00066       offset += 4;
00067       for(unsigned int k= offset; k< offset+length_server_id; ++k){
00068           inbuffer[k-1]=inbuffer[k];
00069       }
00070       inbuffer[offset+length_server_id-1]=0;
00071       this->server_id = (char *)(inbuffer + offset-1);
00072       offset += length_server_id;
00073       union {
00074         uint64_t real;
00075         uint32_t base;
00076       } u_seq_num;
00077       u_seq_num.base = 0;
00078       u_seq_num.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00079       u_seq_num.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00080       u_seq_num.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00081       u_seq_num.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00082       this->seq_num = u_seq_num.real;
00083       offset += sizeof(this->seq_num);
00084       uint32_t markers_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00085       markers_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00086       markers_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00087       markers_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00088       offset += sizeof(this->markers_length);
00089       if(markers_lengthT > markers_length)
00090         this->markers = (visualization_msgs::InteractiveMarker*)realloc(this->markers, markers_lengthT * sizeof(visualization_msgs::InteractiveMarker));
00091       markers_length = markers_lengthT;
00092       for( uint32_t i = 0; i < markers_length; i++){
00093       offset += this->st_markers.deserialize(inbuffer + offset);
00094         memcpy( &(this->markers[i]), &(this->st_markers), sizeof(visualization_msgs::InteractiveMarker));
00095       }
00096      return offset;
00097     }
00098 
00099     const char * getType(){ return "visualization_msgs/InteractiveMarkerInit"; };
00100     const char * getMD5(){ return "d5f2c5045a72456d228676ab91048734"; };
00101 
00102   };
00103 
00104 }
00105 #endif