kitt_platform
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros
TimeReference.h
Go to the documentation of this file.
1 #ifndef _ROS_sensor_msgs_TimeReference_h
2 #define _ROS_sensor_msgs_TimeReference_h
3 
4 #include <stdint.h>
5 #include <string.h>
6 #include <stdlib.h>
7 #include "ros/msg.h"
8 #include "std_msgs/Header.h"
9 #include "ros/time.h"
10 
11 namespace sensor_msgs
12 {
13 
14  class TimeReference : public ros::Msg
15  {
16  public:
19  const char* source;
20 
22  header(),
23  time_ref(),
24  source("")
25  {
26  }
27 
28  virtual int serialize(unsigned char *outbuffer) const
29  {
30  int offset = 0;
31  offset += this->header.serialize(outbuffer + offset);
32  *(outbuffer + offset + 0) = (this->time_ref.sec >> (8 * 0)) & 0xFF;
33  *(outbuffer + offset + 1) = (this->time_ref.sec >> (8 * 1)) & 0xFF;
34  *(outbuffer + offset + 2) = (this->time_ref.sec >> (8 * 2)) & 0xFF;
35  *(outbuffer + offset + 3) = (this->time_ref.sec >> (8 * 3)) & 0xFF;
36  offset += sizeof(this->time_ref.sec);
37  *(outbuffer + offset + 0) = (this->time_ref.nsec >> (8 * 0)) & 0xFF;
38  *(outbuffer + offset + 1) = (this->time_ref.nsec >> (8 * 1)) & 0xFF;
39  *(outbuffer + offset + 2) = (this->time_ref.nsec >> (8 * 2)) & 0xFF;
40  *(outbuffer + offset + 3) = (this->time_ref.nsec >> (8 * 3)) & 0xFF;
41  offset += sizeof(this->time_ref.nsec);
42  uint32_t length_source = strlen(this->source);
43  memcpy(outbuffer + offset, &length_source, sizeof(uint32_t));
44  offset += 4;
45  memcpy(outbuffer + offset, this->source, length_source);
46  offset += length_source;
47  return offset;
48  }
49 
50  virtual int deserialize(unsigned char *inbuffer)
51  {
52  int offset = 0;
53  offset += this->header.deserialize(inbuffer + offset);
54  this->time_ref.sec = ((uint32_t) (*(inbuffer + offset)));
55  this->time_ref.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
56  this->time_ref.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
57  this->time_ref.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
58  offset += sizeof(this->time_ref.sec);
59  this->time_ref.nsec = ((uint32_t) (*(inbuffer + offset)));
60  this->time_ref.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
61  this->time_ref.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
62  this->time_ref.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
63  offset += sizeof(this->time_ref.nsec);
64  uint32_t length_source;
65  memcpy(&length_source, (inbuffer + offset), sizeof(uint32_t));
66  offset += 4;
67  for(unsigned int k= offset; k< offset+length_source; ++k){
68  inbuffer[k-1]=inbuffer[k];
69  }
70  inbuffer[offset+length_source-1]=0;
71  this->source = (char *)(inbuffer + offset-1);
72  offset += length_source;
73  return offset;
74  }
75 
76  const char * getType(){ return "sensor_msgs/TimeReference"; };
77  const char * getMD5(){ return "fded64a0265108ba86c3d38fb11c0c16"; };
78 
79  };
80 
81 }
82 #endif
ros::Time time_ref
Definition: TimeReference.h:18
virtual int deserialize(unsigned char *inbuffer)
Definition: Header.h:53
const char * getMD5()
Definition: TimeReference.h:77
uint32_t nsec
Definition: time.h:50
uint32_t sec
Definition: time.h:50
Definition: time.h:47
virtual int serialize(unsigned char *outbuffer) const
Definition: TimeReference.h:28
std_msgs::Header header
Definition: TimeReference.h:17
Definition: TimeReference.h:14
TimeReference()
Definition: TimeReference.h:21
virtual int serialize(unsigned char *outbuffer) const
Definition: Header.h:27
Definition: Header.h:13
const char * source
Definition: TimeReference.h:19
const char * getType()
Definition: TimeReference.h:76
virtual int deserialize(unsigned char *inbuffer)
Definition: TimeReference.h:50
Definition: msg.h:43