ROS Serial library for Mbed platforms for ROS Melodic Morenia. Check http://wiki.ros.org/rosserial_mbed/ for more information.
sensor_msgs/PointField.h@2:fa426560b283, 2021-05-27 (annotated)
- Committer:
- krogedal
- Date:
- Thu May 27 19:25:46 2021 +0000
- Revision:
- 2:fa426560b283
- Parent:
- 0:04ac6be8229a
no change
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Gary Servin |
0:04ac6be8229a | 1 | #ifndef _ROS_sensor_msgs_PointField_h |
Gary Servin |
0:04ac6be8229a | 2 | #define _ROS_sensor_msgs_PointField_h |
Gary Servin |
0:04ac6be8229a | 3 | |
Gary Servin |
0:04ac6be8229a | 4 | #include <stdint.h> |
Gary Servin |
0:04ac6be8229a | 5 | #include <string.h> |
Gary Servin |
0:04ac6be8229a | 6 | #include <stdlib.h> |
Gary Servin |
0:04ac6be8229a | 7 | #include "ros/msg.h" |
Gary Servin |
0:04ac6be8229a | 8 | |
Gary Servin |
0:04ac6be8229a | 9 | namespace sensor_msgs |
Gary Servin |
0:04ac6be8229a | 10 | { |
Gary Servin |
0:04ac6be8229a | 11 | |
Gary Servin |
0:04ac6be8229a | 12 | class PointField : public ros::Msg |
Gary Servin |
0:04ac6be8229a | 13 | { |
Gary Servin |
0:04ac6be8229a | 14 | public: |
Gary Servin |
0:04ac6be8229a | 15 | typedef const char* _name_type; |
Gary Servin |
0:04ac6be8229a | 16 | _name_type name; |
Gary Servin |
0:04ac6be8229a | 17 | typedef uint32_t _offset_type; |
Gary Servin |
0:04ac6be8229a | 18 | _offset_type offset; |
Gary Servin |
0:04ac6be8229a | 19 | typedef uint8_t _datatype_type; |
Gary Servin |
0:04ac6be8229a | 20 | _datatype_type datatype; |
Gary Servin |
0:04ac6be8229a | 21 | typedef uint32_t _count_type; |
Gary Servin |
0:04ac6be8229a | 22 | _count_type count; |
Gary Servin |
0:04ac6be8229a | 23 | enum { INT8 = 1 }; |
Gary Servin |
0:04ac6be8229a | 24 | enum { UINT8 = 2 }; |
Gary Servin |
0:04ac6be8229a | 25 | enum { INT16 = 3 }; |
Gary Servin |
0:04ac6be8229a | 26 | enum { UINT16 = 4 }; |
Gary Servin |
0:04ac6be8229a | 27 | enum { INT32 = 5 }; |
Gary Servin |
0:04ac6be8229a | 28 | enum { UINT32 = 6 }; |
Gary Servin |
0:04ac6be8229a | 29 | enum { FLOAT32 = 7 }; |
Gary Servin |
0:04ac6be8229a | 30 | enum { FLOAT64 = 8 }; |
Gary Servin |
0:04ac6be8229a | 31 | |
Gary Servin |
0:04ac6be8229a | 32 | PointField(): |
Gary Servin |
0:04ac6be8229a | 33 | name(""), |
Gary Servin |
0:04ac6be8229a | 34 | offset(0), |
Gary Servin |
0:04ac6be8229a | 35 | datatype(0), |
Gary Servin |
0:04ac6be8229a | 36 | count(0) |
Gary Servin |
0:04ac6be8229a | 37 | { |
Gary Servin |
0:04ac6be8229a | 38 | } |
Gary Servin |
0:04ac6be8229a | 39 | |
Gary Servin |
0:04ac6be8229a | 40 | virtual int serialize(unsigned char *outbuffer) const |
Gary Servin |
0:04ac6be8229a | 41 | { |
Gary Servin |
0:04ac6be8229a | 42 | int offset = 0; |
Gary Servin |
0:04ac6be8229a | 43 | uint32_t length_name = strlen(this->name); |
Gary Servin |
0:04ac6be8229a | 44 | varToArr(outbuffer + offset, length_name); |
Gary Servin |
0:04ac6be8229a | 45 | offset += 4; |
Gary Servin |
0:04ac6be8229a | 46 | memcpy(outbuffer + offset, this->name, length_name); |
Gary Servin |
0:04ac6be8229a | 47 | offset += length_name; |
Gary Servin |
0:04ac6be8229a | 48 | *(outbuffer + offset + 0) = (this->offset >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 49 | *(outbuffer + offset + 1) = (this->offset >> (8 * 1)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 50 | *(outbuffer + offset + 2) = (this->offset >> (8 * 2)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 51 | *(outbuffer + offset + 3) = (this->offset >> (8 * 3)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 52 | offset += sizeof(this->offset); |
Gary Servin |
0:04ac6be8229a | 53 | *(outbuffer + offset + 0) = (this->datatype >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 54 | offset += sizeof(this->datatype); |
Gary Servin |
0:04ac6be8229a | 55 | *(outbuffer + offset + 0) = (this->count >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 56 | *(outbuffer + offset + 1) = (this->count >> (8 * 1)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 57 | *(outbuffer + offset + 2) = (this->count >> (8 * 2)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 58 | *(outbuffer + offset + 3) = (this->count >> (8 * 3)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 59 | offset += sizeof(this->count); |
Gary Servin |
0:04ac6be8229a | 60 | return offset; |
Gary Servin |
0:04ac6be8229a | 61 | } |
Gary Servin |
0:04ac6be8229a | 62 | |
Gary Servin |
0:04ac6be8229a | 63 | virtual int deserialize(unsigned char *inbuffer) |
Gary Servin |
0:04ac6be8229a | 64 | { |
Gary Servin |
0:04ac6be8229a | 65 | int offset = 0; |
Gary Servin |
0:04ac6be8229a | 66 | uint32_t length_name; |
Gary Servin |
0:04ac6be8229a | 67 | arrToVar(length_name, (inbuffer + offset)); |
Gary Servin |
0:04ac6be8229a | 68 | offset += 4; |
Gary Servin |
0:04ac6be8229a | 69 | for(unsigned int k= offset; k< offset+length_name; ++k){ |
Gary Servin |
0:04ac6be8229a | 70 | inbuffer[k-1]=inbuffer[k]; |
Gary Servin |
0:04ac6be8229a | 71 | } |
Gary Servin |
0:04ac6be8229a | 72 | inbuffer[offset+length_name-1]=0; |
Gary Servin |
0:04ac6be8229a | 73 | this->name = (char *)(inbuffer + offset-1); |
Gary Servin |
0:04ac6be8229a | 74 | offset += length_name; |
Gary Servin |
0:04ac6be8229a | 75 | this->offset = ((uint32_t) (*(inbuffer + offset))); |
Gary Servin |
0:04ac6be8229a | 76 | this->offset |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Gary Servin |
0:04ac6be8229a | 77 | this->offset |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Gary Servin |
0:04ac6be8229a | 78 | this->offset |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Gary Servin |
0:04ac6be8229a | 79 | offset += sizeof(this->offset); |
Gary Servin |
0:04ac6be8229a | 80 | this->datatype = ((uint8_t) (*(inbuffer + offset))); |
Gary Servin |
0:04ac6be8229a | 81 | offset += sizeof(this->datatype); |
Gary Servin |
0:04ac6be8229a | 82 | this->count = ((uint32_t) (*(inbuffer + offset))); |
Gary Servin |
0:04ac6be8229a | 83 | this->count |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Gary Servin |
0:04ac6be8229a | 84 | this->count |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Gary Servin |
0:04ac6be8229a | 85 | this->count |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Gary Servin |
0:04ac6be8229a | 86 | offset += sizeof(this->count); |
Gary Servin |
0:04ac6be8229a | 87 | return offset; |
Gary Servin |
0:04ac6be8229a | 88 | } |
Gary Servin |
0:04ac6be8229a | 89 | |
Gary Servin |
0:04ac6be8229a | 90 | const char * getType(){ return "sensor_msgs/PointField"; }; |
Gary Servin |
0:04ac6be8229a | 91 | const char * getMD5(){ return "268eacb2962780ceac86cbd17e328150"; }; |
Gary Servin |
0:04ac6be8229a | 92 | |
Gary Servin |
0:04ac6be8229a | 93 | }; |
Gary Servin |
0:04ac6be8229a | 94 | |
Gary Servin |
0:04ac6be8229a | 95 | } |
Gary Servin |
0:04ac6be8229a | 96 | #endif |