capstone_finish
Dependencies: BufferedSerial motor_sn7544
sensor_msgs/TimeReference.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_TimeReference_h |
Jeonghoon | 3:2a3664dc6634 | 2 | #define _ROS_sensor_msgs_TimeReference_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/Header.h" |
Jeonghoon | 3:2a3664dc6634 | 9 | #include "ros/time.h" |
Jeonghoon | 3:2a3664dc6634 | 10 | |
Jeonghoon | 3:2a3664dc6634 | 11 | namespace sensor_msgs |
Jeonghoon | 3:2a3664dc6634 | 12 | { |
Jeonghoon | 3:2a3664dc6634 | 13 | |
Jeonghoon | 3:2a3664dc6634 | 14 | class TimeReference : public ros::Msg |
Jeonghoon | 3:2a3664dc6634 | 15 | { |
Jeonghoon | 3:2a3664dc6634 | 16 | public: |
Jeonghoon | 3:2a3664dc6634 | 17 | typedef std_msgs::Header _header_type; |
Jeonghoon | 3:2a3664dc6634 | 18 | _header_type header; |
Jeonghoon | 3:2a3664dc6634 | 19 | typedef ros::Time _time_ref_type; |
Jeonghoon | 3:2a3664dc6634 | 20 | _time_ref_type time_ref; |
Jeonghoon | 3:2a3664dc6634 | 21 | typedef const char* _source_type; |
Jeonghoon | 3:2a3664dc6634 | 22 | _source_type source; |
Jeonghoon | 3:2a3664dc6634 | 23 | |
Jeonghoon | 3:2a3664dc6634 | 24 | TimeReference(): |
Jeonghoon | 3:2a3664dc6634 | 25 | header(), |
Jeonghoon | 3:2a3664dc6634 | 26 | time_ref(), |
Jeonghoon | 3:2a3664dc6634 | 27 | source("") |
Jeonghoon | 3:2a3664dc6634 | 28 | { |
Jeonghoon | 3:2a3664dc6634 | 29 | } |
Jeonghoon | 3:2a3664dc6634 | 30 | |
Jeonghoon | 3:2a3664dc6634 | 31 | virtual int serialize(unsigned char *outbuffer) const |
Jeonghoon | 3:2a3664dc6634 | 32 | { |
Jeonghoon | 3:2a3664dc6634 | 33 | int offset = 0; |
Jeonghoon | 3:2a3664dc6634 | 34 | offset += this->header.serialize(outbuffer + offset); |
Jeonghoon | 3:2a3664dc6634 | 35 | *(outbuffer + offset + 0) = (this->time_ref.sec >> (8 * 0)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 36 | *(outbuffer + offset + 1) = (this->time_ref.sec >> (8 * 1)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 37 | *(outbuffer + offset + 2) = (this->time_ref.sec >> (8 * 2)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 38 | *(outbuffer + offset + 3) = (this->time_ref.sec >> (8 * 3)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 39 | offset += sizeof(this->time_ref.sec); |
Jeonghoon | 3:2a3664dc6634 | 40 | *(outbuffer + offset + 0) = (this->time_ref.nsec >> (8 * 0)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 41 | *(outbuffer + offset + 1) = (this->time_ref.nsec >> (8 * 1)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 42 | *(outbuffer + offset + 2) = (this->time_ref.nsec >> (8 * 2)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 43 | *(outbuffer + offset + 3) = (this->time_ref.nsec >> (8 * 3)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 44 | offset += sizeof(this->time_ref.nsec); |
Jeonghoon | 3:2a3664dc6634 | 45 | uint32_t length_source = strlen(this->source); |
Jeonghoon | 3:2a3664dc6634 | 46 | varToArr(outbuffer + offset, length_source); |
Jeonghoon | 3:2a3664dc6634 | 47 | offset += 4; |
Jeonghoon | 3:2a3664dc6634 | 48 | memcpy(outbuffer + offset, this->source, length_source); |
Jeonghoon | 3:2a3664dc6634 | 49 | offset += length_source; |
Jeonghoon | 3:2a3664dc6634 | 50 | return offset; |
Jeonghoon | 3:2a3664dc6634 | 51 | } |
Jeonghoon | 3:2a3664dc6634 | 52 | |
Jeonghoon | 3:2a3664dc6634 | 53 | virtual int deserialize(unsigned char *inbuffer) |
Jeonghoon | 3:2a3664dc6634 | 54 | { |
Jeonghoon | 3:2a3664dc6634 | 55 | int offset = 0; |
Jeonghoon | 3:2a3664dc6634 | 56 | offset += this->header.deserialize(inbuffer + offset); |
Jeonghoon | 3:2a3664dc6634 | 57 | this->time_ref.sec = ((uint32_t) (*(inbuffer + offset))); |
Jeonghoon | 3:2a3664dc6634 | 58 | this->time_ref.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Jeonghoon | 3:2a3664dc6634 | 59 | this->time_ref.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Jeonghoon | 3:2a3664dc6634 | 60 | this->time_ref.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Jeonghoon | 3:2a3664dc6634 | 61 | offset += sizeof(this->time_ref.sec); |
Jeonghoon | 3:2a3664dc6634 | 62 | this->time_ref.nsec = ((uint32_t) (*(inbuffer + offset))); |
Jeonghoon | 3:2a3664dc6634 | 63 | this->time_ref.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Jeonghoon | 3:2a3664dc6634 | 64 | this->time_ref.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Jeonghoon | 3:2a3664dc6634 | 65 | this->time_ref.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Jeonghoon | 3:2a3664dc6634 | 66 | offset += sizeof(this->time_ref.nsec); |
Jeonghoon | 3:2a3664dc6634 | 67 | uint32_t length_source; |
Jeonghoon | 3:2a3664dc6634 | 68 | arrToVar(length_source, (inbuffer + offset)); |
Jeonghoon | 3:2a3664dc6634 | 69 | offset += 4; |
Jeonghoon | 3:2a3664dc6634 | 70 | for(unsigned int k= offset; k< offset+length_source; ++k){ |
Jeonghoon | 3:2a3664dc6634 | 71 | inbuffer[k-1]=inbuffer[k]; |
Jeonghoon | 3:2a3664dc6634 | 72 | } |
Jeonghoon | 3:2a3664dc6634 | 73 | inbuffer[offset+length_source-1]=0; |
Jeonghoon | 3:2a3664dc6634 | 74 | this->source = (char *)(inbuffer + offset-1); |
Jeonghoon | 3:2a3664dc6634 | 75 | offset += length_source; |
Jeonghoon | 3:2a3664dc6634 | 76 | return offset; |
Jeonghoon | 3:2a3664dc6634 | 77 | } |
Jeonghoon | 3:2a3664dc6634 | 78 | |
Jeonghoon | 3:2a3664dc6634 | 79 | const char * getType(){ return "sensor_msgs/TimeReference"; }; |
Jeonghoon | 3:2a3664dc6634 | 80 | const char * getMD5(){ return "fded64a0265108ba86c3d38fb11c0c16"; }; |
Jeonghoon | 3:2a3664dc6634 | 81 | |
Jeonghoon | 3:2a3664dc6634 | 82 | }; |
Jeonghoon | 3:2a3664dc6634 | 83 | |
Jeonghoon | 3:2a3664dc6634 | 84 | } |
Jeonghoon | 3:2a3664dc6634 | 85 | #endif |