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 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       const char* server_id;
00017       uint64_t seq_num;
00018       uint8_t markers_length;
00019       visualization_msgs::InteractiveMarker st_markers;
00020       visualization_msgs::InteractiveMarker * markers;
00021 
00022     InteractiveMarkerInit():
00023       server_id(""),
00024       seq_num(0),
00025       markers_length(0), markers(NULL)
00026     {
00027     }
00028 
00029     virtual int serialize(unsigned char *outbuffer) const
00030     {
00031       int offset = 0;
00032       uint32_t length_server_id = strlen(this->server_id);
00033       memcpy(outbuffer + offset, &length_server_id, sizeof(uint32_t));
00034       offset += 4;
00035       memcpy(outbuffer + offset, this->server_id, length_server_id);
00036       offset += length_server_id;
00037       union {
00038         uint64_t real;
00039         uint32_t base;
00040       } u_seq_num;
00041       u_seq_num.real = this->seq_num;
00042       *(outbuffer + offset + 0) = (u_seq_num.base >> (8 * 0)) & 0xFF;
00043       *(outbuffer + offset + 1) = (u_seq_num.base >> (8 * 1)) & 0xFF;
00044       *(outbuffer + offset + 2) = (u_seq_num.base >> (8 * 2)) & 0xFF;
00045       *(outbuffer + offset + 3) = (u_seq_num.base >> (8 * 3)) & 0xFF;
00046       offset += sizeof(this->seq_num);
00047       *(outbuffer + offset++) = markers_length;
00048       *(outbuffer + offset++) = 0;
00049       *(outbuffer + offset++) = 0;
00050       *(outbuffer + offset++) = 0;
00051       for( uint8_t i = 0; i < markers_length; i++){
00052       offset += this->markers[i].serialize(outbuffer + offset);
00053       }
00054       return offset;
00055     }
00056 
00057     virtual int deserialize(unsigned char *inbuffer)
00058     {
00059       int offset = 0;
00060       uint32_t length_server_id;
00061       memcpy(&length_server_id, (inbuffer + offset), sizeof(uint32_t));
00062       offset += 4;
00063       for(unsigned int k= offset; k< offset+length_server_id; ++k){
00064           inbuffer[k-1]=inbuffer[k];
00065       }
00066       inbuffer[offset+length_server_id-1]=0;
00067       this->server_id = (char *)(inbuffer + offset-1);
00068       offset += length_server_id;
00069       union {
00070         uint64_t real;
00071         uint32_t base;
00072       } u_seq_num;
00073       u_seq_num.base = 0;
00074       u_seq_num.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00075       u_seq_num.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00076       u_seq_num.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00077       u_seq_num.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00078       this->seq_num = u_seq_num.real;
00079       offset += sizeof(this->seq_num);
00080       uint8_t markers_lengthT = *(inbuffer + offset++);
00081       if(markers_lengthT > markers_length)
00082         this->markers = (visualization_msgs::InteractiveMarker*)realloc(this->markers, markers_lengthT * sizeof(visualization_msgs::InteractiveMarker));
00083       offset += 3;
00084       markers_length = markers_lengthT;
00085       for( uint8_t i = 0; i < markers_length; i++){
00086       offset += this->st_markers.deserialize(inbuffer + offset);
00087         memcpy( &(this->markers[i]), &(this->st_markers), sizeof(visualization_msgs::InteractiveMarker));
00088       }
00089      return offset;
00090     }
00091 
00092     const char * getType(){ return "visualization_msgs/InteractiveMarkerInit"; };
00093     const char * getMD5(){ return "aa2f1dcea79533d1710675195653028d"; };
00094 
00095   };
00096 
00097 }
00098 #endif