complete motor
Dependencies: BufferedSerial motor_sn7544
rosserial_msgs/RequestMessageInfo.h@7:13dd93a0efe8, 2019-06-27 (annotated)
- Committer:
- Jeonghoon
- Date:
- Thu Jun 27 04:58:29 2019 +0000
- Revision:
- 7:13dd93a0efe8
combine motor with ROS
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jeonghoon | 7:13dd93a0efe8 | 1 | #ifndef _ROS_SERVICE_RequestMessageInfo_h |
Jeonghoon | 7:13dd93a0efe8 | 2 | #define _ROS_SERVICE_RequestMessageInfo_h |
Jeonghoon | 7:13dd93a0efe8 | 3 | #include <stdint.h> |
Jeonghoon | 7:13dd93a0efe8 | 4 | #include <string.h> |
Jeonghoon | 7:13dd93a0efe8 | 5 | #include <stdlib.h> |
Jeonghoon | 7:13dd93a0efe8 | 6 | #include "ros/msg.h" |
Jeonghoon | 7:13dd93a0efe8 | 7 | |
Jeonghoon | 7:13dd93a0efe8 | 8 | namespace rosserial_msgs |
Jeonghoon | 7:13dd93a0efe8 | 9 | { |
Jeonghoon | 7:13dd93a0efe8 | 10 | |
Jeonghoon | 7:13dd93a0efe8 | 11 | static const char REQUESTMESSAGEINFO[] = "rosserial_msgs/RequestMessageInfo"; |
Jeonghoon | 7:13dd93a0efe8 | 12 | |
Jeonghoon | 7:13dd93a0efe8 | 13 | class RequestMessageInfoRequest : public ros::Msg |
Jeonghoon | 7:13dd93a0efe8 | 14 | { |
Jeonghoon | 7:13dd93a0efe8 | 15 | public: |
Jeonghoon | 7:13dd93a0efe8 | 16 | typedef const char* _type_type; |
Jeonghoon | 7:13dd93a0efe8 | 17 | _type_type type; |
Jeonghoon | 7:13dd93a0efe8 | 18 | |
Jeonghoon | 7:13dd93a0efe8 | 19 | RequestMessageInfoRequest(): |
Jeonghoon | 7:13dd93a0efe8 | 20 | type("") |
Jeonghoon | 7:13dd93a0efe8 | 21 | { |
Jeonghoon | 7:13dd93a0efe8 | 22 | } |
Jeonghoon | 7:13dd93a0efe8 | 23 | |
Jeonghoon | 7:13dd93a0efe8 | 24 | virtual int serialize(unsigned char *outbuffer) const |
Jeonghoon | 7:13dd93a0efe8 | 25 | { |
Jeonghoon | 7:13dd93a0efe8 | 26 | int offset = 0; |
Jeonghoon | 7:13dd93a0efe8 | 27 | uint32_t length_type = strlen(this->type); |
Jeonghoon | 7:13dd93a0efe8 | 28 | varToArr(outbuffer + offset, length_type); |
Jeonghoon | 7:13dd93a0efe8 | 29 | offset += 4; |
Jeonghoon | 7:13dd93a0efe8 | 30 | memcpy(outbuffer + offset, this->type, length_type); |
Jeonghoon | 7:13dd93a0efe8 | 31 | offset += length_type; |
Jeonghoon | 7:13dd93a0efe8 | 32 | return offset; |
Jeonghoon | 7:13dd93a0efe8 | 33 | } |
Jeonghoon | 7:13dd93a0efe8 | 34 | |
Jeonghoon | 7:13dd93a0efe8 | 35 | virtual int deserialize(unsigned char *inbuffer) |
Jeonghoon | 7:13dd93a0efe8 | 36 | { |
Jeonghoon | 7:13dd93a0efe8 | 37 | int offset = 0; |
Jeonghoon | 7:13dd93a0efe8 | 38 | uint32_t length_type; |
Jeonghoon | 7:13dd93a0efe8 | 39 | arrToVar(length_type, (inbuffer + offset)); |
Jeonghoon | 7:13dd93a0efe8 | 40 | offset += 4; |
Jeonghoon | 7:13dd93a0efe8 | 41 | for(unsigned int k= offset; k< offset+length_type; ++k){ |
Jeonghoon | 7:13dd93a0efe8 | 42 | inbuffer[k-1]=inbuffer[k]; |
Jeonghoon | 7:13dd93a0efe8 | 43 | } |
Jeonghoon | 7:13dd93a0efe8 | 44 | inbuffer[offset+length_type-1]=0; |
Jeonghoon | 7:13dd93a0efe8 | 45 | this->type = (char *)(inbuffer + offset-1); |
Jeonghoon | 7:13dd93a0efe8 | 46 | offset += length_type; |
Jeonghoon | 7:13dd93a0efe8 | 47 | return offset; |
Jeonghoon | 7:13dd93a0efe8 | 48 | } |
Jeonghoon | 7:13dd93a0efe8 | 49 | |
Jeonghoon | 7:13dd93a0efe8 | 50 | const char * getType(){ return REQUESTMESSAGEINFO; }; |
Jeonghoon | 7:13dd93a0efe8 | 51 | const char * getMD5(){ return "dc67331de85cf97091b7d45e5c64ab75"; }; |
Jeonghoon | 7:13dd93a0efe8 | 52 | |
Jeonghoon | 7:13dd93a0efe8 | 53 | }; |
Jeonghoon | 7:13dd93a0efe8 | 54 | |
Jeonghoon | 7:13dd93a0efe8 | 55 | class RequestMessageInfoResponse : public ros::Msg |
Jeonghoon | 7:13dd93a0efe8 | 56 | { |
Jeonghoon | 7:13dd93a0efe8 | 57 | public: |
Jeonghoon | 7:13dd93a0efe8 | 58 | typedef const char* _md5_type; |
Jeonghoon | 7:13dd93a0efe8 | 59 | _md5_type md5; |
Jeonghoon | 7:13dd93a0efe8 | 60 | typedef const char* _definition_type; |
Jeonghoon | 7:13dd93a0efe8 | 61 | _definition_type definition; |
Jeonghoon | 7:13dd93a0efe8 | 62 | |
Jeonghoon | 7:13dd93a0efe8 | 63 | RequestMessageInfoResponse(): |
Jeonghoon | 7:13dd93a0efe8 | 64 | md5(""), |
Jeonghoon | 7:13dd93a0efe8 | 65 | definition("") |
Jeonghoon | 7:13dd93a0efe8 | 66 | { |
Jeonghoon | 7:13dd93a0efe8 | 67 | } |
Jeonghoon | 7:13dd93a0efe8 | 68 | |
Jeonghoon | 7:13dd93a0efe8 | 69 | virtual int serialize(unsigned char *outbuffer) const |
Jeonghoon | 7:13dd93a0efe8 | 70 | { |
Jeonghoon | 7:13dd93a0efe8 | 71 | int offset = 0; |
Jeonghoon | 7:13dd93a0efe8 | 72 | uint32_t length_md5 = strlen(this->md5); |
Jeonghoon | 7:13dd93a0efe8 | 73 | varToArr(outbuffer + offset, length_md5); |
Jeonghoon | 7:13dd93a0efe8 | 74 | offset += 4; |
Jeonghoon | 7:13dd93a0efe8 | 75 | memcpy(outbuffer + offset, this->md5, length_md5); |
Jeonghoon | 7:13dd93a0efe8 | 76 | offset += length_md5; |
Jeonghoon | 7:13dd93a0efe8 | 77 | uint32_t length_definition = strlen(this->definition); |
Jeonghoon | 7:13dd93a0efe8 | 78 | varToArr(outbuffer + offset, length_definition); |
Jeonghoon | 7:13dd93a0efe8 | 79 | offset += 4; |
Jeonghoon | 7:13dd93a0efe8 | 80 | memcpy(outbuffer + offset, this->definition, length_definition); |
Jeonghoon | 7:13dd93a0efe8 | 81 | offset += length_definition; |
Jeonghoon | 7:13dd93a0efe8 | 82 | return offset; |
Jeonghoon | 7:13dd93a0efe8 | 83 | } |
Jeonghoon | 7:13dd93a0efe8 | 84 | |
Jeonghoon | 7:13dd93a0efe8 | 85 | virtual int deserialize(unsigned char *inbuffer) |
Jeonghoon | 7:13dd93a0efe8 | 86 | { |
Jeonghoon | 7:13dd93a0efe8 | 87 | int offset = 0; |
Jeonghoon | 7:13dd93a0efe8 | 88 | uint32_t length_md5; |
Jeonghoon | 7:13dd93a0efe8 | 89 | arrToVar(length_md5, (inbuffer + offset)); |
Jeonghoon | 7:13dd93a0efe8 | 90 | offset += 4; |
Jeonghoon | 7:13dd93a0efe8 | 91 | for(unsigned int k= offset; k< offset+length_md5; ++k){ |
Jeonghoon | 7:13dd93a0efe8 | 92 | inbuffer[k-1]=inbuffer[k]; |
Jeonghoon | 7:13dd93a0efe8 | 93 | } |
Jeonghoon | 7:13dd93a0efe8 | 94 | inbuffer[offset+length_md5-1]=0; |
Jeonghoon | 7:13dd93a0efe8 | 95 | this->md5 = (char *)(inbuffer + offset-1); |
Jeonghoon | 7:13dd93a0efe8 | 96 | offset += length_md5; |
Jeonghoon | 7:13dd93a0efe8 | 97 | uint32_t length_definition; |
Jeonghoon | 7:13dd93a0efe8 | 98 | arrToVar(length_definition, (inbuffer + offset)); |
Jeonghoon | 7:13dd93a0efe8 | 99 | offset += 4; |
Jeonghoon | 7:13dd93a0efe8 | 100 | for(unsigned int k= offset; k< offset+length_definition; ++k){ |
Jeonghoon | 7:13dd93a0efe8 | 101 | inbuffer[k-1]=inbuffer[k]; |
Jeonghoon | 7:13dd93a0efe8 | 102 | } |
Jeonghoon | 7:13dd93a0efe8 | 103 | inbuffer[offset+length_definition-1]=0; |
Jeonghoon | 7:13dd93a0efe8 | 104 | this->definition = (char *)(inbuffer + offset-1); |
Jeonghoon | 7:13dd93a0efe8 | 105 | offset += length_definition; |
Jeonghoon | 7:13dd93a0efe8 | 106 | return offset; |
Jeonghoon | 7:13dd93a0efe8 | 107 | } |
Jeonghoon | 7:13dd93a0efe8 | 108 | |
Jeonghoon | 7:13dd93a0efe8 | 109 | const char * getType(){ return REQUESTMESSAGEINFO; }; |
Jeonghoon | 7:13dd93a0efe8 | 110 | const char * getMD5(){ return "fe452186a069bed40f09b8628fe5eac8"; }; |
Jeonghoon | 7:13dd93a0efe8 | 111 | |
Jeonghoon | 7:13dd93a0efe8 | 112 | }; |
Jeonghoon | 7:13dd93a0efe8 | 113 | |
Jeonghoon | 7:13dd93a0efe8 | 114 | class RequestMessageInfo { |
Jeonghoon | 7:13dd93a0efe8 | 115 | public: |
Jeonghoon | 7:13dd93a0efe8 | 116 | typedef RequestMessageInfoRequest Request; |
Jeonghoon | 7:13dd93a0efe8 | 117 | typedef RequestMessageInfoResponse Response; |
Jeonghoon | 7:13dd93a0efe8 | 118 | }; |
Jeonghoon | 7:13dd93a0efe8 | 119 | |
Jeonghoon | 7:13dd93a0efe8 | 120 | } |
Jeonghoon | 7:13dd93a0efe8 | 121 | #endif |