complete motor
Dependencies: BufferedSerial motor_sn7544
std_msgs/MultiArrayLayout.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_MultiArrayLayout_h |
Jeonghoon | 7:13dd93a0efe8 | 2 | #define _ROS_std_msgs_MultiArrayLayout_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/MultiArrayDimension.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 MultiArrayLayout : public ros::Msg |
Jeonghoon | 7:13dd93a0efe8 | 14 | { |
Jeonghoon | 7:13dd93a0efe8 | 15 | public: |
Jeonghoon | 7:13dd93a0efe8 | 16 | uint32_t dim_length; |
Jeonghoon | 7:13dd93a0efe8 | 17 | typedef std_msgs::MultiArrayDimension _dim_type; |
Jeonghoon | 7:13dd93a0efe8 | 18 | _dim_type st_dim; |
Jeonghoon | 7:13dd93a0efe8 | 19 | _dim_type * dim; |
Jeonghoon | 7:13dd93a0efe8 | 20 | typedef uint32_t _data_offset_type; |
Jeonghoon | 7:13dd93a0efe8 | 21 | _data_offset_type data_offset; |
Jeonghoon | 7:13dd93a0efe8 | 22 | |
Jeonghoon | 7:13dd93a0efe8 | 23 | MultiArrayLayout(): |
Jeonghoon | 7:13dd93a0efe8 | 24 | dim_length(0), dim(NULL), |
Jeonghoon | 7:13dd93a0efe8 | 25 | data_offset(0) |
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 | *(outbuffer + offset + 0) = (this->dim_length >> (8 * 0)) & 0xFF; |
Jeonghoon | 7:13dd93a0efe8 | 33 | *(outbuffer + offset + 1) = (this->dim_length >> (8 * 1)) & 0xFF; |
Jeonghoon | 7:13dd93a0efe8 | 34 | *(outbuffer + offset + 2) = (this->dim_length >> (8 * 2)) & 0xFF; |
Jeonghoon | 7:13dd93a0efe8 | 35 | *(outbuffer + offset + 3) = (this->dim_length >> (8 * 3)) & 0xFF; |
Jeonghoon | 7:13dd93a0efe8 | 36 | offset += sizeof(this->dim_length); |
Jeonghoon | 7:13dd93a0efe8 | 37 | for( uint32_t i = 0; i < dim_length; i++){ |
Jeonghoon | 7:13dd93a0efe8 | 38 | offset += this->dim[i].serialize(outbuffer + offset); |
Jeonghoon | 7:13dd93a0efe8 | 39 | } |
Jeonghoon | 7:13dd93a0efe8 | 40 | *(outbuffer + offset + 0) = (this->data_offset >> (8 * 0)) & 0xFF; |
Jeonghoon | 7:13dd93a0efe8 | 41 | *(outbuffer + offset + 1) = (this->data_offset >> (8 * 1)) & 0xFF; |
Jeonghoon | 7:13dd93a0efe8 | 42 | *(outbuffer + offset + 2) = (this->data_offset >> (8 * 2)) & 0xFF; |
Jeonghoon | 7:13dd93a0efe8 | 43 | *(outbuffer + offset + 3) = (this->data_offset >> (8 * 3)) & 0xFF; |
Jeonghoon | 7:13dd93a0efe8 | 44 | offset += sizeof(this->data_offset); |
Jeonghoon | 7:13dd93a0efe8 | 45 | return offset; |
Jeonghoon | 7:13dd93a0efe8 | 46 | } |
Jeonghoon | 7:13dd93a0efe8 | 47 | |
Jeonghoon | 7:13dd93a0efe8 | 48 | virtual int deserialize(unsigned char *inbuffer) |
Jeonghoon | 7:13dd93a0efe8 | 49 | { |
Jeonghoon | 7:13dd93a0efe8 | 50 | int offset = 0; |
Jeonghoon | 7:13dd93a0efe8 | 51 | uint32_t dim_lengthT = ((uint32_t) (*(inbuffer + offset))); |
Jeonghoon | 7:13dd93a0efe8 | 52 | dim_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Jeonghoon | 7:13dd93a0efe8 | 53 | dim_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Jeonghoon | 7:13dd93a0efe8 | 54 | dim_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Jeonghoon | 7:13dd93a0efe8 | 55 | offset += sizeof(this->dim_length); |
Jeonghoon | 7:13dd93a0efe8 | 56 | if(dim_lengthT > dim_length) |
Jeonghoon | 7:13dd93a0efe8 | 57 | this->dim = (std_msgs::MultiArrayDimension*)realloc(this->dim, dim_lengthT * sizeof(std_msgs::MultiArrayDimension)); |
Jeonghoon | 7:13dd93a0efe8 | 58 | dim_length = dim_lengthT; |
Jeonghoon | 7:13dd93a0efe8 | 59 | for( uint32_t i = 0; i < dim_length; i++){ |
Jeonghoon | 7:13dd93a0efe8 | 60 | offset += this->st_dim.deserialize(inbuffer + offset); |
Jeonghoon | 7:13dd93a0efe8 | 61 | memcpy( &(this->dim[i]), &(this->st_dim), sizeof(std_msgs::MultiArrayDimension)); |
Jeonghoon | 7:13dd93a0efe8 | 62 | } |
Jeonghoon | 7:13dd93a0efe8 | 63 | this->data_offset = ((uint32_t) (*(inbuffer + offset))); |
Jeonghoon | 7:13dd93a0efe8 | 64 | this->data_offset |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Jeonghoon | 7:13dd93a0efe8 | 65 | this->data_offset |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Jeonghoon | 7:13dd93a0efe8 | 66 | this->data_offset |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Jeonghoon | 7:13dd93a0efe8 | 67 | offset += sizeof(this->data_offset); |
Jeonghoon | 7:13dd93a0efe8 | 68 | return offset; |
Jeonghoon | 7:13dd93a0efe8 | 69 | } |
Jeonghoon | 7:13dd93a0efe8 | 70 | |
Jeonghoon | 7:13dd93a0efe8 | 71 | const char * getType(){ return "std_msgs/MultiArrayLayout"; }; |
Jeonghoon | 7:13dd93a0efe8 | 72 | const char * getMD5(){ return "0fed2a11c13e11c5571b4e2a995a91a3"; }; |
Jeonghoon | 7:13dd93a0efe8 | 73 | |
Jeonghoon | 7:13dd93a0efe8 | 74 | }; |
Jeonghoon | 7:13dd93a0efe8 | 75 | |
Jeonghoon | 7:13dd93a0efe8 | 76 | } |
Jeonghoon | 7:13dd93a0efe8 | 77 | #endif |