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

Header.h

00001 #ifndef _ROS_std_msgs_Header_h
00002 #define _ROS_std_msgs_Header_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 #include "ros/time.h"
00009 
00010 namespace std_msgs
00011 {
00012 
00013   class Header : public ros::Msg
00014   {
00015     public:
00016       typedef uint32_t _seq_type;
00017       _seq_type seq;
00018       typedef ros::Time _stamp_type;
00019       _stamp_type stamp;
00020       typedef const char* _frame_id_type;
00021       _frame_id_type frame_id;
00022 
00023     Header():
00024       seq(0),
00025       stamp(),
00026       frame_id("")
00027     {
00028     }
00029 
00030     virtual int serialize(unsigned char *outbuffer) const
00031     {
00032       int offset = 0;
00033       *(outbuffer + offset + 0) = (this->seq >> (8 * 0)) & 0xFF;
00034       *(outbuffer + offset + 1) = (this->seq >> (8 * 1)) & 0xFF;
00035       *(outbuffer + offset + 2) = (this->seq >> (8 * 2)) & 0xFF;
00036       *(outbuffer + offset + 3) = (this->seq >> (8 * 3)) & 0xFF;
00037       offset += sizeof(this->seq);
00038       *(outbuffer + offset + 0) = (this->stamp.sec >> (8 * 0)) & 0xFF;
00039       *(outbuffer + offset + 1) = (this->stamp.sec >> (8 * 1)) & 0xFF;
00040       *(outbuffer + offset + 2) = (this->stamp.sec >> (8 * 2)) & 0xFF;
00041       *(outbuffer + offset + 3) = (this->stamp.sec >> (8 * 3)) & 0xFF;
00042       offset += sizeof(this->stamp.sec);
00043       *(outbuffer + offset + 0) = (this->stamp.nsec >> (8 * 0)) & 0xFF;
00044       *(outbuffer + offset + 1) = (this->stamp.nsec >> (8 * 1)) & 0xFF;
00045       *(outbuffer + offset + 2) = (this->stamp.nsec >> (8 * 2)) & 0xFF;
00046       *(outbuffer + offset + 3) = (this->stamp.nsec >> (8 * 3)) & 0xFF;
00047       offset += sizeof(this->stamp.nsec);
00048       uint32_t length_frame_id = strlen(this->frame_id);
00049       varToArr(outbuffer + offset, length_frame_id);
00050       offset += 4;
00051       memcpy(outbuffer + offset, this->frame_id, length_frame_id);
00052       offset += length_frame_id;
00053       return offset;
00054     }
00055 
00056     virtual int deserialize(unsigned char *inbuffer)
00057     {
00058       int offset = 0;
00059       this->seq =  ((uint32_t) (*(inbuffer + offset)));
00060       this->seq |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00061       this->seq |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00062       this->seq |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00063       offset += sizeof(this->seq);
00064       this->stamp.sec =  ((uint32_t) (*(inbuffer + offset)));
00065       this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00066       this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00067       this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00068       offset += sizeof(this->stamp.sec);
00069       this->stamp.nsec =  ((uint32_t) (*(inbuffer + offset)));
00070       this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00071       this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00072       this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00073       offset += sizeof(this->stamp.nsec);
00074       uint32_t length_frame_id;
00075       arrToVar(length_frame_id, (inbuffer + offset));
00076       offset += 4;
00077       for(unsigned int k= offset; k< offset+length_frame_id; ++k){
00078           inbuffer[k-1]=inbuffer[k];
00079       }
00080       inbuffer[offset+length_frame_id-1]=0;
00081       this->frame_id = (char *)(inbuffer + offset-1);
00082       offset += length_frame_id;
00083      return offset;
00084     }
00085 
00086     const char * getType(){ return "std_msgs/Header"; };
00087     const char * getMD5(){ return "2176decaecbce78abc3b96ef049fabed"; };
00088 
00089   };
00090 
00091 }
00092 #endif