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