capstone_finish

Dependencies:   BufferedSerial motor_sn7544

Committer:
Jeonghoon
Date:
Tue Aug 13 05:53:22 2019 +0000
Revision:
3:2a3664dc6634
with ROS;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jeonghoon 3:2a3664dc6634 1 #ifndef _ROS_std_msgs_MultiArrayDimension_h
Jeonghoon 3:2a3664dc6634 2 #define _ROS_std_msgs_MultiArrayDimension_h
Jeonghoon 3:2a3664dc6634 3
Jeonghoon 3:2a3664dc6634 4 #include <stdint.h>
Jeonghoon 3:2a3664dc6634 5 #include <string.h>
Jeonghoon 3:2a3664dc6634 6 #include <stdlib.h>
Jeonghoon 3:2a3664dc6634 7 #include "ros/msg.h"
Jeonghoon 3:2a3664dc6634 8
Jeonghoon 3:2a3664dc6634 9 namespace std_msgs
Jeonghoon 3:2a3664dc6634 10 {
Jeonghoon 3:2a3664dc6634 11
Jeonghoon 3:2a3664dc6634 12 class MultiArrayDimension : public ros::Msg
Jeonghoon 3:2a3664dc6634 13 {
Jeonghoon 3:2a3664dc6634 14 public:
Jeonghoon 3:2a3664dc6634 15 typedef const char* _label_type;
Jeonghoon 3:2a3664dc6634 16 _label_type label;
Jeonghoon 3:2a3664dc6634 17 typedef uint32_t _size_type;
Jeonghoon 3:2a3664dc6634 18 _size_type size;
Jeonghoon 3:2a3664dc6634 19 typedef uint32_t _stride_type;
Jeonghoon 3:2a3664dc6634 20 _stride_type stride;
Jeonghoon 3:2a3664dc6634 21
Jeonghoon 3:2a3664dc6634 22 MultiArrayDimension():
Jeonghoon 3:2a3664dc6634 23 label(""),
Jeonghoon 3:2a3664dc6634 24 size(0),
Jeonghoon 3:2a3664dc6634 25 stride(0)
Jeonghoon 3:2a3664dc6634 26 {
Jeonghoon 3:2a3664dc6634 27 }
Jeonghoon 3:2a3664dc6634 28
Jeonghoon 3:2a3664dc6634 29 virtual int serialize(unsigned char *outbuffer) const
Jeonghoon 3:2a3664dc6634 30 {
Jeonghoon 3:2a3664dc6634 31 int offset = 0;
Jeonghoon 3:2a3664dc6634 32 uint32_t length_label = strlen(this->label);
Jeonghoon 3:2a3664dc6634 33 varToArr(outbuffer + offset, length_label);
Jeonghoon 3:2a3664dc6634 34 offset += 4;
Jeonghoon 3:2a3664dc6634 35 memcpy(outbuffer + offset, this->label, length_label);
Jeonghoon 3:2a3664dc6634 36 offset += length_label;
Jeonghoon 3:2a3664dc6634 37 *(outbuffer + offset + 0) = (this->size >> (8 * 0)) & 0xFF;
Jeonghoon 3:2a3664dc6634 38 *(outbuffer + offset + 1) = (this->size >> (8 * 1)) & 0xFF;
Jeonghoon 3:2a3664dc6634 39 *(outbuffer + offset + 2) = (this->size >> (8 * 2)) & 0xFF;
Jeonghoon 3:2a3664dc6634 40 *(outbuffer + offset + 3) = (this->size >> (8 * 3)) & 0xFF;
Jeonghoon 3:2a3664dc6634 41 offset += sizeof(this->size);
Jeonghoon 3:2a3664dc6634 42 *(outbuffer + offset + 0) = (this->stride >> (8 * 0)) & 0xFF;
Jeonghoon 3:2a3664dc6634 43 *(outbuffer + offset + 1) = (this->stride >> (8 * 1)) & 0xFF;
Jeonghoon 3:2a3664dc6634 44 *(outbuffer + offset + 2) = (this->stride >> (8 * 2)) & 0xFF;
Jeonghoon 3:2a3664dc6634 45 *(outbuffer + offset + 3) = (this->stride >> (8 * 3)) & 0xFF;
Jeonghoon 3:2a3664dc6634 46 offset += sizeof(this->stride);
Jeonghoon 3:2a3664dc6634 47 return offset;
Jeonghoon 3:2a3664dc6634 48 }
Jeonghoon 3:2a3664dc6634 49
Jeonghoon 3:2a3664dc6634 50 virtual int deserialize(unsigned char *inbuffer)
Jeonghoon 3:2a3664dc6634 51 {
Jeonghoon 3:2a3664dc6634 52 int offset = 0;
Jeonghoon 3:2a3664dc6634 53 uint32_t length_label;
Jeonghoon 3:2a3664dc6634 54 arrToVar(length_label, (inbuffer + offset));
Jeonghoon 3:2a3664dc6634 55 offset += 4;
Jeonghoon 3:2a3664dc6634 56 for(unsigned int k= offset; k< offset+length_label; ++k){
Jeonghoon 3:2a3664dc6634 57 inbuffer[k-1]=inbuffer[k];
Jeonghoon 3:2a3664dc6634 58 }
Jeonghoon 3:2a3664dc6634 59 inbuffer[offset+length_label-1]=0;
Jeonghoon 3:2a3664dc6634 60 this->label = (char *)(inbuffer + offset-1);
Jeonghoon 3:2a3664dc6634 61 offset += length_label;
Jeonghoon 3:2a3664dc6634 62 this->size = ((uint32_t) (*(inbuffer + offset)));
Jeonghoon 3:2a3664dc6634 63 this->size |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Jeonghoon 3:2a3664dc6634 64 this->size |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Jeonghoon 3:2a3664dc6634 65 this->size |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Jeonghoon 3:2a3664dc6634 66 offset += sizeof(this->size);
Jeonghoon 3:2a3664dc6634 67 this->stride = ((uint32_t) (*(inbuffer + offset)));
Jeonghoon 3:2a3664dc6634 68 this->stride |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Jeonghoon 3:2a3664dc6634 69 this->stride |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Jeonghoon 3:2a3664dc6634 70 this->stride |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Jeonghoon 3:2a3664dc6634 71 offset += sizeof(this->stride);
Jeonghoon 3:2a3664dc6634 72 return offset;
Jeonghoon 3:2a3664dc6634 73 }
Jeonghoon 3:2a3664dc6634 74
Jeonghoon 3:2a3664dc6634 75 const char * getType(){ return "std_msgs/MultiArrayDimension"; };
Jeonghoon 3:2a3664dc6634 76 const char * getMD5(){ return "4cd0c83a8683deae40ecdac60e53bfa8"; };
Jeonghoon 3:2a3664dc6634 77
Jeonghoon 3:2a3664dc6634 78 };
Jeonghoon 3:2a3664dc6634 79
Jeonghoon 3:2a3664dc6634 80 }
Jeonghoon 3:2a3664dc6634 81 #endif