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

TimeReference.h

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