ros melodic library with custom message
Dependents: Robot_team1_QEI_Douglas Robot_team1
ros_lib/dynamic_reconfigure/Group.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_dynamic_reconfigure_Group_h |
scarter1 | 0:020db18a476d | 2 | #define _ROS_dynamic_reconfigure_Group_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 | #include "dynamic_reconfigure/ParamDescription.h" |
scarter1 | 0:020db18a476d | 9 | |
scarter1 | 0:020db18a476d | 10 | namespace dynamic_reconfigure |
scarter1 | 0:020db18a476d | 11 | { |
scarter1 | 0:020db18a476d | 12 | |
scarter1 | 0:020db18a476d | 13 | class Group : public ros::Msg |
scarter1 | 0:020db18a476d | 14 | { |
scarter1 | 0:020db18a476d | 15 | public: |
scarter1 | 0:020db18a476d | 16 | typedef const char* _name_type; |
scarter1 | 0:020db18a476d | 17 | _name_type name; |
scarter1 | 0:020db18a476d | 18 | typedef const char* _type_type; |
scarter1 | 0:020db18a476d | 19 | _type_type type; |
scarter1 | 0:020db18a476d | 20 | uint32_t parameters_length; |
scarter1 | 0:020db18a476d | 21 | typedef dynamic_reconfigure::ParamDescription _parameters_type; |
scarter1 | 0:020db18a476d | 22 | _parameters_type st_parameters; |
scarter1 | 0:020db18a476d | 23 | _parameters_type * parameters; |
scarter1 | 0:020db18a476d | 24 | typedef int32_t _parent_type; |
scarter1 | 0:020db18a476d | 25 | _parent_type parent; |
scarter1 | 0:020db18a476d | 26 | typedef int32_t _id_type; |
scarter1 | 0:020db18a476d | 27 | _id_type id; |
scarter1 | 0:020db18a476d | 28 | |
scarter1 | 0:020db18a476d | 29 | Group(): |
scarter1 | 0:020db18a476d | 30 | name(""), |
scarter1 | 0:020db18a476d | 31 | type(""), |
scarter1 | 0:020db18a476d | 32 | parameters_length(0), parameters(NULL), |
scarter1 | 0:020db18a476d | 33 | parent(0), |
scarter1 | 0:020db18a476d | 34 | id(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 | uint32_t length_name = strlen(this->name); |
scarter1 | 0:020db18a476d | 42 | varToArr(outbuffer + offset, length_name); |
scarter1 | 0:020db18a476d | 43 | offset += 4; |
scarter1 | 0:020db18a476d | 44 | memcpy(outbuffer + offset, this->name, length_name); |
scarter1 | 0:020db18a476d | 45 | offset += length_name; |
scarter1 | 0:020db18a476d | 46 | uint32_t length_type = strlen(this->type); |
scarter1 | 0:020db18a476d | 47 | varToArr(outbuffer + offset, length_type); |
scarter1 | 0:020db18a476d | 48 | offset += 4; |
scarter1 | 0:020db18a476d | 49 | memcpy(outbuffer + offset, this->type, length_type); |
scarter1 | 0:020db18a476d | 50 | offset += length_type; |
scarter1 | 0:020db18a476d | 51 | *(outbuffer + offset + 0) = (this->parameters_length >> (8 * 0)) & 0xFF; |
scarter1 | 0:020db18a476d | 52 | *(outbuffer + offset + 1) = (this->parameters_length >> (8 * 1)) & 0xFF; |
scarter1 | 0:020db18a476d | 53 | *(outbuffer + offset + 2) = (this->parameters_length >> (8 * 2)) & 0xFF; |
scarter1 | 0:020db18a476d | 54 | *(outbuffer + offset + 3) = (this->parameters_length >> (8 * 3)) & 0xFF; |
scarter1 | 0:020db18a476d | 55 | offset += sizeof(this->parameters_length); |
scarter1 | 0:020db18a476d | 56 | for( uint32_t i = 0; i < parameters_length; i++){ |
scarter1 | 0:020db18a476d | 57 | offset += this->parameters[i].serialize(outbuffer + offset); |
scarter1 | 0:020db18a476d | 58 | } |
scarter1 | 0:020db18a476d | 59 | union { |
scarter1 | 0:020db18a476d | 60 | int32_t real; |
scarter1 | 0:020db18a476d | 61 | uint32_t base; |
scarter1 | 0:020db18a476d | 62 | } u_parent; |
scarter1 | 0:020db18a476d | 63 | u_parent.real = this->parent; |
scarter1 | 0:020db18a476d | 64 | *(outbuffer + offset + 0) = (u_parent.base >> (8 * 0)) & 0xFF; |
scarter1 | 0:020db18a476d | 65 | *(outbuffer + offset + 1) = (u_parent.base >> (8 * 1)) & 0xFF; |
scarter1 | 0:020db18a476d | 66 | *(outbuffer + offset + 2) = (u_parent.base >> (8 * 2)) & 0xFF; |
scarter1 | 0:020db18a476d | 67 | *(outbuffer + offset + 3) = (u_parent.base >> (8 * 3)) & 0xFF; |
scarter1 | 0:020db18a476d | 68 | offset += sizeof(this->parent); |
scarter1 | 0:020db18a476d | 69 | union { |
scarter1 | 0:020db18a476d | 70 | int32_t real; |
scarter1 | 0:020db18a476d | 71 | uint32_t base; |
scarter1 | 0:020db18a476d | 72 | } u_id; |
scarter1 | 0:020db18a476d | 73 | u_id.real = this->id; |
scarter1 | 0:020db18a476d | 74 | *(outbuffer + offset + 0) = (u_id.base >> (8 * 0)) & 0xFF; |
scarter1 | 0:020db18a476d | 75 | *(outbuffer + offset + 1) = (u_id.base >> (8 * 1)) & 0xFF; |
scarter1 | 0:020db18a476d | 76 | *(outbuffer + offset + 2) = (u_id.base >> (8 * 2)) & 0xFF; |
scarter1 | 0:020db18a476d | 77 | *(outbuffer + offset + 3) = (u_id.base >> (8 * 3)) & 0xFF; |
scarter1 | 0:020db18a476d | 78 | offset += sizeof(this->id); |
scarter1 | 0:020db18a476d | 79 | return offset; |
scarter1 | 0:020db18a476d | 80 | } |
scarter1 | 0:020db18a476d | 81 | |
scarter1 | 0:020db18a476d | 82 | virtual int deserialize(unsigned char *inbuffer) |
scarter1 | 0:020db18a476d | 83 | { |
scarter1 | 0:020db18a476d | 84 | int offset = 0; |
scarter1 | 0:020db18a476d | 85 | uint32_t length_name; |
scarter1 | 0:020db18a476d | 86 | arrToVar(length_name, (inbuffer + offset)); |
scarter1 | 0:020db18a476d | 87 | offset += 4; |
scarter1 | 0:020db18a476d | 88 | for(unsigned int k= offset; k< offset+length_name; ++k){ |
scarter1 | 0:020db18a476d | 89 | inbuffer[k-1]=inbuffer[k]; |
scarter1 | 0:020db18a476d | 90 | } |
scarter1 | 0:020db18a476d | 91 | inbuffer[offset+length_name-1]=0; |
scarter1 | 0:020db18a476d | 92 | this->name = (char *)(inbuffer + offset-1); |
scarter1 | 0:020db18a476d | 93 | offset += length_name; |
scarter1 | 0:020db18a476d | 94 | uint32_t length_type; |
scarter1 | 0:020db18a476d | 95 | arrToVar(length_type, (inbuffer + offset)); |
scarter1 | 0:020db18a476d | 96 | offset += 4; |
scarter1 | 0:020db18a476d | 97 | for(unsigned int k= offset; k< offset+length_type; ++k){ |
scarter1 | 0:020db18a476d | 98 | inbuffer[k-1]=inbuffer[k]; |
scarter1 | 0:020db18a476d | 99 | } |
scarter1 | 0:020db18a476d | 100 | inbuffer[offset+length_type-1]=0; |
scarter1 | 0:020db18a476d | 101 | this->type = (char *)(inbuffer + offset-1); |
scarter1 | 0:020db18a476d | 102 | offset += length_type; |
scarter1 | 0:020db18a476d | 103 | uint32_t parameters_lengthT = ((uint32_t) (*(inbuffer + offset))); |
scarter1 | 0:020db18a476d | 104 | parameters_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
scarter1 | 0:020db18a476d | 105 | parameters_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
scarter1 | 0:020db18a476d | 106 | parameters_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
scarter1 | 0:020db18a476d | 107 | offset += sizeof(this->parameters_length); |
scarter1 | 0:020db18a476d | 108 | if(parameters_lengthT > parameters_length) |
scarter1 | 0:020db18a476d | 109 | this->parameters = (dynamic_reconfigure::ParamDescription*)realloc(this->parameters, parameters_lengthT * sizeof(dynamic_reconfigure::ParamDescription)); |
scarter1 | 0:020db18a476d | 110 | parameters_length = parameters_lengthT; |
scarter1 | 0:020db18a476d | 111 | for( uint32_t i = 0; i < parameters_length; i++){ |
scarter1 | 0:020db18a476d | 112 | offset += this->st_parameters.deserialize(inbuffer + offset); |
scarter1 | 0:020db18a476d | 113 | memcpy( &(this->parameters[i]), &(this->st_parameters), sizeof(dynamic_reconfigure::ParamDescription)); |
scarter1 | 0:020db18a476d | 114 | } |
scarter1 | 0:020db18a476d | 115 | union { |
scarter1 | 0:020db18a476d | 116 | int32_t real; |
scarter1 | 0:020db18a476d | 117 | uint32_t base; |
scarter1 | 0:020db18a476d | 118 | } u_parent; |
scarter1 | 0:020db18a476d | 119 | u_parent.base = 0; |
scarter1 | 0:020db18a476d | 120 | u_parent.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
scarter1 | 0:020db18a476d | 121 | u_parent.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
scarter1 | 0:020db18a476d | 122 | u_parent.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
scarter1 | 0:020db18a476d | 123 | u_parent.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
scarter1 | 0:020db18a476d | 124 | this->parent = u_parent.real; |
scarter1 | 0:020db18a476d | 125 | offset += sizeof(this->parent); |
scarter1 | 0:020db18a476d | 126 | union { |
scarter1 | 0:020db18a476d | 127 | int32_t real; |
scarter1 | 0:020db18a476d | 128 | uint32_t base; |
scarter1 | 0:020db18a476d | 129 | } u_id; |
scarter1 | 0:020db18a476d | 130 | u_id.base = 0; |
scarter1 | 0:020db18a476d | 131 | u_id.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
scarter1 | 0:020db18a476d | 132 | u_id.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
scarter1 | 0:020db18a476d | 133 | u_id.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
scarter1 | 0:020db18a476d | 134 | u_id.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
scarter1 | 0:020db18a476d | 135 | this->id = u_id.real; |
scarter1 | 0:020db18a476d | 136 | offset += sizeof(this->id); |
scarter1 | 0:020db18a476d | 137 | return offset; |
scarter1 | 0:020db18a476d | 138 | } |
scarter1 | 0:020db18a476d | 139 | |
scarter1 | 0:020db18a476d | 140 | const char * getType(){ return "dynamic_reconfigure/Group"; }; |
scarter1 | 0:020db18a476d | 141 | const char * getMD5(){ return "9e8cd9e9423c94823db3614dd8b1cf7a"; }; |
scarter1 | 0:020db18a476d | 142 | |
scarter1 | 0:020db18a476d | 143 | }; |
scarter1 | 0:020db18a476d | 144 | |
scarter1 | 0:020db18a476d | 145 | } |
scarter1 | 0:020db18a476d | 146 | #endif |