hairo
Dependencies: mbed BufferedSerial
visualization_msgs/InteractiveMarkerUpdate.h@4:bcdd99711326, 2018-12-04 (annotated)
- Committer:
- tknara
- Date:
- Tue Dec 04 00:14:32 2018 +0000
- Revision:
- 4:bcdd99711326
- Parent:
- 0:9e9b7db60fd5
test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
garyservin | 0:9e9b7db60fd5 | 1 | #ifndef _ROS_visualization_msgs_InteractiveMarkerUpdate_h |
garyservin | 0:9e9b7db60fd5 | 2 | #define _ROS_visualization_msgs_InteractiveMarkerUpdate_h |
garyservin | 0:9e9b7db60fd5 | 3 | |
garyservin | 0:9e9b7db60fd5 | 4 | #include <stdint.h> |
garyservin | 0:9e9b7db60fd5 | 5 | #include <string.h> |
garyservin | 0:9e9b7db60fd5 | 6 | #include <stdlib.h> |
garyservin | 0:9e9b7db60fd5 | 7 | #include "ros/msg.h" |
garyservin | 0:9e9b7db60fd5 | 8 | #include "visualization_msgs/InteractiveMarker.h" |
garyservin | 0:9e9b7db60fd5 | 9 | #include "visualization_msgs/InteractiveMarkerPose.h" |
garyservin | 0:9e9b7db60fd5 | 10 | |
garyservin | 0:9e9b7db60fd5 | 11 | namespace visualization_msgs |
garyservin | 0:9e9b7db60fd5 | 12 | { |
garyservin | 0:9e9b7db60fd5 | 13 | |
garyservin | 0:9e9b7db60fd5 | 14 | class InteractiveMarkerUpdate : public ros::Msg |
garyservin | 0:9e9b7db60fd5 | 15 | { |
garyservin | 0:9e9b7db60fd5 | 16 | public: |
garyservin | 0:9e9b7db60fd5 | 17 | typedef const char* _server_id_type; |
garyservin | 0:9e9b7db60fd5 | 18 | _server_id_type server_id; |
garyservin | 0:9e9b7db60fd5 | 19 | typedef uint64_t _seq_num_type; |
garyservin | 0:9e9b7db60fd5 | 20 | _seq_num_type seq_num; |
garyservin | 0:9e9b7db60fd5 | 21 | typedef uint8_t _type_type; |
garyservin | 0:9e9b7db60fd5 | 22 | _type_type type; |
garyservin | 0:9e9b7db60fd5 | 23 | uint32_t markers_length; |
garyservin | 0:9e9b7db60fd5 | 24 | typedef visualization_msgs::InteractiveMarker _markers_type; |
garyservin | 0:9e9b7db60fd5 | 25 | _markers_type st_markers; |
garyservin | 0:9e9b7db60fd5 | 26 | _markers_type * markers; |
garyservin | 0:9e9b7db60fd5 | 27 | uint32_t poses_length; |
garyservin | 0:9e9b7db60fd5 | 28 | typedef visualization_msgs::InteractiveMarkerPose _poses_type; |
garyservin | 0:9e9b7db60fd5 | 29 | _poses_type st_poses; |
garyservin | 0:9e9b7db60fd5 | 30 | _poses_type * poses; |
garyservin | 0:9e9b7db60fd5 | 31 | uint32_t erases_length; |
garyservin | 0:9e9b7db60fd5 | 32 | typedef char* _erases_type; |
garyservin | 0:9e9b7db60fd5 | 33 | _erases_type st_erases; |
garyservin | 0:9e9b7db60fd5 | 34 | _erases_type * erases; |
garyservin | 0:9e9b7db60fd5 | 35 | enum { KEEP_ALIVE = 0 }; |
garyservin | 0:9e9b7db60fd5 | 36 | enum { UPDATE = 1 }; |
garyservin | 0:9e9b7db60fd5 | 37 | |
garyservin | 0:9e9b7db60fd5 | 38 | InteractiveMarkerUpdate(): |
garyservin | 0:9e9b7db60fd5 | 39 | server_id(""), |
garyservin | 0:9e9b7db60fd5 | 40 | seq_num(0), |
garyservin | 0:9e9b7db60fd5 | 41 | type(0), |
garyservin | 0:9e9b7db60fd5 | 42 | markers_length(0), markers(NULL), |
garyservin | 0:9e9b7db60fd5 | 43 | poses_length(0), poses(NULL), |
garyservin | 0:9e9b7db60fd5 | 44 | erases_length(0), erases(NULL) |
garyservin | 0:9e9b7db60fd5 | 45 | { |
garyservin | 0:9e9b7db60fd5 | 46 | } |
garyservin | 0:9e9b7db60fd5 | 47 | |
garyservin | 0:9e9b7db60fd5 | 48 | virtual int serialize(unsigned char *outbuffer) const |
garyservin | 0:9e9b7db60fd5 | 49 | { |
garyservin | 0:9e9b7db60fd5 | 50 | int offset = 0; |
garyservin | 0:9e9b7db60fd5 | 51 | uint32_t length_server_id = strlen(this->server_id); |
garyservin | 0:9e9b7db60fd5 | 52 | varToArr(outbuffer + offset, length_server_id); |
garyservin | 0:9e9b7db60fd5 | 53 | offset += 4; |
garyservin | 0:9e9b7db60fd5 | 54 | memcpy(outbuffer + offset, this->server_id, length_server_id); |
garyservin | 0:9e9b7db60fd5 | 55 | offset += length_server_id; |
garyservin | 0:9e9b7db60fd5 | 56 | union { |
garyservin | 0:9e9b7db60fd5 | 57 | uint64_t real; |
garyservin | 0:9e9b7db60fd5 | 58 | uint32_t base; |
garyservin | 0:9e9b7db60fd5 | 59 | } u_seq_num; |
garyservin | 0:9e9b7db60fd5 | 60 | u_seq_num.real = this->seq_num; |
garyservin | 0:9e9b7db60fd5 | 61 | *(outbuffer + offset + 0) = (u_seq_num.base >> (8 * 0)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 62 | *(outbuffer + offset + 1) = (u_seq_num.base >> (8 * 1)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 63 | *(outbuffer + offset + 2) = (u_seq_num.base >> (8 * 2)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 64 | *(outbuffer + offset + 3) = (u_seq_num.base >> (8 * 3)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 65 | offset += sizeof(this->seq_num); |
garyservin | 0:9e9b7db60fd5 | 66 | *(outbuffer + offset + 0) = (this->type >> (8 * 0)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 67 | offset += sizeof(this->type); |
garyservin | 0:9e9b7db60fd5 | 68 | *(outbuffer + offset + 0) = (this->markers_length >> (8 * 0)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 69 | *(outbuffer + offset + 1) = (this->markers_length >> (8 * 1)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 70 | *(outbuffer + offset + 2) = (this->markers_length >> (8 * 2)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 71 | *(outbuffer + offset + 3) = (this->markers_length >> (8 * 3)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 72 | offset += sizeof(this->markers_length); |
garyservin | 0:9e9b7db60fd5 | 73 | for( uint32_t i = 0; i < markers_length; i++){ |
garyservin | 0:9e9b7db60fd5 | 74 | offset += this->markers[i].serialize(outbuffer + offset); |
garyservin | 0:9e9b7db60fd5 | 75 | } |
garyservin | 0:9e9b7db60fd5 | 76 | *(outbuffer + offset + 0) = (this->poses_length >> (8 * 0)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 77 | *(outbuffer + offset + 1) = (this->poses_length >> (8 * 1)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 78 | *(outbuffer + offset + 2) = (this->poses_length >> (8 * 2)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 79 | *(outbuffer + offset + 3) = (this->poses_length >> (8 * 3)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 80 | offset += sizeof(this->poses_length); |
garyservin | 0:9e9b7db60fd5 | 81 | for( uint32_t i = 0; i < poses_length; i++){ |
garyservin | 0:9e9b7db60fd5 | 82 | offset += this->poses[i].serialize(outbuffer + offset); |
garyservin | 0:9e9b7db60fd5 | 83 | } |
garyservin | 0:9e9b7db60fd5 | 84 | *(outbuffer + offset + 0) = (this->erases_length >> (8 * 0)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 85 | *(outbuffer + offset + 1) = (this->erases_length >> (8 * 1)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 86 | *(outbuffer + offset + 2) = (this->erases_length >> (8 * 2)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 87 | *(outbuffer + offset + 3) = (this->erases_length >> (8 * 3)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 88 | offset += sizeof(this->erases_length); |
garyservin | 0:9e9b7db60fd5 | 89 | for( uint32_t i = 0; i < erases_length; i++){ |
garyservin | 0:9e9b7db60fd5 | 90 | uint32_t length_erasesi = strlen(this->erases[i]); |
garyservin | 0:9e9b7db60fd5 | 91 | varToArr(outbuffer + offset, length_erasesi); |
garyservin | 0:9e9b7db60fd5 | 92 | offset += 4; |
garyservin | 0:9e9b7db60fd5 | 93 | memcpy(outbuffer + offset, this->erases[i], length_erasesi); |
garyservin | 0:9e9b7db60fd5 | 94 | offset += length_erasesi; |
garyservin | 0:9e9b7db60fd5 | 95 | } |
garyservin | 0:9e9b7db60fd5 | 96 | return offset; |
garyservin | 0:9e9b7db60fd5 | 97 | } |
garyservin | 0:9e9b7db60fd5 | 98 | |
garyservin | 0:9e9b7db60fd5 | 99 | virtual int deserialize(unsigned char *inbuffer) |
garyservin | 0:9e9b7db60fd5 | 100 | { |
garyservin | 0:9e9b7db60fd5 | 101 | int offset = 0; |
garyservin | 0:9e9b7db60fd5 | 102 | uint32_t length_server_id; |
garyservin | 0:9e9b7db60fd5 | 103 | arrToVar(length_server_id, (inbuffer + offset)); |
garyservin | 0:9e9b7db60fd5 | 104 | offset += 4; |
garyservin | 0:9e9b7db60fd5 | 105 | for(unsigned int k= offset; k< offset+length_server_id; ++k){ |
garyservin | 0:9e9b7db60fd5 | 106 | inbuffer[k-1]=inbuffer[k]; |
garyservin | 0:9e9b7db60fd5 | 107 | } |
garyservin | 0:9e9b7db60fd5 | 108 | inbuffer[offset+length_server_id-1]=0; |
garyservin | 0:9e9b7db60fd5 | 109 | this->server_id = (char *)(inbuffer + offset-1); |
garyservin | 0:9e9b7db60fd5 | 110 | offset += length_server_id; |
garyservin | 0:9e9b7db60fd5 | 111 | union { |
garyservin | 0:9e9b7db60fd5 | 112 | uint64_t real; |
garyservin | 0:9e9b7db60fd5 | 113 | uint32_t base; |
garyservin | 0:9e9b7db60fd5 | 114 | } u_seq_num; |
garyservin | 0:9e9b7db60fd5 | 115 | u_seq_num.base = 0; |
garyservin | 0:9e9b7db60fd5 | 116 | u_seq_num.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
garyservin | 0:9e9b7db60fd5 | 117 | u_seq_num.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:9e9b7db60fd5 | 118 | u_seq_num.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:9e9b7db60fd5 | 119 | u_seq_num.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:9e9b7db60fd5 | 120 | this->seq_num = u_seq_num.real; |
garyservin | 0:9e9b7db60fd5 | 121 | offset += sizeof(this->seq_num); |
garyservin | 0:9e9b7db60fd5 | 122 | this->type = ((uint8_t) (*(inbuffer + offset))); |
garyservin | 0:9e9b7db60fd5 | 123 | offset += sizeof(this->type); |
garyservin | 0:9e9b7db60fd5 | 124 | uint32_t markers_lengthT = ((uint32_t) (*(inbuffer + offset))); |
garyservin | 0:9e9b7db60fd5 | 125 | markers_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:9e9b7db60fd5 | 126 | markers_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:9e9b7db60fd5 | 127 | markers_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:9e9b7db60fd5 | 128 | offset += sizeof(this->markers_length); |
garyservin | 0:9e9b7db60fd5 | 129 | if(markers_lengthT > markers_length) |
garyservin | 0:9e9b7db60fd5 | 130 | this->markers = (visualization_msgs::InteractiveMarker*)realloc(this->markers, markers_lengthT * sizeof(visualization_msgs::InteractiveMarker)); |
garyservin | 0:9e9b7db60fd5 | 131 | markers_length = markers_lengthT; |
garyservin | 0:9e9b7db60fd5 | 132 | for( uint32_t i = 0; i < markers_length; i++){ |
garyservin | 0:9e9b7db60fd5 | 133 | offset += this->st_markers.deserialize(inbuffer + offset); |
garyservin | 0:9e9b7db60fd5 | 134 | memcpy( &(this->markers[i]), &(this->st_markers), sizeof(visualization_msgs::InteractiveMarker)); |
garyservin | 0:9e9b7db60fd5 | 135 | } |
garyservin | 0:9e9b7db60fd5 | 136 | uint32_t poses_lengthT = ((uint32_t) (*(inbuffer + offset))); |
garyservin | 0:9e9b7db60fd5 | 137 | poses_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:9e9b7db60fd5 | 138 | poses_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:9e9b7db60fd5 | 139 | poses_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:9e9b7db60fd5 | 140 | offset += sizeof(this->poses_length); |
garyservin | 0:9e9b7db60fd5 | 141 | if(poses_lengthT > poses_length) |
garyservin | 0:9e9b7db60fd5 | 142 | this->poses = (visualization_msgs::InteractiveMarkerPose*)realloc(this->poses, poses_lengthT * sizeof(visualization_msgs::InteractiveMarkerPose)); |
garyservin | 0:9e9b7db60fd5 | 143 | poses_length = poses_lengthT; |
garyservin | 0:9e9b7db60fd5 | 144 | for( uint32_t i = 0; i < poses_length; i++){ |
garyservin | 0:9e9b7db60fd5 | 145 | offset += this->st_poses.deserialize(inbuffer + offset); |
garyservin | 0:9e9b7db60fd5 | 146 | memcpy( &(this->poses[i]), &(this->st_poses), sizeof(visualization_msgs::InteractiveMarkerPose)); |
garyservin | 0:9e9b7db60fd5 | 147 | } |
garyservin | 0:9e9b7db60fd5 | 148 | uint32_t erases_lengthT = ((uint32_t) (*(inbuffer + offset))); |
garyservin | 0:9e9b7db60fd5 | 149 | erases_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:9e9b7db60fd5 | 150 | erases_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:9e9b7db60fd5 | 151 | erases_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:9e9b7db60fd5 | 152 | offset += sizeof(this->erases_length); |
garyservin | 0:9e9b7db60fd5 | 153 | if(erases_lengthT > erases_length) |
garyservin | 0:9e9b7db60fd5 | 154 | this->erases = (char**)realloc(this->erases, erases_lengthT * sizeof(char*)); |
garyservin | 0:9e9b7db60fd5 | 155 | erases_length = erases_lengthT; |
garyservin | 0:9e9b7db60fd5 | 156 | for( uint32_t i = 0; i < erases_length; i++){ |
garyservin | 0:9e9b7db60fd5 | 157 | uint32_t length_st_erases; |
garyservin | 0:9e9b7db60fd5 | 158 | arrToVar(length_st_erases, (inbuffer + offset)); |
garyservin | 0:9e9b7db60fd5 | 159 | offset += 4; |
garyservin | 0:9e9b7db60fd5 | 160 | for(unsigned int k= offset; k< offset+length_st_erases; ++k){ |
garyservin | 0:9e9b7db60fd5 | 161 | inbuffer[k-1]=inbuffer[k]; |
garyservin | 0:9e9b7db60fd5 | 162 | } |
garyservin | 0:9e9b7db60fd5 | 163 | inbuffer[offset+length_st_erases-1]=0; |
garyservin | 0:9e9b7db60fd5 | 164 | this->st_erases = (char *)(inbuffer + offset-1); |
garyservin | 0:9e9b7db60fd5 | 165 | offset += length_st_erases; |
garyservin | 0:9e9b7db60fd5 | 166 | memcpy( &(this->erases[i]), &(this->st_erases), sizeof(char*)); |
garyservin | 0:9e9b7db60fd5 | 167 | } |
garyservin | 0:9e9b7db60fd5 | 168 | return offset; |
garyservin | 0:9e9b7db60fd5 | 169 | } |
garyservin | 0:9e9b7db60fd5 | 170 | |
garyservin | 0:9e9b7db60fd5 | 171 | const char * getType(){ return "visualization_msgs/InteractiveMarkerUpdate"; }; |
garyservin | 0:9e9b7db60fd5 | 172 | const char * getMD5(){ return "710d308d0a9276d65945e92dd30b3946"; }; |
garyservin | 0:9e9b7db60fd5 | 173 | |
garyservin | 0:9e9b7db60fd5 | 174 | }; |
garyservin | 0:9e9b7db60fd5 | 175 | |
garyservin | 0:9e9b7db60fd5 | 176 | } |
garyservin | 0:9e9b7db60fd5 | 177 | #endif |