capstone_finish
Dependencies: BufferedSerial motor_sn7544
std_msgs/Int64MultiArray.h@3:2a3664dc6634, 2019-08-13 (annotated)
- Committer:
- Jeonghoon
- Date:
- Tue Aug 13 05:53:22 2019 +0000
- Revision:
- 3:2a3664dc6634
with ROS;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jeonghoon | 3:2a3664dc6634 | 1 | #ifndef _ROS_std_msgs_Int64MultiArray_h |
Jeonghoon | 3:2a3664dc6634 | 2 | #define _ROS_std_msgs_Int64MultiArray_h |
Jeonghoon | 3:2a3664dc6634 | 3 | |
Jeonghoon | 3:2a3664dc6634 | 4 | #include <stdint.h> |
Jeonghoon | 3:2a3664dc6634 | 5 | #include <string.h> |
Jeonghoon | 3:2a3664dc6634 | 6 | #include <stdlib.h> |
Jeonghoon | 3:2a3664dc6634 | 7 | #include "ros/msg.h" |
Jeonghoon | 3:2a3664dc6634 | 8 | #include "std_msgs/MultiArrayLayout.h" |
Jeonghoon | 3:2a3664dc6634 | 9 | |
Jeonghoon | 3:2a3664dc6634 | 10 | namespace std_msgs |
Jeonghoon | 3:2a3664dc6634 | 11 | { |
Jeonghoon | 3:2a3664dc6634 | 12 | |
Jeonghoon | 3:2a3664dc6634 | 13 | class Int64MultiArray : public ros::Msg |
Jeonghoon | 3:2a3664dc6634 | 14 | { |
Jeonghoon | 3:2a3664dc6634 | 15 | public: |
Jeonghoon | 3:2a3664dc6634 | 16 | typedef std_msgs::MultiArrayLayout _layout_type; |
Jeonghoon | 3:2a3664dc6634 | 17 | _layout_type layout; |
Jeonghoon | 3:2a3664dc6634 | 18 | uint32_t data_length; |
Jeonghoon | 3:2a3664dc6634 | 19 | typedef int64_t _data_type; |
Jeonghoon | 3:2a3664dc6634 | 20 | _data_type st_data; |
Jeonghoon | 3:2a3664dc6634 | 21 | _data_type * data; |
Jeonghoon | 3:2a3664dc6634 | 22 | |
Jeonghoon | 3:2a3664dc6634 | 23 | Int64MultiArray(): |
Jeonghoon | 3:2a3664dc6634 | 24 | layout(), |
Jeonghoon | 3:2a3664dc6634 | 25 | data_length(0), data(NULL) |
Jeonghoon | 3:2a3664dc6634 | 26 | { |
Jeonghoon | 3:2a3664dc6634 | 27 | } |
Jeonghoon | 3:2a3664dc6634 | 28 | |
Jeonghoon | 3:2a3664dc6634 | 29 | virtual int serialize(unsigned char *outbuffer) const |
Jeonghoon | 3:2a3664dc6634 | 30 | { |
Jeonghoon | 3:2a3664dc6634 | 31 | int offset = 0; |
Jeonghoon | 3:2a3664dc6634 | 32 | offset += this->layout.serialize(outbuffer + offset); |
Jeonghoon | 3:2a3664dc6634 | 33 | *(outbuffer + offset + 0) = (this->data_length >> (8 * 0)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 34 | *(outbuffer + offset + 1) = (this->data_length >> (8 * 1)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 35 | *(outbuffer + offset + 2) = (this->data_length >> (8 * 2)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 36 | *(outbuffer + offset + 3) = (this->data_length >> (8 * 3)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 37 | offset += sizeof(this->data_length); |
Jeonghoon | 3:2a3664dc6634 | 38 | for( uint32_t i = 0; i < data_length; i++){ |
Jeonghoon | 3:2a3664dc6634 | 39 | union { |
Jeonghoon | 3:2a3664dc6634 | 40 | int64_t real; |
Jeonghoon | 3:2a3664dc6634 | 41 | uint64_t base; |
Jeonghoon | 3:2a3664dc6634 | 42 | } u_datai; |
Jeonghoon | 3:2a3664dc6634 | 43 | u_datai.real = this->data[i]; |
Jeonghoon | 3:2a3664dc6634 | 44 | *(outbuffer + offset + 0) = (u_datai.base >> (8 * 0)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 45 | *(outbuffer + offset + 1) = (u_datai.base >> (8 * 1)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 46 | *(outbuffer + offset + 2) = (u_datai.base >> (8 * 2)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 47 | *(outbuffer + offset + 3) = (u_datai.base >> (8 * 3)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 48 | *(outbuffer + offset + 4) = (u_datai.base >> (8 * 4)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 49 | *(outbuffer + offset + 5) = (u_datai.base >> (8 * 5)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 50 | *(outbuffer + offset + 6) = (u_datai.base >> (8 * 6)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 51 | *(outbuffer + offset + 7) = (u_datai.base >> (8 * 7)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 52 | offset += sizeof(this->data[i]); |
Jeonghoon | 3:2a3664dc6634 | 53 | } |
Jeonghoon | 3:2a3664dc6634 | 54 | return offset; |
Jeonghoon | 3:2a3664dc6634 | 55 | } |
Jeonghoon | 3:2a3664dc6634 | 56 | |
Jeonghoon | 3:2a3664dc6634 | 57 | virtual int deserialize(unsigned char *inbuffer) |
Jeonghoon | 3:2a3664dc6634 | 58 | { |
Jeonghoon | 3:2a3664dc6634 | 59 | int offset = 0; |
Jeonghoon | 3:2a3664dc6634 | 60 | offset += this->layout.deserialize(inbuffer + offset); |
Jeonghoon | 3:2a3664dc6634 | 61 | uint32_t data_lengthT = ((uint32_t) (*(inbuffer + offset))); |
Jeonghoon | 3:2a3664dc6634 | 62 | data_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Jeonghoon | 3:2a3664dc6634 | 63 | data_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Jeonghoon | 3:2a3664dc6634 | 64 | data_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Jeonghoon | 3:2a3664dc6634 | 65 | offset += sizeof(this->data_length); |
Jeonghoon | 3:2a3664dc6634 | 66 | if(data_lengthT > data_length) |
Jeonghoon | 3:2a3664dc6634 | 67 | this->data = (int64_t*)realloc(this->data, data_lengthT * sizeof(int64_t)); |
Jeonghoon | 3:2a3664dc6634 | 68 | data_length = data_lengthT; |
Jeonghoon | 3:2a3664dc6634 | 69 | for( uint32_t i = 0; i < data_length; i++){ |
Jeonghoon | 3:2a3664dc6634 | 70 | union { |
Jeonghoon | 3:2a3664dc6634 | 71 | int64_t real; |
Jeonghoon | 3:2a3664dc6634 | 72 | uint64_t base; |
Jeonghoon | 3:2a3664dc6634 | 73 | } u_st_data; |
Jeonghoon | 3:2a3664dc6634 | 74 | u_st_data.base = 0; |
Jeonghoon | 3:2a3664dc6634 | 75 | u_st_data.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); |
Jeonghoon | 3:2a3664dc6634 | 76 | u_st_data.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Jeonghoon | 3:2a3664dc6634 | 77 | u_st_data.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Jeonghoon | 3:2a3664dc6634 | 78 | u_st_data.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Jeonghoon | 3:2a3664dc6634 | 79 | u_st_data.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); |
Jeonghoon | 3:2a3664dc6634 | 80 | u_st_data.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); |
Jeonghoon | 3:2a3664dc6634 | 81 | u_st_data.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); |
Jeonghoon | 3:2a3664dc6634 | 82 | u_st_data.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); |
Jeonghoon | 3:2a3664dc6634 | 83 | this->st_data = u_st_data.real; |
Jeonghoon | 3:2a3664dc6634 | 84 | offset += sizeof(this->st_data); |
Jeonghoon | 3:2a3664dc6634 | 85 | memcpy( &(this->data[i]), &(this->st_data), sizeof(int64_t)); |
Jeonghoon | 3:2a3664dc6634 | 86 | } |
Jeonghoon | 3:2a3664dc6634 | 87 | return offset; |
Jeonghoon | 3:2a3664dc6634 | 88 | } |
Jeonghoon | 3:2a3664dc6634 | 89 | |
Jeonghoon | 3:2a3664dc6634 | 90 | const char * getType(){ return "std_msgs/Int64MultiArray"; }; |
Jeonghoon | 3:2a3664dc6634 | 91 | const char * getMD5(){ return "54865aa6c65be0448113a2afc6a49270"; }; |
Jeonghoon | 3:2a3664dc6634 | 92 | |
Jeonghoon | 3:2a3664dc6634 | 93 | }; |
Jeonghoon | 3:2a3664dc6634 | 94 | |
Jeonghoon | 3:2a3664dc6634 | 95 | } |
Jeonghoon | 3:2a3664dc6634 | 96 | #endif |