rosserial library for mbed Inspired by nucho's rosserial library This library is still under development
Dependents: mbed_roshydro_test
Library still under development!
shape_msgs/Mesh.h@0:30537dec6e0b, 2015-02-15 (annotated)
- Committer:
- akashvibhute
- Date:
- Sun Feb 15 10:53:43 2015 +0000
- Revision:
- 0:30537dec6e0b
First commit; Library still need to be debugged, compilation issues with new mbed and modserial updates.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
akashvibhute | 0:30537dec6e0b | 1 | #ifndef _ROS_shape_msgs_Mesh_h |
akashvibhute | 0:30537dec6e0b | 2 | #define _ROS_shape_msgs_Mesh_h |
akashvibhute | 0:30537dec6e0b | 3 | |
akashvibhute | 0:30537dec6e0b | 4 | #include <stdint.h> |
akashvibhute | 0:30537dec6e0b | 5 | #include <string.h> |
akashvibhute | 0:30537dec6e0b | 6 | #include <stdlib.h> |
akashvibhute | 0:30537dec6e0b | 7 | #include "ros/msg.h" |
akashvibhute | 0:30537dec6e0b | 8 | #include "shape_msgs/MeshTriangle.h" |
akashvibhute | 0:30537dec6e0b | 9 | #include "geometry_msgs/Point.h" |
akashvibhute | 0:30537dec6e0b | 10 | |
akashvibhute | 0:30537dec6e0b | 11 | namespace shape_msgs |
akashvibhute | 0:30537dec6e0b | 12 | { |
akashvibhute | 0:30537dec6e0b | 13 | |
akashvibhute | 0:30537dec6e0b | 14 | class Mesh : public ros::Msg |
akashvibhute | 0:30537dec6e0b | 15 | { |
akashvibhute | 0:30537dec6e0b | 16 | public: |
akashvibhute | 0:30537dec6e0b | 17 | uint8_t triangles_length; |
akashvibhute | 0:30537dec6e0b | 18 | shape_msgs::MeshTriangle st_triangles; |
akashvibhute | 0:30537dec6e0b | 19 | shape_msgs::MeshTriangle * triangles; |
akashvibhute | 0:30537dec6e0b | 20 | uint8_t vertices_length; |
akashvibhute | 0:30537dec6e0b | 21 | geometry_msgs::Point st_vertices; |
akashvibhute | 0:30537dec6e0b | 22 | geometry_msgs::Point * vertices; |
akashvibhute | 0:30537dec6e0b | 23 | |
akashvibhute | 0:30537dec6e0b | 24 | Mesh(): |
akashvibhute | 0:30537dec6e0b | 25 | triangles_length(0), triangles(NULL), |
akashvibhute | 0:30537dec6e0b | 26 | vertices_length(0), vertices(NULL) |
akashvibhute | 0:30537dec6e0b | 27 | { |
akashvibhute | 0:30537dec6e0b | 28 | } |
akashvibhute | 0:30537dec6e0b | 29 | |
akashvibhute | 0:30537dec6e0b | 30 | virtual int serialize(unsigned char *outbuffer) const |
akashvibhute | 0:30537dec6e0b | 31 | { |
akashvibhute | 0:30537dec6e0b | 32 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 33 | *(outbuffer + offset++) = triangles_length; |
akashvibhute | 0:30537dec6e0b | 34 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 35 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 36 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 37 | for( uint8_t i = 0; i < triangles_length; i++){ |
akashvibhute | 0:30537dec6e0b | 38 | offset += this->triangles[i].serialize(outbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 39 | } |
akashvibhute | 0:30537dec6e0b | 40 | *(outbuffer + offset++) = vertices_length; |
akashvibhute | 0:30537dec6e0b | 41 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 42 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 43 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 44 | for( uint8_t i = 0; i < vertices_length; i++){ |
akashvibhute | 0:30537dec6e0b | 45 | offset += this->vertices[i].serialize(outbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 46 | } |
akashvibhute | 0:30537dec6e0b | 47 | return offset; |
akashvibhute | 0:30537dec6e0b | 48 | } |
akashvibhute | 0:30537dec6e0b | 49 | |
akashvibhute | 0:30537dec6e0b | 50 | virtual int deserialize(unsigned char *inbuffer) |
akashvibhute | 0:30537dec6e0b | 51 | { |
akashvibhute | 0:30537dec6e0b | 52 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 53 | uint8_t triangles_lengthT = *(inbuffer + offset++); |
akashvibhute | 0:30537dec6e0b | 54 | if(triangles_lengthT > triangles_length) |
akashvibhute | 0:30537dec6e0b | 55 | this->triangles = (shape_msgs::MeshTriangle*)realloc(this->triangles, triangles_lengthT * sizeof(shape_msgs::MeshTriangle)); |
akashvibhute | 0:30537dec6e0b | 56 | offset += 3; |
akashvibhute | 0:30537dec6e0b | 57 | triangles_length = triangles_lengthT; |
akashvibhute | 0:30537dec6e0b | 58 | for( uint8_t i = 0; i < triangles_length; i++){ |
akashvibhute | 0:30537dec6e0b | 59 | offset += this->st_triangles.deserialize(inbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 60 | memcpy( &(this->triangles[i]), &(this->st_triangles), sizeof(shape_msgs::MeshTriangle)); |
akashvibhute | 0:30537dec6e0b | 61 | } |
akashvibhute | 0:30537dec6e0b | 62 | uint8_t vertices_lengthT = *(inbuffer + offset++); |
akashvibhute | 0:30537dec6e0b | 63 | if(vertices_lengthT > vertices_length) |
akashvibhute | 0:30537dec6e0b | 64 | this->vertices = (geometry_msgs::Point*)realloc(this->vertices, vertices_lengthT * sizeof(geometry_msgs::Point)); |
akashvibhute | 0:30537dec6e0b | 65 | offset += 3; |
akashvibhute | 0:30537dec6e0b | 66 | vertices_length = vertices_lengthT; |
akashvibhute | 0:30537dec6e0b | 67 | for( uint8_t i = 0; i < vertices_length; i++){ |
akashvibhute | 0:30537dec6e0b | 68 | offset += this->st_vertices.deserialize(inbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 69 | memcpy( &(this->vertices[i]), &(this->st_vertices), sizeof(geometry_msgs::Point)); |
akashvibhute | 0:30537dec6e0b | 70 | } |
akashvibhute | 0:30537dec6e0b | 71 | return offset; |
akashvibhute | 0:30537dec6e0b | 72 | } |
akashvibhute | 0:30537dec6e0b | 73 | |
akashvibhute | 0:30537dec6e0b | 74 | const char * getType(){ return "shape_msgs/Mesh"; }; |
akashvibhute | 0:30537dec6e0b | 75 | const char * getMD5(){ return "1ffdae9486cd3316a121c578b47a85cc"; }; |
akashvibhute | 0:30537dec6e0b | 76 | |
akashvibhute | 0:30537dec6e0b | 77 | }; |
akashvibhute | 0:30537dec6e0b | 78 | |
akashvibhute | 0:30537dec6e0b | 79 | } |
akashvibhute | 0:30537dec6e0b | 80 | #endif |