rosserial for Hydro
Fork of rosserial_mbed_lib by
sensor_msgs/PointField.h@3:1cf99502f396, 2011-11-12 (annotated)
- Committer:
- nucho
- Date:
- Sat Nov 12 23:54:45 2011 +0000
- Revision:
- 3:1cf99502f396
- Parent:
- 0:77afd7560544
This program supported the revision of 167 of rosserial.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nucho | 3:1cf99502f396 | 1 | #ifndef _ROS_sensor_msgs_PointField_h |
nucho | 3:1cf99502f396 | 2 | #define _ROS_sensor_msgs_PointField_h |
nucho | 0:77afd7560544 | 3 | |
nucho | 0:77afd7560544 | 4 | #include <stdint.h> |
nucho | 0:77afd7560544 | 5 | #include <string.h> |
nucho | 0:77afd7560544 | 6 | #include <stdlib.h> |
nucho | 3:1cf99502f396 | 7 | #include "ros/msg.h" |
nucho | 0:77afd7560544 | 8 | |
nucho | 0:77afd7560544 | 9 | namespace sensor_msgs |
nucho | 0:77afd7560544 | 10 | { |
nucho | 0:77afd7560544 | 11 | |
nucho | 0:77afd7560544 | 12 | class PointField : public ros::Msg |
nucho | 0:77afd7560544 | 13 | { |
nucho | 0:77afd7560544 | 14 | public: |
nucho | 0:77afd7560544 | 15 | char * name; |
nucho | 3:1cf99502f396 | 16 | uint32_t offset; |
nucho | 3:1cf99502f396 | 17 | uint8_t datatype; |
nucho | 3:1cf99502f396 | 18 | uint32_t count; |
nucho | 3:1cf99502f396 | 19 | enum { INT8 = 1 }; |
nucho | 3:1cf99502f396 | 20 | enum { UINT8 = 2 }; |
nucho | 3:1cf99502f396 | 21 | enum { INT16 = 3 }; |
nucho | 3:1cf99502f396 | 22 | enum { UINT16 = 4 }; |
nucho | 3:1cf99502f396 | 23 | enum { INT32 = 5 }; |
nucho | 3:1cf99502f396 | 24 | enum { UINT32 = 6 }; |
nucho | 3:1cf99502f396 | 25 | enum { FLOAT32 = 7 }; |
nucho | 3:1cf99502f396 | 26 | enum { FLOAT64 = 8 }; |
nucho | 0:77afd7560544 | 27 | |
nucho | 3:1cf99502f396 | 28 | virtual int serialize(unsigned char *outbuffer) const |
nucho | 0:77afd7560544 | 29 | { |
nucho | 0:77afd7560544 | 30 | int offset = 0; |
nucho | 3:1cf99502f396 | 31 | uint32_t * length_name = (uint32_t *)(outbuffer + offset); |
nucho | 0:77afd7560544 | 32 | *length_name = strlen( (const char*) this->name); |
nucho | 0:77afd7560544 | 33 | offset += 4; |
nucho | 0:77afd7560544 | 34 | memcpy(outbuffer + offset, this->name, *length_name); |
nucho | 0:77afd7560544 | 35 | offset += *length_name; |
nucho | 3:1cf99502f396 | 36 | *(outbuffer + offset + 0) = (this->offset >> (8 * 0)) & 0xFF; |
nucho | 3:1cf99502f396 | 37 | *(outbuffer + offset + 1) = (this->offset >> (8 * 1)) & 0xFF; |
nucho | 3:1cf99502f396 | 38 | *(outbuffer + offset + 2) = (this->offset >> (8 * 2)) & 0xFF; |
nucho | 3:1cf99502f396 | 39 | *(outbuffer + offset + 3) = (this->offset >> (8 * 3)) & 0xFF; |
nucho | 0:77afd7560544 | 40 | offset += sizeof(this->offset); |
nucho | 3:1cf99502f396 | 41 | *(outbuffer + offset + 0) = (this->datatype >> (8 * 0)) & 0xFF; |
nucho | 0:77afd7560544 | 42 | offset += sizeof(this->datatype); |
nucho | 3:1cf99502f396 | 43 | *(outbuffer + offset + 0) = (this->count >> (8 * 0)) & 0xFF; |
nucho | 3:1cf99502f396 | 44 | *(outbuffer + offset + 1) = (this->count >> (8 * 1)) & 0xFF; |
nucho | 3:1cf99502f396 | 45 | *(outbuffer + offset + 2) = (this->count >> (8 * 2)) & 0xFF; |
nucho | 3:1cf99502f396 | 46 | *(outbuffer + offset + 3) = (this->count >> (8 * 3)) & 0xFF; |
nucho | 0:77afd7560544 | 47 | offset += sizeof(this->count); |
nucho | 0:77afd7560544 | 48 | return offset; |
nucho | 0:77afd7560544 | 49 | } |
nucho | 0:77afd7560544 | 50 | |
nucho | 0:77afd7560544 | 51 | virtual int deserialize(unsigned char *inbuffer) |
nucho | 0:77afd7560544 | 52 | { |
nucho | 0:77afd7560544 | 53 | int offset = 0; |
nucho | 0:77afd7560544 | 54 | uint32_t length_name = *(uint32_t *)(inbuffer + offset); |
nucho | 0:77afd7560544 | 55 | offset += 4; |
nucho | 0:77afd7560544 | 56 | for(unsigned int k= offset; k< offset+length_name; ++k){ |
nucho | 0:77afd7560544 | 57 | inbuffer[k-1]=inbuffer[k]; |
nucho | 3:1cf99502f396 | 58 | } |
nucho | 0:77afd7560544 | 59 | inbuffer[offset+length_name-1]=0; |
nucho | 0:77afd7560544 | 60 | this->name = (char *)(inbuffer + offset-1); |
nucho | 0:77afd7560544 | 61 | offset += length_name; |
nucho | 3:1cf99502f396 | 62 | this->offset |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
nucho | 3:1cf99502f396 | 63 | this->offset |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
nucho | 3:1cf99502f396 | 64 | this->offset |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
nucho | 3:1cf99502f396 | 65 | this->offset |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
nucho | 0:77afd7560544 | 66 | offset += sizeof(this->offset); |
nucho | 3:1cf99502f396 | 67 | this->datatype |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); |
nucho | 0:77afd7560544 | 68 | offset += sizeof(this->datatype); |
nucho | 3:1cf99502f396 | 69 | this->count |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
nucho | 3:1cf99502f396 | 70 | this->count |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
nucho | 3:1cf99502f396 | 71 | this->count |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
nucho | 3:1cf99502f396 | 72 | this->count |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
nucho | 0:77afd7560544 | 73 | offset += sizeof(this->count); |
nucho | 0:77afd7560544 | 74 | return offset; |
nucho | 0:77afd7560544 | 75 | } |
nucho | 0:77afd7560544 | 76 | |
nucho | 3:1cf99502f396 | 77 | virtual const char * getType(){ return "sensor_msgs/PointField"; }; |
nucho | 3:1cf99502f396 | 78 | virtual const char * getMD5(){ return "268eacb2962780ceac86cbd17e328150"; }; |
nucho | 0:77afd7560544 | 79 | |
nucho | 0:77afd7560544 | 80 | }; |
nucho | 0:77afd7560544 | 81 | |
nucho | 0:77afd7560544 | 82 | } |
nucho | 0:77afd7560544 | 83 | #endif |