root / quad2 / arduino / src / ros_lib / std_msgs / Header.h @ c1426757
History | View | Annotate | Download (3.15 KB)
1 | c1426757 | Tom Mullins | #ifndef _ROS_std_msgs_Header_h
|
---|---|---|---|
2 | #define _ROS_std_msgs_Header_h
|
||
3 | |||
4 | #include <stdint.h> |
||
5 | #include <string.h> |
||
6 | #include <stdlib.h> |
||
7 | #include "ros/msg.h" |
||
8 | #include "ros/time.h" |
||
9 | |||
10 | namespace std_msgs |
||
11 | { |
||
12 | |||
13 | class Header : public ros::Msg |
||
14 | { |
||
15 | public:
|
||
16 | uint32_t seq; |
||
17 | ros::Time stamp; |
||
18 | char * frame_id;
|
||
19 | |||
20 | virtual int serialize(unsigned char *outbuffer) const |
||
21 | { |
||
22 | int offset = 0; |
||
23 | *(outbuffer + offset + 0) = (this->seq >> (8 * 0)) & 0xFF; |
||
24 | *(outbuffer + offset + 1) = (this->seq >> (8 * 1)) & 0xFF; |
||
25 | *(outbuffer + offset + 2) = (this->seq >> (8 * 2)) & 0xFF; |
||
26 | *(outbuffer + offset + 3) = (this->seq >> (8 * 3)) & 0xFF; |
||
27 | offset += sizeof(this->seq);
|
||
28 | *(outbuffer + offset + 0) = (this->stamp.sec >> (8 * 0)) & 0xFF; |
||
29 | *(outbuffer + offset + 1) = (this->stamp.sec >> (8 * 1)) & 0xFF; |
||
30 | *(outbuffer + offset + 2) = (this->stamp.sec >> (8 * 2)) & 0xFF; |
||
31 | *(outbuffer + offset + 3) = (this->stamp.sec >> (8 * 3)) & 0xFF; |
||
32 | offset += sizeof(this->stamp.sec);
|
||
33 | *(outbuffer + offset + 0) = (this->stamp.nsec >> (8 * 0)) & 0xFF; |
||
34 | *(outbuffer + offset + 1) = (this->stamp.nsec >> (8 * 1)) & 0xFF; |
||
35 | *(outbuffer + offset + 2) = (this->stamp.nsec >> (8 * 2)) & 0xFF; |
||
36 | *(outbuffer + offset + 3) = (this->stamp.nsec >> (8 * 3)) & 0xFF; |
||
37 | offset += sizeof(this->stamp.nsec);
|
||
38 | uint32_t * length_frame_id = (uint32_t *)(outbuffer + offset); |
||
39 | *length_frame_id = strlen( (const char*) this->frame_id); |
||
40 | offset += 4;
|
||
41 | memcpy(outbuffer + offset, this->frame_id, *length_frame_id); |
||
42 | offset += *length_frame_id; |
||
43 | return offset;
|
||
44 | } |
||
45 | |||
46 | virtual int deserialize(unsigned char *inbuffer) |
||
47 | { |
||
48 | int offset = 0; |
||
49 | this->seq |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
||
50 | this->seq |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
||
51 | this->seq |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
||
52 | this->seq |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
||
53 | offset += sizeof(this->seq);
|
||
54 | this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
||
55 | this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
||
56 | this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
||
57 | this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
||
58 | offset += sizeof(this->stamp.sec);
|
||
59 | this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
||
60 | this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
||
61 | this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
||
62 | this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
||
63 | offset += sizeof(this->stamp.nsec);
|
||
64 | uint32_t length_frame_id = *(uint32_t *)(inbuffer + offset); |
||
65 | offset += 4;
|
||
66 | for(unsigned int k= offset; k< offset+length_frame_id; ++k){ |
||
67 | inbuffer[k-1]=inbuffer[k];
|
||
68 | } |
||
69 | inbuffer[offset+length_frame_id-1]=0; |
||
70 | this->frame_id = (char *)(inbuffer + offset-1); |
||
71 | offset += length_frame_id; |
||
72 | return offset;
|
||
73 | } |
||
74 | |||
75 | const char * getType(){ return "std_msgs/Header"; }; |
||
76 | const char * getMD5(){ return "2176decaecbce78abc3b96ef049fabed"; }; |
||
77 | |||
78 | }; |
||
79 | |||
80 | } |
||
81 | #endif |