ros melodic library with custom message
Dependents: Robot_team1_QEI_Douglas Robot_team1
ros_lib/visualization_msgs/MenuEntry.h@0:020db18a476d, 2019-10-30 (annotated)
- Committer:
- scarter1
- Date:
- Wed Oct 30 14:59:49 2019 +0000
- Revision:
- 0:020db18a476d
melodic library;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
scarter1 | 0:020db18a476d | 1 | #ifndef _ROS_visualization_msgs_MenuEntry_h |
scarter1 | 0:020db18a476d | 2 | #define _ROS_visualization_msgs_MenuEntry_h |
scarter1 | 0:020db18a476d | 3 | |
scarter1 | 0:020db18a476d | 4 | #include <stdint.h> |
scarter1 | 0:020db18a476d | 5 | #include <string.h> |
scarter1 | 0:020db18a476d | 6 | #include <stdlib.h> |
scarter1 | 0:020db18a476d | 7 | #include "ros/msg.h" |
scarter1 | 0:020db18a476d | 8 | |
scarter1 | 0:020db18a476d | 9 | namespace visualization_msgs |
scarter1 | 0:020db18a476d | 10 | { |
scarter1 | 0:020db18a476d | 11 | |
scarter1 | 0:020db18a476d | 12 | class MenuEntry : public ros::Msg |
scarter1 | 0:020db18a476d | 13 | { |
scarter1 | 0:020db18a476d | 14 | public: |
scarter1 | 0:020db18a476d | 15 | typedef uint32_t _id_type; |
scarter1 | 0:020db18a476d | 16 | _id_type id; |
scarter1 | 0:020db18a476d | 17 | typedef uint32_t _parent_id_type; |
scarter1 | 0:020db18a476d | 18 | _parent_id_type parent_id; |
scarter1 | 0:020db18a476d | 19 | typedef const char* _title_type; |
scarter1 | 0:020db18a476d | 20 | _title_type title; |
scarter1 | 0:020db18a476d | 21 | typedef const char* _command_type; |
scarter1 | 0:020db18a476d | 22 | _command_type command; |
scarter1 | 0:020db18a476d | 23 | typedef uint8_t _command_type_type; |
scarter1 | 0:020db18a476d | 24 | _command_type_type command_type; |
scarter1 | 0:020db18a476d | 25 | enum { FEEDBACK = 0 }; |
scarter1 | 0:020db18a476d | 26 | enum { ROSRUN = 1 }; |
scarter1 | 0:020db18a476d | 27 | enum { ROSLAUNCH = 2 }; |
scarter1 | 0:020db18a476d | 28 | |
scarter1 | 0:020db18a476d | 29 | MenuEntry(): |
scarter1 | 0:020db18a476d | 30 | id(0), |
scarter1 | 0:020db18a476d | 31 | parent_id(0), |
scarter1 | 0:020db18a476d | 32 | title(""), |
scarter1 | 0:020db18a476d | 33 | command(""), |
scarter1 | 0:020db18a476d | 34 | command_type(0) |
scarter1 | 0:020db18a476d | 35 | { |
scarter1 | 0:020db18a476d | 36 | } |
scarter1 | 0:020db18a476d | 37 | |
scarter1 | 0:020db18a476d | 38 | virtual int serialize(unsigned char *outbuffer) const |
scarter1 | 0:020db18a476d | 39 | { |
scarter1 | 0:020db18a476d | 40 | int offset = 0; |
scarter1 | 0:020db18a476d | 41 | *(outbuffer + offset + 0) = (this->id >> (8 * 0)) & 0xFF; |
scarter1 | 0:020db18a476d | 42 | *(outbuffer + offset + 1) = (this->id >> (8 * 1)) & 0xFF; |
scarter1 | 0:020db18a476d | 43 | *(outbuffer + offset + 2) = (this->id >> (8 * 2)) & 0xFF; |
scarter1 | 0:020db18a476d | 44 | *(outbuffer + offset + 3) = (this->id >> (8 * 3)) & 0xFF; |
scarter1 | 0:020db18a476d | 45 | offset += sizeof(this->id); |
scarter1 | 0:020db18a476d | 46 | *(outbuffer + offset + 0) = (this->parent_id >> (8 * 0)) & 0xFF; |
scarter1 | 0:020db18a476d | 47 | *(outbuffer + offset + 1) = (this->parent_id >> (8 * 1)) & 0xFF; |
scarter1 | 0:020db18a476d | 48 | *(outbuffer + offset + 2) = (this->parent_id >> (8 * 2)) & 0xFF; |
scarter1 | 0:020db18a476d | 49 | *(outbuffer + offset + 3) = (this->parent_id >> (8 * 3)) & 0xFF; |
scarter1 | 0:020db18a476d | 50 | offset += sizeof(this->parent_id); |
scarter1 | 0:020db18a476d | 51 | uint32_t length_title = strlen(this->title); |
scarter1 | 0:020db18a476d | 52 | varToArr(outbuffer + offset, length_title); |
scarter1 | 0:020db18a476d | 53 | offset += 4; |
scarter1 | 0:020db18a476d | 54 | memcpy(outbuffer + offset, this->title, length_title); |
scarter1 | 0:020db18a476d | 55 | offset += length_title; |
scarter1 | 0:020db18a476d | 56 | uint32_t length_command = strlen(this->command); |
scarter1 | 0:020db18a476d | 57 | varToArr(outbuffer + offset, length_command); |
scarter1 | 0:020db18a476d | 58 | offset += 4; |
scarter1 | 0:020db18a476d | 59 | memcpy(outbuffer + offset, this->command, length_command); |
scarter1 | 0:020db18a476d | 60 | offset += length_command; |
scarter1 | 0:020db18a476d | 61 | *(outbuffer + offset + 0) = (this->command_type >> (8 * 0)) & 0xFF; |
scarter1 | 0:020db18a476d | 62 | offset += sizeof(this->command_type); |
scarter1 | 0:020db18a476d | 63 | return offset; |
scarter1 | 0:020db18a476d | 64 | } |
scarter1 | 0:020db18a476d | 65 | |
scarter1 | 0:020db18a476d | 66 | virtual int deserialize(unsigned char *inbuffer) |
scarter1 | 0:020db18a476d | 67 | { |
scarter1 | 0:020db18a476d | 68 | int offset = 0; |
scarter1 | 0:020db18a476d | 69 | this->id = ((uint32_t) (*(inbuffer + offset))); |
scarter1 | 0:020db18a476d | 70 | this->id |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
scarter1 | 0:020db18a476d | 71 | this->id |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
scarter1 | 0:020db18a476d | 72 | this->id |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
scarter1 | 0:020db18a476d | 73 | offset += sizeof(this->id); |
scarter1 | 0:020db18a476d | 74 | this->parent_id = ((uint32_t) (*(inbuffer + offset))); |
scarter1 | 0:020db18a476d | 75 | this->parent_id |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
scarter1 | 0:020db18a476d | 76 | this->parent_id |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
scarter1 | 0:020db18a476d | 77 | this->parent_id |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
scarter1 | 0:020db18a476d | 78 | offset += sizeof(this->parent_id); |
scarter1 | 0:020db18a476d | 79 | uint32_t length_title; |
scarter1 | 0:020db18a476d | 80 | arrToVar(length_title, (inbuffer + offset)); |
scarter1 | 0:020db18a476d | 81 | offset += 4; |
scarter1 | 0:020db18a476d | 82 | for(unsigned int k= offset; k< offset+length_title; ++k){ |
scarter1 | 0:020db18a476d | 83 | inbuffer[k-1]=inbuffer[k]; |
scarter1 | 0:020db18a476d | 84 | } |
scarter1 | 0:020db18a476d | 85 | inbuffer[offset+length_title-1]=0; |
scarter1 | 0:020db18a476d | 86 | this->title = (char *)(inbuffer + offset-1); |
scarter1 | 0:020db18a476d | 87 | offset += length_title; |
scarter1 | 0:020db18a476d | 88 | uint32_t length_command; |
scarter1 | 0:020db18a476d | 89 | arrToVar(length_command, (inbuffer + offset)); |
scarter1 | 0:020db18a476d | 90 | offset += 4; |
scarter1 | 0:020db18a476d | 91 | for(unsigned int k= offset; k< offset+length_command; ++k){ |
scarter1 | 0:020db18a476d | 92 | inbuffer[k-1]=inbuffer[k]; |
scarter1 | 0:020db18a476d | 93 | } |
scarter1 | 0:020db18a476d | 94 | inbuffer[offset+length_command-1]=0; |
scarter1 | 0:020db18a476d | 95 | this->command = (char *)(inbuffer + offset-1); |
scarter1 | 0:020db18a476d | 96 | offset += length_command; |
scarter1 | 0:020db18a476d | 97 | this->command_type = ((uint8_t) (*(inbuffer + offset))); |
scarter1 | 0:020db18a476d | 98 | offset += sizeof(this->command_type); |
scarter1 | 0:020db18a476d | 99 | return offset; |
scarter1 | 0:020db18a476d | 100 | } |
scarter1 | 0:020db18a476d | 101 | |
scarter1 | 0:020db18a476d | 102 | const char * getType(){ return "visualization_msgs/MenuEntry"; }; |
scarter1 | 0:020db18a476d | 103 | const char * getMD5(){ return "b90ec63024573de83b57aa93eb39be2d"; }; |
scarter1 | 0:020db18a476d | 104 | |
scarter1 | 0:020db18a476d | 105 | }; |
scarter1 | 0:020db18a476d | 106 | |
scarter1 | 0:020db18a476d | 107 | } |
scarter1 | 0:020db18a476d | 108 | #endif |