This program is porting rosserial_arduino for mbed http://www.ros.org/wiki/rosserial_arduino This program supported the revision of 169 of rosserial.

Dependencies:  

Dependents:   rosserial_mbed robot_S2

Committer:
nucho
Date:
Sun Oct 16 07:19:36 2011 +0000
Revision:
1:ff0ec969dad1
Parent:
0:77afd7560544
Child:
3:1cf99502f396
This program supported the revision of 143 of rosserial.
And the bug fix of receive of array data.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nucho 1:ff0ec969dad1 1 #ifndef ros_geometry_msgs_Polygon_h
nucho 1:ff0ec969dad1 2 #define ros_geometry_msgs_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 1:ff0ec969dad1 10 namespace geometry_msgs {
nucho 0:77afd7560544 11
nucho 1:ff0ec969dad1 12 class Polygon : public ros::Msg {
nucho 1:ff0ec969dad1 13 public:
nucho 1:ff0ec969dad1 14 unsigned char points_length;
nucho 1:ff0ec969dad1 15 geometry_msgs::Point32 st_points;
nucho 1:ff0ec969dad1 16 geometry_msgs::Point32 * points;
nucho 0:77afd7560544 17
nucho 1:ff0ec969dad1 18 virtual int serialize(unsigned char *outbuffer) {
nucho 1:ff0ec969dad1 19 int offset = 0;
nucho 1:ff0ec969dad1 20 *(outbuffer + offset++) = points_length;
nucho 1:ff0ec969dad1 21 *(outbuffer + offset++) = 0;
nucho 1:ff0ec969dad1 22 *(outbuffer + offset++) = 0;
nucho 1:ff0ec969dad1 23 *(outbuffer + offset++) = 0;
nucho 1:ff0ec969dad1 24 for ( unsigned char i = 0; i < points_length; i++) {
nucho 1:ff0ec969dad1 25 offset += this->points[i].serialize(outbuffer + offset);
nucho 1:ff0ec969dad1 26 }
nucho 1:ff0ec969dad1 27 return offset;
nucho 0:77afd7560544 28 }
nucho 0:77afd7560544 29
nucho 1:ff0ec969dad1 30 virtual int deserialize(unsigned char *inbuffer) {
nucho 1:ff0ec969dad1 31 int offset = 0;
nucho 1:ff0ec969dad1 32 unsigned char points_lengthT = *(inbuffer + offset++);
nucho 1:ff0ec969dad1 33 if (points_lengthT > points_length)
nucho 1:ff0ec969dad1 34 this->points = (geometry_msgs::Point32*)realloc(this->points, points_lengthT * sizeof(geometry_msgs::Point32));
nucho 1:ff0ec969dad1 35 offset += 3;
nucho 1:ff0ec969dad1 36 points_length = points_lengthT;
nucho 1:ff0ec969dad1 37 for ( unsigned char i = 0; i < points_length; i++) {
nucho 1:ff0ec969dad1 38 offset += this->st_points.deserialize(inbuffer + offset);
nucho 1:ff0ec969dad1 39 memcpy( &(this->points[i]), &(this->st_points), sizeof(geometry_msgs::Point32));
nucho 1:ff0ec969dad1 40 }
nucho 1:ff0ec969dad1 41 return offset;
nucho 0:77afd7560544 42 }
nucho 0:77afd7560544 43
nucho 1:ff0ec969dad1 44 virtual const char * getType() {
nucho 1:ff0ec969dad1 45 return "geometry_msgs/Polygon";
nucho 1:ff0ec969dad1 46 };
nucho 0:77afd7560544 47
nucho 1:ff0ec969dad1 48 };
nucho 0:77afd7560544 49
nucho 0:77afd7560544 50 }
nucho 0:77afd7560544 51 #endif