complete motor

Dependencies:   BufferedSerial motor_sn7544

Committer:
Jeonghoon
Date:
Thu Nov 21 11:39:20 2019 +0000
Revision:
13:3ac8d2472417
Parent:
11:2228e8931266
complete motor

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jeonghoon 11:2228e8931266 1 #ifndef _ROS_geometry_msgs_Polygon_h
Jeonghoon 11:2228e8931266 2 #define _ROS_geometry_msgs_Polygon_h
Jeonghoon 11:2228e8931266 3
Jeonghoon 11:2228e8931266 4 #include <stdint.h>
Jeonghoon 11:2228e8931266 5 #include <string.h>
Jeonghoon 11:2228e8931266 6 #include <stdlib.h>
Jeonghoon 11:2228e8931266 7 #include "ros/msg.h"
Jeonghoon 11:2228e8931266 8 #include "geometry_msgs/Point32.h"
Jeonghoon 11:2228e8931266 9
Jeonghoon 11:2228e8931266 10 namespace geometry_msgs
Jeonghoon 11:2228e8931266 11 {
Jeonghoon 11:2228e8931266 12
Jeonghoon 11:2228e8931266 13 class Polygon : public ros::Msg
Jeonghoon 11:2228e8931266 14 {
Jeonghoon 11:2228e8931266 15 public:
Jeonghoon 11:2228e8931266 16 uint32_t points_length;
Jeonghoon 11:2228e8931266 17 typedef geometry_msgs::Point32 _points_type;
Jeonghoon 11:2228e8931266 18 _points_type st_points;
Jeonghoon 11:2228e8931266 19 _points_type * points;
Jeonghoon 11:2228e8931266 20
Jeonghoon 11:2228e8931266 21 Polygon():
Jeonghoon 11:2228e8931266 22 points_length(0), points(NULL)
Jeonghoon 11:2228e8931266 23 {
Jeonghoon 11:2228e8931266 24 }
Jeonghoon 11:2228e8931266 25
Jeonghoon 11:2228e8931266 26 virtual int serialize(unsigned char *outbuffer) const
Jeonghoon 11:2228e8931266 27 {
Jeonghoon 11:2228e8931266 28 int offset = 0;
Jeonghoon 11:2228e8931266 29 *(outbuffer + offset + 0) = (this->points_length >> (8 * 0)) & 0xFF;
Jeonghoon 11:2228e8931266 30 *(outbuffer + offset + 1) = (this->points_length >> (8 * 1)) & 0xFF;
Jeonghoon 11:2228e8931266 31 *(outbuffer + offset + 2) = (this->points_length >> (8 * 2)) & 0xFF;
Jeonghoon 11:2228e8931266 32 *(outbuffer + offset + 3) = (this->points_length >> (8 * 3)) & 0xFF;
Jeonghoon 11:2228e8931266 33 offset += sizeof(this->points_length);
Jeonghoon 11:2228e8931266 34 for( uint32_t i = 0; i < points_length; i++){
Jeonghoon 11:2228e8931266 35 offset += this->points[i].serialize(outbuffer + offset);
Jeonghoon 11:2228e8931266 36 }
Jeonghoon 11:2228e8931266 37 return offset;
Jeonghoon 11:2228e8931266 38 }
Jeonghoon 11:2228e8931266 39
Jeonghoon 11:2228e8931266 40 virtual int deserialize(unsigned char *inbuffer)
Jeonghoon 11:2228e8931266 41 {
Jeonghoon 11:2228e8931266 42 int offset = 0;
Jeonghoon 11:2228e8931266 43 uint32_t points_lengthT = ((uint32_t) (*(inbuffer + offset)));
Jeonghoon 11:2228e8931266 44 points_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Jeonghoon 11:2228e8931266 45 points_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Jeonghoon 11:2228e8931266 46 points_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Jeonghoon 11:2228e8931266 47 offset += sizeof(this->points_length);
Jeonghoon 11:2228e8931266 48 if(points_lengthT > points_length)
Jeonghoon 11:2228e8931266 49 this->points = (geometry_msgs::Point32*)realloc(this->points, points_lengthT * sizeof(geometry_msgs::Point32));
Jeonghoon 11:2228e8931266 50 points_length = points_lengthT;
Jeonghoon 11:2228e8931266 51 for( uint32_t i = 0; i < points_length; i++){
Jeonghoon 11:2228e8931266 52 offset += this->st_points.deserialize(inbuffer + offset);
Jeonghoon 11:2228e8931266 53 memcpy( &(this->points[i]), &(this->st_points), sizeof(geometry_msgs::Point32));
Jeonghoon 11:2228e8931266 54 }
Jeonghoon 11:2228e8931266 55 return offset;
Jeonghoon 11:2228e8931266 56 }
Jeonghoon 11:2228e8931266 57
Jeonghoon 11:2228e8931266 58 const char * getType(){ return "geometry_msgs/Polygon"; };
Jeonghoon 11:2228e8931266 59 const char * getMD5(){ return "cd60a26494a087f577976f0329fa120e"; };
Jeonghoon 11:2228e8931266 60
Jeonghoon 11:2228e8931266 61 };
Jeonghoon 11:2228e8931266 62
Jeonghoon 11:2228e8931266 63 }
Jeonghoon 11:2228e8931266 64 #endif