rosserial for Hydro
Fork of rosserial_mbed_lib by
geometry_msgs/Polygon.h@0:77afd7560544, 2011-08-19 (annotated)
- Committer:
- nucho
- Date:
- Fri Aug 19 09:06:30 2011 +0000
- Revision:
- 0:77afd7560544
- Child:
- 1:ff0ec969dad1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nucho | 0:77afd7560544 | 1 | #ifndef ros_Polygon_h |
nucho | 0:77afd7560544 | 2 | #define ros_Polygon_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 | 0:77afd7560544 | 7 | #include "../ros/msg.h" |
nucho | 0:77afd7560544 | 8 | #include "geometry_msgs/Point32.h" |
nucho | 0:77afd7560544 | 9 | |
nucho | 0:77afd7560544 | 10 | namespace geometry_msgs |
nucho | 0:77afd7560544 | 11 | { |
nucho | 0:77afd7560544 | 12 | |
nucho | 0:77afd7560544 | 13 | class Polygon : public ros::Msg |
nucho | 0:77afd7560544 | 14 | { |
nucho | 0:77afd7560544 | 15 | public: |
nucho | 0:77afd7560544 | 16 | unsigned char points_length; |
nucho | 0:77afd7560544 | 17 | geometry_msgs::Point32 st_points; |
nucho | 0:77afd7560544 | 18 | geometry_msgs::Point32 * points; |
nucho | 0:77afd7560544 | 19 | |
nucho | 0:77afd7560544 | 20 | virtual int serialize(unsigned char *outbuffer) |
nucho | 0:77afd7560544 | 21 | { |
nucho | 0:77afd7560544 | 22 | int offset = 0; |
nucho | 0:77afd7560544 | 23 | *(outbuffer + offset++) = points_length; |
nucho | 0:77afd7560544 | 24 | *(outbuffer + offset++) = 0; |
nucho | 0:77afd7560544 | 25 | *(outbuffer + offset++) = 0; |
nucho | 0:77afd7560544 | 26 | *(outbuffer + offset++) = 0; |
nucho | 0:77afd7560544 | 27 | for( unsigned char i = 0; i < points_length; i++){ |
nucho | 0:77afd7560544 | 28 | offset += this->points[i].serialize(outbuffer + offset); |
nucho | 0:77afd7560544 | 29 | } |
nucho | 0:77afd7560544 | 30 | return offset; |
nucho | 0:77afd7560544 | 31 | } |
nucho | 0:77afd7560544 | 32 | |
nucho | 0:77afd7560544 | 33 | virtual int deserialize(unsigned char *inbuffer) |
nucho | 0:77afd7560544 | 34 | { |
nucho | 0:77afd7560544 | 35 | int offset = 0; |
nucho | 0:77afd7560544 | 36 | unsigned char points_lengthT = *(inbuffer + offset++); |
nucho | 0:77afd7560544 | 37 | if(points_lengthT > points_length) |
nucho | 0:77afd7560544 | 38 | this->points = (geometry_msgs::Point32*)realloc(this->points, points_lengthT * sizeof(geometry_msgs::Point32)); |
nucho | 0:77afd7560544 | 39 | offset += 3; |
nucho | 0:77afd7560544 | 40 | points_length = points_lengthT; |
nucho | 0:77afd7560544 | 41 | for( unsigned char i = 0; i < points_length; i++){ |
nucho | 0:77afd7560544 | 42 | offset += this->st_points.deserialize(inbuffer + offset); |
nucho | 0:77afd7560544 | 43 | memcpy( &(this->points[i]), &(this->st_points), sizeof(geometry_msgs::Point32)); |
nucho | 0:77afd7560544 | 44 | } |
nucho | 0:77afd7560544 | 45 | return offset; |
nucho | 0:77afd7560544 | 46 | } |
nucho | 0:77afd7560544 | 47 | |
nucho | 0:77afd7560544 | 48 | virtual const char * getType(){ return "geometry_msgs/Polygon"; }; |
nucho | 0:77afd7560544 | 49 | |
nucho | 0:77afd7560544 | 50 | }; |
nucho | 0:77afd7560544 | 51 | |
nucho | 0:77afd7560544 | 52 | } |
nucho | 0:77afd7560544 | 53 | #endif |