hairo
Dependencies: mbed BufferedSerial
shape_msgs/Mesh.h@4:bcdd99711326, 2018-12-04 (annotated)
- Committer:
- tknara
- Date:
- Tue Dec 04 00:14:32 2018 +0000
- Revision:
- 4:bcdd99711326
- Parent:
- 0:9e9b7db60fd5
test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
garyservin | 0:9e9b7db60fd5 | 1 | #ifndef _ROS_shape_msgs_Mesh_h |
garyservin | 0:9e9b7db60fd5 | 2 | #define _ROS_shape_msgs_Mesh_h |
garyservin | 0:9e9b7db60fd5 | 3 | |
garyservin | 0:9e9b7db60fd5 | 4 | #include <stdint.h> |
garyservin | 0:9e9b7db60fd5 | 5 | #include <string.h> |
garyservin | 0:9e9b7db60fd5 | 6 | #include <stdlib.h> |
garyservin | 0:9e9b7db60fd5 | 7 | #include "ros/msg.h" |
garyservin | 0:9e9b7db60fd5 | 8 | #include "shape_msgs/MeshTriangle.h" |
garyservin | 0:9e9b7db60fd5 | 9 | #include "geometry_msgs/Point.h" |
garyservin | 0:9e9b7db60fd5 | 10 | |
garyservin | 0:9e9b7db60fd5 | 11 | namespace shape_msgs |
garyservin | 0:9e9b7db60fd5 | 12 | { |
garyservin | 0:9e9b7db60fd5 | 13 | |
garyservin | 0:9e9b7db60fd5 | 14 | class Mesh : public ros::Msg |
garyservin | 0:9e9b7db60fd5 | 15 | { |
garyservin | 0:9e9b7db60fd5 | 16 | public: |
garyservin | 0:9e9b7db60fd5 | 17 | uint32_t triangles_length; |
garyservin | 0:9e9b7db60fd5 | 18 | typedef shape_msgs::MeshTriangle _triangles_type; |
garyservin | 0:9e9b7db60fd5 | 19 | _triangles_type st_triangles; |
garyservin | 0:9e9b7db60fd5 | 20 | _triangles_type * triangles; |
garyservin | 0:9e9b7db60fd5 | 21 | uint32_t vertices_length; |
garyservin | 0:9e9b7db60fd5 | 22 | typedef geometry_msgs::Point _vertices_type; |
garyservin | 0:9e9b7db60fd5 | 23 | _vertices_type st_vertices; |
garyservin | 0:9e9b7db60fd5 | 24 | _vertices_type * vertices; |
garyservin | 0:9e9b7db60fd5 | 25 | |
garyservin | 0:9e9b7db60fd5 | 26 | Mesh(): |
garyservin | 0:9e9b7db60fd5 | 27 | triangles_length(0), triangles(NULL), |
garyservin | 0:9e9b7db60fd5 | 28 | vertices_length(0), vertices(NULL) |
garyservin | 0:9e9b7db60fd5 | 29 | { |
garyservin | 0:9e9b7db60fd5 | 30 | } |
garyservin | 0:9e9b7db60fd5 | 31 | |
garyservin | 0:9e9b7db60fd5 | 32 | virtual int serialize(unsigned char *outbuffer) const |
garyservin | 0:9e9b7db60fd5 | 33 | { |
garyservin | 0:9e9b7db60fd5 | 34 | int offset = 0; |
garyservin | 0:9e9b7db60fd5 | 35 | *(outbuffer + offset + 0) = (this->triangles_length >> (8 * 0)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 36 | *(outbuffer + offset + 1) = (this->triangles_length >> (8 * 1)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 37 | *(outbuffer + offset + 2) = (this->triangles_length >> (8 * 2)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 38 | *(outbuffer + offset + 3) = (this->triangles_length >> (8 * 3)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 39 | offset += sizeof(this->triangles_length); |
garyservin | 0:9e9b7db60fd5 | 40 | for( uint32_t i = 0; i < triangles_length; i++){ |
garyservin | 0:9e9b7db60fd5 | 41 | offset += this->triangles[i].serialize(outbuffer + offset); |
garyservin | 0:9e9b7db60fd5 | 42 | } |
garyservin | 0:9e9b7db60fd5 | 43 | *(outbuffer + offset + 0) = (this->vertices_length >> (8 * 0)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 44 | *(outbuffer + offset + 1) = (this->vertices_length >> (8 * 1)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 45 | *(outbuffer + offset + 2) = (this->vertices_length >> (8 * 2)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 46 | *(outbuffer + offset + 3) = (this->vertices_length >> (8 * 3)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 47 | offset += sizeof(this->vertices_length); |
garyservin | 0:9e9b7db60fd5 | 48 | for( uint32_t i = 0; i < vertices_length; i++){ |
garyservin | 0:9e9b7db60fd5 | 49 | offset += this->vertices[i].serialize(outbuffer + offset); |
garyservin | 0:9e9b7db60fd5 | 50 | } |
garyservin | 0:9e9b7db60fd5 | 51 | return offset; |
garyservin | 0:9e9b7db60fd5 | 52 | } |
garyservin | 0:9e9b7db60fd5 | 53 | |
garyservin | 0:9e9b7db60fd5 | 54 | virtual int deserialize(unsigned char *inbuffer) |
garyservin | 0:9e9b7db60fd5 | 55 | { |
garyservin | 0:9e9b7db60fd5 | 56 | int offset = 0; |
garyservin | 0:9e9b7db60fd5 | 57 | uint32_t triangles_lengthT = ((uint32_t) (*(inbuffer + offset))); |
garyservin | 0:9e9b7db60fd5 | 58 | triangles_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:9e9b7db60fd5 | 59 | triangles_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:9e9b7db60fd5 | 60 | triangles_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:9e9b7db60fd5 | 61 | offset += sizeof(this->triangles_length); |
garyservin | 0:9e9b7db60fd5 | 62 | if(triangles_lengthT > triangles_length) |
garyservin | 0:9e9b7db60fd5 | 63 | this->triangles = (shape_msgs::MeshTriangle*)realloc(this->triangles, triangles_lengthT * sizeof(shape_msgs::MeshTriangle)); |
garyservin | 0:9e9b7db60fd5 | 64 | triangles_length = triangles_lengthT; |
garyservin | 0:9e9b7db60fd5 | 65 | for( uint32_t i = 0; i < triangles_length; i++){ |
garyservin | 0:9e9b7db60fd5 | 66 | offset += this->st_triangles.deserialize(inbuffer + offset); |
garyservin | 0:9e9b7db60fd5 | 67 | memcpy( &(this->triangles[i]), &(this->st_triangles), sizeof(shape_msgs::MeshTriangle)); |
garyservin | 0:9e9b7db60fd5 | 68 | } |
garyservin | 0:9e9b7db60fd5 | 69 | uint32_t vertices_lengthT = ((uint32_t) (*(inbuffer + offset))); |
garyservin | 0:9e9b7db60fd5 | 70 | vertices_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:9e9b7db60fd5 | 71 | vertices_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:9e9b7db60fd5 | 72 | vertices_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:9e9b7db60fd5 | 73 | offset += sizeof(this->vertices_length); |
garyservin | 0:9e9b7db60fd5 | 74 | if(vertices_lengthT > vertices_length) |
garyservin | 0:9e9b7db60fd5 | 75 | this->vertices = (geometry_msgs::Point*)realloc(this->vertices, vertices_lengthT * sizeof(geometry_msgs::Point)); |
garyservin | 0:9e9b7db60fd5 | 76 | vertices_length = vertices_lengthT; |
garyservin | 0:9e9b7db60fd5 | 77 | for( uint32_t i = 0; i < vertices_length; i++){ |
garyservin | 0:9e9b7db60fd5 | 78 | offset += this->st_vertices.deserialize(inbuffer + offset); |
garyservin | 0:9e9b7db60fd5 | 79 | memcpy( &(this->vertices[i]), &(this->st_vertices), sizeof(geometry_msgs::Point)); |
garyservin | 0:9e9b7db60fd5 | 80 | } |
garyservin | 0:9e9b7db60fd5 | 81 | return offset; |
garyservin | 0:9e9b7db60fd5 | 82 | } |
garyservin | 0:9e9b7db60fd5 | 83 | |
garyservin | 0:9e9b7db60fd5 | 84 | const char * getType(){ return "shape_msgs/Mesh"; }; |
garyservin | 0:9e9b7db60fd5 | 85 | const char * getMD5(){ return "1ffdae9486cd3316a121c578b47a85cc"; }; |
garyservin | 0:9e9b7db60fd5 | 86 | |
garyservin | 0:9e9b7db60fd5 | 87 | }; |
garyservin | 0:9e9b7db60fd5 | 88 | |
garyservin | 0:9e9b7db60fd5 | 89 | } |
garyservin | 0:9e9b7db60fd5 | 90 | #endif |