complete motor
Dependencies: BufferedSerial motor_sn7544
std_msgs/Int16MultiArray.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_Int16MultiArray_h |
Jeonghoon | 7:13dd93a0efe8 | 2 | #define _ROS_std_msgs_Int16MultiArray_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 | #include "std_msgs/MultiArrayLayout.h" |
Jeonghoon | 7:13dd93a0efe8 | 9 | |
Jeonghoon | 7:13dd93a0efe8 | 10 | namespace std_msgs |
Jeonghoon | 7:13dd93a0efe8 | 11 | { |
Jeonghoon | 7:13dd93a0efe8 | 12 | |
Jeonghoon | 7:13dd93a0efe8 | 13 | class Int16MultiArray : public ros::Msg |
Jeonghoon | 7:13dd93a0efe8 | 14 | { |
Jeonghoon | 7:13dd93a0efe8 | 15 | public: |
Jeonghoon | 7:13dd93a0efe8 | 16 | typedef std_msgs::MultiArrayLayout _layout_type; |
Jeonghoon | 7:13dd93a0efe8 | 17 | _layout_type layout; |
Jeonghoon | 7:13dd93a0efe8 | 18 | uint32_t data_length; |
Jeonghoon | 7:13dd93a0efe8 | 19 | typedef int16_t _data_type; |
Jeonghoon | 7:13dd93a0efe8 | 20 | _data_type st_data; |
Jeonghoon | 7:13dd93a0efe8 | 21 | _data_type * data; |
Jeonghoon | 7:13dd93a0efe8 | 22 | |
Jeonghoon | 7:13dd93a0efe8 | 23 | Int16MultiArray(): |
Jeonghoon | 7:13dd93a0efe8 | 24 | layout(), |
Jeonghoon | 7:13dd93a0efe8 | 25 | data_length(0), data(NULL) |
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 | offset += this->layout.serialize(outbuffer + offset); |
Jeonghoon | 7:13dd93a0efe8 | 33 | *(outbuffer + offset + 0) = (this->data_length >> (8 * 0)) & 0xFF; |
Jeonghoon | 7:13dd93a0efe8 | 34 | *(outbuffer + offset + 1) = (this->data_length >> (8 * 1)) & 0xFF; |
Jeonghoon | 7:13dd93a0efe8 | 35 | *(outbuffer + offset + 2) = (this->data_length >> (8 * 2)) & 0xFF; |
Jeonghoon | 7:13dd93a0efe8 | 36 | *(outbuffer + offset + 3) = (this->data_length >> (8 * 3)) & 0xFF; |
Jeonghoon | 7:13dd93a0efe8 | 37 | offset += sizeof(this->data_length); |
Jeonghoon | 7:13dd93a0efe8 | 38 | for( uint32_t i = 0; i < data_length; i++){ |
Jeonghoon | 7:13dd93a0efe8 | 39 | union { |
Jeonghoon | 7:13dd93a0efe8 | 40 | int16_t real; |
Jeonghoon | 7:13dd93a0efe8 | 41 | uint16_t base; |
Jeonghoon | 7:13dd93a0efe8 | 42 | } u_datai; |
Jeonghoon | 7:13dd93a0efe8 | 43 | u_datai.real = this->data[i]; |
Jeonghoon | 7:13dd93a0efe8 | 44 | *(outbuffer + offset + 0) = (u_datai.base >> (8 * 0)) & 0xFF; |
Jeonghoon | 7:13dd93a0efe8 | 45 | *(outbuffer + offset + 1) = (u_datai.base >> (8 * 1)) & 0xFF; |
Jeonghoon | 7:13dd93a0efe8 | 46 | offset += sizeof(this->data[i]); |
Jeonghoon | 7:13dd93a0efe8 | 47 | } |
Jeonghoon | 7:13dd93a0efe8 | 48 | return offset; |
Jeonghoon | 7:13dd93a0efe8 | 49 | } |
Jeonghoon | 7:13dd93a0efe8 | 50 | |
Jeonghoon | 7:13dd93a0efe8 | 51 | virtual int deserialize(unsigned char *inbuffer) |
Jeonghoon | 7:13dd93a0efe8 | 52 | { |
Jeonghoon | 7:13dd93a0efe8 | 53 | int offset = 0; |
Jeonghoon | 7:13dd93a0efe8 | 54 | offset += this->layout.deserialize(inbuffer + offset); |
Jeonghoon | 7:13dd93a0efe8 | 55 | uint32_t data_lengthT = ((uint32_t) (*(inbuffer + offset))); |
Jeonghoon | 7:13dd93a0efe8 | 56 | data_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Jeonghoon | 7:13dd93a0efe8 | 57 | data_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Jeonghoon | 7:13dd93a0efe8 | 58 | data_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Jeonghoon | 7:13dd93a0efe8 | 59 | offset += sizeof(this->data_length); |
Jeonghoon | 7:13dd93a0efe8 | 60 | if(data_lengthT > data_length) |
Jeonghoon | 7:13dd93a0efe8 | 61 | this->data = (int16_t*)realloc(this->data, data_lengthT * sizeof(int16_t)); |
Jeonghoon | 7:13dd93a0efe8 | 62 | data_length = data_lengthT; |
Jeonghoon | 7:13dd93a0efe8 | 63 | for( uint32_t i = 0; i < data_length; i++){ |
Jeonghoon | 7:13dd93a0efe8 | 64 | union { |
Jeonghoon | 7:13dd93a0efe8 | 65 | int16_t real; |
Jeonghoon | 7:13dd93a0efe8 | 66 | uint16_t base; |
Jeonghoon | 7:13dd93a0efe8 | 67 | } u_st_data; |
Jeonghoon | 7:13dd93a0efe8 | 68 | u_st_data.base = 0; |
Jeonghoon | 7:13dd93a0efe8 | 69 | u_st_data.base |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0); |
Jeonghoon | 7:13dd93a0efe8 | 70 | u_st_data.base |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Jeonghoon | 7:13dd93a0efe8 | 71 | this->st_data = u_st_data.real; |
Jeonghoon | 7:13dd93a0efe8 | 72 | offset += sizeof(this->st_data); |
Jeonghoon | 7:13dd93a0efe8 | 73 | memcpy( &(this->data[i]), &(this->st_data), sizeof(int16_t)); |
Jeonghoon | 7:13dd93a0efe8 | 74 | } |
Jeonghoon | 7:13dd93a0efe8 | 75 | return offset; |
Jeonghoon | 7:13dd93a0efe8 | 76 | } |
Jeonghoon | 7:13dd93a0efe8 | 77 | |
Jeonghoon | 7:13dd93a0efe8 | 78 | const char * getType(){ return "std_msgs/Int16MultiArray"; }; |
Jeonghoon | 7:13dd93a0efe8 | 79 | const char * getMD5(){ return "d9338d7f523fcb692fae9d0a0e9f067c"; }; |
Jeonghoon | 7:13dd93a0efe8 | 80 | |
Jeonghoon | 7:13dd93a0efe8 | 81 | }; |
Jeonghoon | 7:13dd93a0efe8 | 82 | |
Jeonghoon | 7:13dd93a0efe8 | 83 | } |
Jeonghoon | 7:13dd93a0efe8 | 84 | #endif |