![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
capstone_finish
Dependencies: BufferedSerial motor_sn7544
sensor_msgs/JoyFeedbackArray.h@10:ca4e4062701a, 2019-11-26 (annotated)
- Committer:
- Jeonghoon
- Date:
- Tue Nov 26 15:30:27 2019 +0000
- Revision:
- 10:ca4e4062701a
- Parent:
- 3:2a3664dc6634
capstone finish
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jeonghoon | 3:2a3664dc6634 | 1 | #ifndef _ROS_sensor_msgs_JoyFeedbackArray_h |
Jeonghoon | 3:2a3664dc6634 | 2 | #define _ROS_sensor_msgs_JoyFeedbackArray_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 "sensor_msgs/JoyFeedback.h" |
Jeonghoon | 3:2a3664dc6634 | 9 | |
Jeonghoon | 3:2a3664dc6634 | 10 | namespace sensor_msgs |
Jeonghoon | 3:2a3664dc6634 | 11 | { |
Jeonghoon | 3:2a3664dc6634 | 12 | |
Jeonghoon | 3:2a3664dc6634 | 13 | class JoyFeedbackArray : public ros::Msg |
Jeonghoon | 3:2a3664dc6634 | 14 | { |
Jeonghoon | 3:2a3664dc6634 | 15 | public: |
Jeonghoon | 3:2a3664dc6634 | 16 | uint32_t array_length; |
Jeonghoon | 3:2a3664dc6634 | 17 | typedef sensor_msgs::JoyFeedback _array_type; |
Jeonghoon | 3:2a3664dc6634 | 18 | _array_type st_array; |
Jeonghoon | 3:2a3664dc6634 | 19 | _array_type * array; |
Jeonghoon | 3:2a3664dc6634 | 20 | |
Jeonghoon | 3:2a3664dc6634 | 21 | JoyFeedbackArray(): |
Jeonghoon | 3:2a3664dc6634 | 22 | array_length(0), array(NULL) |
Jeonghoon | 3:2a3664dc6634 | 23 | { |
Jeonghoon | 3:2a3664dc6634 | 24 | } |
Jeonghoon | 3:2a3664dc6634 | 25 | |
Jeonghoon | 3:2a3664dc6634 | 26 | virtual int serialize(unsigned char *outbuffer) const |
Jeonghoon | 3:2a3664dc6634 | 27 | { |
Jeonghoon | 3:2a3664dc6634 | 28 | int offset = 0; |
Jeonghoon | 3:2a3664dc6634 | 29 | *(outbuffer + offset + 0) = (this->array_length >> (8 * 0)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 30 | *(outbuffer + offset + 1) = (this->array_length >> (8 * 1)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 31 | *(outbuffer + offset + 2) = (this->array_length >> (8 * 2)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 32 | *(outbuffer + offset + 3) = (this->array_length >> (8 * 3)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 33 | offset += sizeof(this->array_length); |
Jeonghoon | 3:2a3664dc6634 | 34 | for( uint32_t i = 0; i < array_length; i++){ |
Jeonghoon | 3:2a3664dc6634 | 35 | offset += this->array[i].serialize(outbuffer + offset); |
Jeonghoon | 3:2a3664dc6634 | 36 | } |
Jeonghoon | 3:2a3664dc6634 | 37 | return offset; |
Jeonghoon | 3:2a3664dc6634 | 38 | } |
Jeonghoon | 3:2a3664dc6634 | 39 | |
Jeonghoon | 3:2a3664dc6634 | 40 | virtual int deserialize(unsigned char *inbuffer) |
Jeonghoon | 3:2a3664dc6634 | 41 | { |
Jeonghoon | 3:2a3664dc6634 | 42 | int offset = 0; |
Jeonghoon | 3:2a3664dc6634 | 43 | uint32_t array_lengthT = ((uint32_t) (*(inbuffer + offset))); |
Jeonghoon | 3:2a3664dc6634 | 44 | array_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Jeonghoon | 3:2a3664dc6634 | 45 | array_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Jeonghoon | 3:2a3664dc6634 | 46 | array_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Jeonghoon | 3:2a3664dc6634 | 47 | offset += sizeof(this->array_length); |
Jeonghoon | 3:2a3664dc6634 | 48 | if(array_lengthT > array_length) |
Jeonghoon | 3:2a3664dc6634 | 49 | this->array = (sensor_msgs::JoyFeedback*)realloc(this->array, array_lengthT * sizeof(sensor_msgs::JoyFeedback)); |
Jeonghoon | 3:2a3664dc6634 | 50 | array_length = array_lengthT; |
Jeonghoon | 3:2a3664dc6634 | 51 | for( uint32_t i = 0; i < array_length; i++){ |
Jeonghoon | 3:2a3664dc6634 | 52 | offset += this->st_array.deserialize(inbuffer + offset); |
Jeonghoon | 3:2a3664dc6634 | 53 | memcpy( &(this->array[i]), &(this->st_array), sizeof(sensor_msgs::JoyFeedback)); |
Jeonghoon | 3:2a3664dc6634 | 54 | } |
Jeonghoon | 3:2a3664dc6634 | 55 | return offset; |
Jeonghoon | 3:2a3664dc6634 | 56 | } |
Jeonghoon | 3:2a3664dc6634 | 57 | |
Jeonghoon | 3:2a3664dc6634 | 58 | const char * getType(){ return "sensor_msgs/JoyFeedbackArray"; }; |
Jeonghoon | 3:2a3664dc6634 | 59 | const char * getMD5(){ return "cde5730a895b1fc4dee6f91b754b213d"; }; |
Jeonghoon | 3:2a3664dc6634 | 60 | |
Jeonghoon | 3:2a3664dc6634 | 61 | }; |
Jeonghoon | 3:2a3664dc6634 | 62 | |
Jeonghoon | 3:2a3664dc6634 | 63 | } |
Jeonghoon | 3:2a3664dc6634 | 64 | #endif |