ROS Serial library for Mbed platforms for ROS Melodic Morenia. Check http://wiki.ros.org/rosserial_mbed/ for more information.
shape_msgs/SolidPrimitive.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_shape_msgs_SolidPrimitive_h |
Gary Servin |
0:04ac6be8229a | 2 | #define _ROS_shape_msgs_SolidPrimitive_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 shape_msgs |
Gary Servin |
0:04ac6be8229a | 10 | { |
Gary Servin |
0:04ac6be8229a | 11 | |
Gary Servin |
0:04ac6be8229a | 12 | class SolidPrimitive : public ros::Msg |
Gary Servin |
0:04ac6be8229a | 13 | { |
Gary Servin |
0:04ac6be8229a | 14 | public: |
Gary Servin |
0:04ac6be8229a | 15 | typedef uint8_t _type_type; |
Gary Servin |
0:04ac6be8229a | 16 | _type_type type; |
Gary Servin |
0:04ac6be8229a | 17 | uint32_t dimensions_length; |
Gary Servin |
0:04ac6be8229a | 18 | typedef double _dimensions_type; |
Gary Servin |
0:04ac6be8229a | 19 | _dimensions_type st_dimensions; |
Gary Servin |
0:04ac6be8229a | 20 | _dimensions_type * dimensions; |
Gary Servin |
0:04ac6be8229a | 21 | enum { BOX = 1 }; |
Gary Servin |
0:04ac6be8229a | 22 | enum { SPHERE = 2 }; |
Gary Servin |
0:04ac6be8229a | 23 | enum { CYLINDER = 3 }; |
Gary Servin |
0:04ac6be8229a | 24 | enum { CONE = 4 }; |
Gary Servin |
0:04ac6be8229a | 25 | enum { BOX_X = 0 }; |
Gary Servin |
0:04ac6be8229a | 26 | enum { BOX_Y = 1 }; |
Gary Servin |
0:04ac6be8229a | 27 | enum { BOX_Z = 2 }; |
Gary Servin |
0:04ac6be8229a | 28 | enum { SPHERE_RADIUS = 0 }; |
Gary Servin |
0:04ac6be8229a | 29 | enum { CYLINDER_HEIGHT = 0 }; |
Gary Servin |
0:04ac6be8229a | 30 | enum { CYLINDER_RADIUS = 1 }; |
Gary Servin |
0:04ac6be8229a | 31 | enum { CONE_HEIGHT = 0 }; |
Gary Servin |
0:04ac6be8229a | 32 | enum { CONE_RADIUS = 1 }; |
Gary Servin |
0:04ac6be8229a | 33 | |
Gary Servin |
0:04ac6be8229a | 34 | SolidPrimitive(): |
Gary Servin |
0:04ac6be8229a | 35 | type(0), |
Gary Servin |
0:04ac6be8229a | 36 | dimensions_length(0), dimensions(NULL) |
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 | *(outbuffer + offset + 0) = (this->type >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 44 | offset += sizeof(this->type); |
Gary Servin |
0:04ac6be8229a | 45 | *(outbuffer + offset + 0) = (this->dimensions_length >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 46 | *(outbuffer + offset + 1) = (this->dimensions_length >> (8 * 1)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 47 | *(outbuffer + offset + 2) = (this->dimensions_length >> (8 * 2)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 48 | *(outbuffer + offset + 3) = (this->dimensions_length >> (8 * 3)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 49 | offset += sizeof(this->dimensions_length); |
Gary Servin |
0:04ac6be8229a | 50 | for( uint32_t i = 0; i < dimensions_length; i++){ |
Gary Servin |
0:04ac6be8229a | 51 | union { |
Gary Servin |
0:04ac6be8229a | 52 | double real; |
Gary Servin |
0:04ac6be8229a | 53 | uint64_t base; |
Gary Servin |
0:04ac6be8229a | 54 | } u_dimensionsi; |
Gary Servin |
0:04ac6be8229a | 55 | u_dimensionsi.real = this->dimensions[i]; |
Gary Servin |
0:04ac6be8229a | 56 | *(outbuffer + offset + 0) = (u_dimensionsi.base >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 57 | *(outbuffer + offset + 1) = (u_dimensionsi.base >> (8 * 1)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 58 | *(outbuffer + offset + 2) = (u_dimensionsi.base >> (8 * 2)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 59 | *(outbuffer + offset + 3) = (u_dimensionsi.base >> (8 * 3)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 60 | *(outbuffer + offset + 4) = (u_dimensionsi.base >> (8 * 4)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 61 | *(outbuffer + offset + 5) = (u_dimensionsi.base >> (8 * 5)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 62 | *(outbuffer + offset + 6) = (u_dimensionsi.base >> (8 * 6)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 63 | *(outbuffer + offset + 7) = (u_dimensionsi.base >> (8 * 7)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 64 | offset += sizeof(this->dimensions[i]); |
Gary Servin |
0:04ac6be8229a | 65 | } |
Gary Servin |
0:04ac6be8229a | 66 | return offset; |
Gary Servin |
0:04ac6be8229a | 67 | } |
Gary Servin |
0:04ac6be8229a | 68 | |
Gary Servin |
0:04ac6be8229a | 69 | virtual int deserialize(unsigned char *inbuffer) |
Gary Servin |
0:04ac6be8229a | 70 | { |
Gary Servin |
0:04ac6be8229a | 71 | int offset = 0; |
Gary Servin |
0:04ac6be8229a | 72 | this->type = ((uint8_t) (*(inbuffer + offset))); |
Gary Servin |
0:04ac6be8229a | 73 | offset += sizeof(this->type); |
Gary Servin |
0:04ac6be8229a | 74 | uint32_t dimensions_lengthT = ((uint32_t) (*(inbuffer + offset))); |
Gary Servin |
0:04ac6be8229a | 75 | dimensions_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Gary Servin |
0:04ac6be8229a | 76 | dimensions_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Gary Servin |
0:04ac6be8229a | 77 | dimensions_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Gary Servin |
0:04ac6be8229a | 78 | offset += sizeof(this->dimensions_length); |
Gary Servin |
0:04ac6be8229a | 79 | if(dimensions_lengthT > dimensions_length) |
Gary Servin |
0:04ac6be8229a | 80 | this->dimensions = (double*)realloc(this->dimensions, dimensions_lengthT * sizeof(double)); |
Gary Servin |
0:04ac6be8229a | 81 | dimensions_length = dimensions_lengthT; |
Gary Servin |
0:04ac6be8229a | 82 | for( uint32_t i = 0; i < dimensions_length; i++){ |
Gary Servin |
0:04ac6be8229a | 83 | union { |
Gary Servin |
0:04ac6be8229a | 84 | double real; |
Gary Servin |
0:04ac6be8229a | 85 | uint64_t base; |
Gary Servin |
0:04ac6be8229a | 86 | } u_st_dimensions; |
Gary Servin |
0:04ac6be8229a | 87 | u_st_dimensions.base = 0; |
Gary Servin |
0:04ac6be8229a | 88 | u_st_dimensions.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); |
Gary Servin |
0:04ac6be8229a | 89 | u_st_dimensions.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Gary Servin |
0:04ac6be8229a | 90 | u_st_dimensions.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Gary Servin |
0:04ac6be8229a | 91 | u_st_dimensions.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Gary Servin |
0:04ac6be8229a | 92 | u_st_dimensions.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); |
Gary Servin |
0:04ac6be8229a | 93 | u_st_dimensions.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); |
Gary Servin |
0:04ac6be8229a | 94 | u_st_dimensions.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); |
Gary Servin |
0:04ac6be8229a | 95 | u_st_dimensions.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); |
Gary Servin |
0:04ac6be8229a | 96 | this->st_dimensions = u_st_dimensions.real; |
Gary Servin |
0:04ac6be8229a | 97 | offset += sizeof(this->st_dimensions); |
Gary Servin |
0:04ac6be8229a | 98 | memcpy( &(this->dimensions[i]), &(this->st_dimensions), sizeof(double)); |
Gary Servin |
0:04ac6be8229a | 99 | } |
Gary Servin |
0:04ac6be8229a | 100 | return offset; |
Gary Servin |
0:04ac6be8229a | 101 | } |
Gary Servin |
0:04ac6be8229a | 102 | |
Gary Servin |
0:04ac6be8229a | 103 | const char * getType(){ return "shape_msgs/SolidPrimitive"; }; |
Gary Servin |
0:04ac6be8229a | 104 | const char * getMD5(){ return "d8f8cbc74c5ff283fca29569ccefb45d"; }; |
Gary Servin |
0:04ac6be8229a | 105 | |
Gary Servin |
0:04ac6be8229a | 106 | }; |
Gary Servin |
0:04ac6be8229a | 107 | |
Gary Servin |
0:04ac6be8229a | 108 | } |
Gary Servin |
0:04ac6be8229a | 109 | #endif |