complete motor
Dependencies: BufferedSerial motor_sn7544
std_msgs/Int16.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_std_msgs_Int16_h |
Jeonghoon | 7:13dd93a0efe8 | 2 | #define _ROS_std_msgs_Int16_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 Int16 : public ros::Msg |
Jeonghoon | 7:13dd93a0efe8 | 13 | { |
Jeonghoon | 7:13dd93a0efe8 | 14 | public: |
Jeonghoon | 7:13dd93a0efe8 | 15 | typedef int16_t _data_type; |
Jeonghoon | 7:13dd93a0efe8 | 16 | _data_type data; |
Jeonghoon | 7:13dd93a0efe8 | 17 | |
Jeonghoon | 7:13dd93a0efe8 | 18 | Int16(): |
Jeonghoon | 7:13dd93a0efe8 | 19 | data(0) |
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 | union { |
Jeonghoon | 7:13dd93a0efe8 | 27 | int16_t real; |
Jeonghoon | 7:13dd93a0efe8 | 28 | uint16_t base; |
Jeonghoon | 7:13dd93a0efe8 | 29 | } u_data; |
Jeonghoon | 7:13dd93a0efe8 | 30 | u_data.real = this->data; |
Jeonghoon | 7:13dd93a0efe8 | 31 | *(outbuffer + offset + 0) = (u_data.base >> (8 * 0)) & 0xFF; |
Jeonghoon | 7:13dd93a0efe8 | 32 | *(outbuffer + offset + 1) = (u_data.base >> (8 * 1)) & 0xFF; |
Jeonghoon | 7:13dd93a0efe8 | 33 | offset += sizeof(this->data); |
Jeonghoon | 7:13dd93a0efe8 | 34 | return offset; |
Jeonghoon | 7:13dd93a0efe8 | 35 | } |
Jeonghoon | 7:13dd93a0efe8 | 36 | |
Jeonghoon | 7:13dd93a0efe8 | 37 | virtual int deserialize(unsigned char *inbuffer) |
Jeonghoon | 7:13dd93a0efe8 | 38 | { |
Jeonghoon | 7:13dd93a0efe8 | 39 | int offset = 0; |
Jeonghoon | 7:13dd93a0efe8 | 40 | union { |
Jeonghoon | 7:13dd93a0efe8 | 41 | int16_t real; |
Jeonghoon | 7:13dd93a0efe8 | 42 | uint16_t base; |
Jeonghoon | 7:13dd93a0efe8 | 43 | } u_data; |
Jeonghoon | 7:13dd93a0efe8 | 44 | u_data.base = 0; |
Jeonghoon | 7:13dd93a0efe8 | 45 | u_data.base |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0); |
Jeonghoon | 7:13dd93a0efe8 | 46 | u_data.base |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Jeonghoon | 7:13dd93a0efe8 | 47 | this->data = u_data.real; |
Jeonghoon | 7:13dd93a0efe8 | 48 | offset += sizeof(this->data); |
Jeonghoon | 7:13dd93a0efe8 | 49 | return offset; |
Jeonghoon | 7:13dd93a0efe8 | 50 | } |
Jeonghoon | 7:13dd93a0efe8 | 51 | |
Jeonghoon | 7:13dd93a0efe8 | 52 | const char * getType(){ return "std_msgs/Int16"; }; |
Jeonghoon | 7:13dd93a0efe8 | 53 | const char * getMD5(){ return "8524586e34fbd7cb1c08c5f5f1ca0e57"; }; |
Jeonghoon | 7:13dd93a0efe8 | 54 | |
Jeonghoon | 7:13dd93a0efe8 | 55 | }; |
Jeonghoon | 7:13dd93a0efe8 | 56 | |
Jeonghoon | 7:13dd93a0efe8 | 57 | } |
Jeonghoon | 7:13dd93a0efe8 | 58 | #endif |