complete motor
Dependencies: BufferedSerial motor_sn7544
std_msgs/String.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_String_h |
Jeonghoon | 7:13dd93a0efe8 | 2 | #define _ROS_std_msgs_String_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 String : public ros::Msg |
Jeonghoon | 7:13dd93a0efe8 | 13 | { |
Jeonghoon | 7:13dd93a0efe8 | 14 | public: |
Jeonghoon | 7:13dd93a0efe8 | 15 | typedef const char* _data_type; |
Jeonghoon | 7:13dd93a0efe8 | 16 | _data_type data; |
Jeonghoon | 7:13dd93a0efe8 | 17 | |
Jeonghoon | 7:13dd93a0efe8 | 18 | String(): |
Jeonghoon | 7:13dd93a0efe8 | 19 | data("") |
Jeonghoon | 7:13dd93a0efe8 | 20 | { |
Jeonghoon | 7:13dd93a0efe8 | 21 | } |
Jeonghoon | 7:13dd93a0efe8 | 22 | |
Jeonghoon | 7:13dd93a0efe8 | 23 | virtual int serialize(unsigned char *outbuffer) const |
Jeonghoon | 7:13dd93a0efe8 | 24 | { |
Jeonghoon | 7:13dd93a0efe8 | 25 | int offset = 0; |
Jeonghoon | 7:13dd93a0efe8 | 26 | uint32_t length_data = strlen(this->data); |
Jeonghoon | 7:13dd93a0efe8 | 27 | varToArr(outbuffer + offset, length_data); |
Jeonghoon | 7:13dd93a0efe8 | 28 | offset += 4; |
Jeonghoon | 7:13dd93a0efe8 | 29 | memcpy(outbuffer + offset, this->data, length_data); |
Jeonghoon | 7:13dd93a0efe8 | 30 | offset += length_data; |
Jeonghoon | 7:13dd93a0efe8 | 31 | return offset; |
Jeonghoon | 7:13dd93a0efe8 | 32 | } |
Jeonghoon | 7:13dd93a0efe8 | 33 | |
Jeonghoon | 7:13dd93a0efe8 | 34 | virtual int deserialize(unsigned char *inbuffer) |
Jeonghoon | 7:13dd93a0efe8 | 35 | { |
Jeonghoon | 7:13dd93a0efe8 | 36 | int offset = 0; |
Jeonghoon | 7:13dd93a0efe8 | 37 | uint32_t length_data; |
Jeonghoon | 7:13dd93a0efe8 | 38 | arrToVar(length_data, (inbuffer + offset)); |
Jeonghoon | 7:13dd93a0efe8 | 39 | offset += 4; |
Jeonghoon | 7:13dd93a0efe8 | 40 | for(unsigned int k= offset; k< offset+length_data; ++k){ |
Jeonghoon | 7:13dd93a0efe8 | 41 | inbuffer[k-1]=inbuffer[k]; |
Jeonghoon | 7:13dd93a0efe8 | 42 | } |
Jeonghoon | 7:13dd93a0efe8 | 43 | inbuffer[offset+length_data-1]=0; |
Jeonghoon | 7:13dd93a0efe8 | 44 | this->data = (char *)(inbuffer + offset-1); |
Jeonghoon | 7:13dd93a0efe8 | 45 | offset += length_data; |
Jeonghoon | 7:13dd93a0efe8 | 46 | return offset; |
Jeonghoon | 7:13dd93a0efe8 | 47 | } |
Jeonghoon | 7:13dd93a0efe8 | 48 | |
Jeonghoon | 7:13dd93a0efe8 | 49 | const char * getType(){ return "std_msgs/String"; }; |
Jeonghoon | 7:13dd93a0efe8 | 50 | const char * getMD5(){ return "992ce8a1687cec8c8bd883ec73ca41d1"; }; |
Jeonghoon | 7:13dd93a0efe8 | 51 | |
Jeonghoon | 7:13dd93a0efe8 | 52 | }; |
Jeonghoon | 7:13dd93a0efe8 | 53 | |
Jeonghoon | 7:13dd93a0efe8 | 54 | } |
Jeonghoon | 7:13dd93a0efe8 | 55 | #endif |