ros melodic library with custom message
Dependents: Robot_team1_QEI_Douglas Robot_team1
ros_lib/gazebo_msgs/ApplyBodyWrench.h@3:b964e3f71102, 2019-12-03 (annotated)
- Committer:
- florine_van
- Date:
- Tue Dec 03 09:39:29 2019 +0000
- Revision:
- 3:b964e3f71102
- Parent:
- 0:020db18a476d
Clean code and remove unused lines
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
scarter1 | 0:020db18a476d | 1 | #ifndef _ROS_SERVICE_ApplyBodyWrench_h |
scarter1 | 0:020db18a476d | 2 | #define _ROS_SERVICE_ApplyBodyWrench_h |
scarter1 | 0:020db18a476d | 3 | #include <stdint.h> |
scarter1 | 0:020db18a476d | 4 | #include <string.h> |
scarter1 | 0:020db18a476d | 5 | #include <stdlib.h> |
scarter1 | 0:020db18a476d | 6 | #include "ros/msg.h" |
scarter1 | 0:020db18a476d | 7 | #include "ros/duration.h" |
scarter1 | 0:020db18a476d | 8 | #include "geometry_msgs/Wrench.h" |
scarter1 | 0:020db18a476d | 9 | #include "ros/time.h" |
scarter1 | 0:020db18a476d | 10 | #include "geometry_msgs/Point.h" |
scarter1 | 0:020db18a476d | 11 | |
scarter1 | 0:020db18a476d | 12 | namespace gazebo_msgs |
scarter1 | 0:020db18a476d | 13 | { |
scarter1 | 0:020db18a476d | 14 | |
scarter1 | 0:020db18a476d | 15 | static const char APPLYBODYWRENCH[] = "gazebo_msgs/ApplyBodyWrench"; |
scarter1 | 0:020db18a476d | 16 | |
scarter1 | 0:020db18a476d | 17 | class ApplyBodyWrenchRequest : public ros::Msg |
scarter1 | 0:020db18a476d | 18 | { |
scarter1 | 0:020db18a476d | 19 | public: |
scarter1 | 0:020db18a476d | 20 | typedef const char* _body_name_type; |
scarter1 | 0:020db18a476d | 21 | _body_name_type body_name; |
scarter1 | 0:020db18a476d | 22 | typedef const char* _reference_frame_type; |
scarter1 | 0:020db18a476d | 23 | _reference_frame_type reference_frame; |
scarter1 | 0:020db18a476d | 24 | typedef geometry_msgs::Point _reference_point_type; |
scarter1 | 0:020db18a476d | 25 | _reference_point_type reference_point; |
scarter1 | 0:020db18a476d | 26 | typedef geometry_msgs::Wrench _wrench_type; |
scarter1 | 0:020db18a476d | 27 | _wrench_type wrench; |
scarter1 | 0:020db18a476d | 28 | typedef ros::Time _start_time_type; |
scarter1 | 0:020db18a476d | 29 | _start_time_type start_time; |
scarter1 | 0:020db18a476d | 30 | typedef ros::Duration _duration_type; |
scarter1 | 0:020db18a476d | 31 | _duration_type duration; |
scarter1 | 0:020db18a476d | 32 | |
scarter1 | 0:020db18a476d | 33 | ApplyBodyWrenchRequest(): |
scarter1 | 0:020db18a476d | 34 | body_name(""), |
scarter1 | 0:020db18a476d | 35 | reference_frame(""), |
scarter1 | 0:020db18a476d | 36 | reference_point(), |
scarter1 | 0:020db18a476d | 37 | wrench(), |
scarter1 | 0:020db18a476d | 38 | start_time(), |
scarter1 | 0:020db18a476d | 39 | duration() |
scarter1 | 0:020db18a476d | 40 | { |
scarter1 | 0:020db18a476d | 41 | } |
scarter1 | 0:020db18a476d | 42 | |
scarter1 | 0:020db18a476d | 43 | virtual int serialize(unsigned char *outbuffer) const |
scarter1 | 0:020db18a476d | 44 | { |
scarter1 | 0:020db18a476d | 45 | int offset = 0; |
scarter1 | 0:020db18a476d | 46 | uint32_t length_body_name = strlen(this->body_name); |
scarter1 | 0:020db18a476d | 47 | varToArr(outbuffer + offset, length_body_name); |
scarter1 | 0:020db18a476d | 48 | offset += 4; |
scarter1 | 0:020db18a476d | 49 | memcpy(outbuffer + offset, this->body_name, length_body_name); |
scarter1 | 0:020db18a476d | 50 | offset += length_body_name; |
scarter1 | 0:020db18a476d | 51 | uint32_t length_reference_frame = strlen(this->reference_frame); |
scarter1 | 0:020db18a476d | 52 | varToArr(outbuffer + offset, length_reference_frame); |
scarter1 | 0:020db18a476d | 53 | offset += 4; |
scarter1 | 0:020db18a476d | 54 | memcpy(outbuffer + offset, this->reference_frame, length_reference_frame); |
scarter1 | 0:020db18a476d | 55 | offset += length_reference_frame; |
scarter1 | 0:020db18a476d | 56 | offset += this->reference_point.serialize(outbuffer + offset); |
scarter1 | 0:020db18a476d | 57 | offset += this->wrench.serialize(outbuffer + offset); |
scarter1 | 0:020db18a476d | 58 | *(outbuffer + offset + 0) = (this->start_time.sec >> (8 * 0)) & 0xFF; |
scarter1 | 0:020db18a476d | 59 | *(outbuffer + offset + 1) = (this->start_time.sec >> (8 * 1)) & 0xFF; |
scarter1 | 0:020db18a476d | 60 | *(outbuffer + offset + 2) = (this->start_time.sec >> (8 * 2)) & 0xFF; |
scarter1 | 0:020db18a476d | 61 | *(outbuffer + offset + 3) = (this->start_time.sec >> (8 * 3)) & 0xFF; |
scarter1 | 0:020db18a476d | 62 | offset += sizeof(this->start_time.sec); |
scarter1 | 0:020db18a476d | 63 | *(outbuffer + offset + 0) = (this->start_time.nsec >> (8 * 0)) & 0xFF; |
scarter1 | 0:020db18a476d | 64 | *(outbuffer + offset + 1) = (this->start_time.nsec >> (8 * 1)) & 0xFF; |
scarter1 | 0:020db18a476d | 65 | *(outbuffer + offset + 2) = (this->start_time.nsec >> (8 * 2)) & 0xFF; |
scarter1 | 0:020db18a476d | 66 | *(outbuffer + offset + 3) = (this->start_time.nsec >> (8 * 3)) & 0xFF; |
scarter1 | 0:020db18a476d | 67 | offset += sizeof(this->start_time.nsec); |
scarter1 | 0:020db18a476d | 68 | *(outbuffer + offset + 0) = (this->duration.sec >> (8 * 0)) & 0xFF; |
scarter1 | 0:020db18a476d | 69 | *(outbuffer + offset + 1) = (this->duration.sec >> (8 * 1)) & 0xFF; |
scarter1 | 0:020db18a476d | 70 | *(outbuffer + offset + 2) = (this->duration.sec >> (8 * 2)) & 0xFF; |
scarter1 | 0:020db18a476d | 71 | *(outbuffer + offset + 3) = (this->duration.sec >> (8 * 3)) & 0xFF; |
scarter1 | 0:020db18a476d | 72 | offset += sizeof(this->duration.sec); |
scarter1 | 0:020db18a476d | 73 | *(outbuffer + offset + 0) = (this->duration.nsec >> (8 * 0)) & 0xFF; |
scarter1 | 0:020db18a476d | 74 | *(outbuffer + offset + 1) = (this->duration.nsec >> (8 * 1)) & 0xFF; |
scarter1 | 0:020db18a476d | 75 | *(outbuffer + offset + 2) = (this->duration.nsec >> (8 * 2)) & 0xFF; |
scarter1 | 0:020db18a476d | 76 | *(outbuffer + offset + 3) = (this->duration.nsec >> (8 * 3)) & 0xFF; |
scarter1 | 0:020db18a476d | 77 | offset += sizeof(this->duration.nsec); |
scarter1 | 0:020db18a476d | 78 | return offset; |
scarter1 | 0:020db18a476d | 79 | } |
scarter1 | 0:020db18a476d | 80 | |
scarter1 | 0:020db18a476d | 81 | virtual int deserialize(unsigned char *inbuffer) |
scarter1 | 0:020db18a476d | 82 | { |
scarter1 | 0:020db18a476d | 83 | int offset = 0; |
scarter1 | 0:020db18a476d | 84 | uint32_t length_body_name; |
scarter1 | 0:020db18a476d | 85 | arrToVar(length_body_name, (inbuffer + offset)); |
scarter1 | 0:020db18a476d | 86 | offset += 4; |
scarter1 | 0:020db18a476d | 87 | for(unsigned int k= offset; k< offset+length_body_name; ++k){ |
scarter1 | 0:020db18a476d | 88 | inbuffer[k-1]=inbuffer[k]; |
scarter1 | 0:020db18a476d | 89 | } |
scarter1 | 0:020db18a476d | 90 | inbuffer[offset+length_body_name-1]=0; |
scarter1 | 0:020db18a476d | 91 | this->body_name = (char *)(inbuffer + offset-1); |
scarter1 | 0:020db18a476d | 92 | offset += length_body_name; |
scarter1 | 0:020db18a476d | 93 | uint32_t length_reference_frame; |
scarter1 | 0:020db18a476d | 94 | arrToVar(length_reference_frame, (inbuffer + offset)); |
scarter1 | 0:020db18a476d | 95 | offset += 4; |
scarter1 | 0:020db18a476d | 96 | for(unsigned int k= offset; k< offset+length_reference_frame; ++k){ |
scarter1 | 0:020db18a476d | 97 | inbuffer[k-1]=inbuffer[k]; |
scarter1 | 0:020db18a476d | 98 | } |
scarter1 | 0:020db18a476d | 99 | inbuffer[offset+length_reference_frame-1]=0; |
scarter1 | 0:020db18a476d | 100 | this->reference_frame = (char *)(inbuffer + offset-1); |
scarter1 | 0:020db18a476d | 101 | offset += length_reference_frame; |
scarter1 | 0:020db18a476d | 102 | offset += this->reference_point.deserialize(inbuffer + offset); |
scarter1 | 0:020db18a476d | 103 | offset += this->wrench.deserialize(inbuffer + offset); |
scarter1 | 0:020db18a476d | 104 | this->start_time.sec = ((uint32_t) (*(inbuffer + offset))); |
scarter1 | 0:020db18a476d | 105 | this->start_time.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
scarter1 | 0:020db18a476d | 106 | this->start_time.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
scarter1 | 0:020db18a476d | 107 | this->start_time.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
scarter1 | 0:020db18a476d | 108 | offset += sizeof(this->start_time.sec); |
scarter1 | 0:020db18a476d | 109 | this->start_time.nsec = ((uint32_t) (*(inbuffer + offset))); |
scarter1 | 0:020db18a476d | 110 | this->start_time.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
scarter1 | 0:020db18a476d | 111 | this->start_time.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
scarter1 | 0:020db18a476d | 112 | this->start_time.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
scarter1 | 0:020db18a476d | 113 | offset += sizeof(this->start_time.nsec); |
scarter1 | 0:020db18a476d | 114 | this->duration.sec = ((uint32_t) (*(inbuffer + offset))); |
scarter1 | 0:020db18a476d | 115 | this->duration.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
scarter1 | 0:020db18a476d | 116 | this->duration.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
scarter1 | 0:020db18a476d | 117 | this->duration.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
scarter1 | 0:020db18a476d | 118 | offset += sizeof(this->duration.sec); |
scarter1 | 0:020db18a476d | 119 | this->duration.nsec = ((uint32_t) (*(inbuffer + offset))); |
scarter1 | 0:020db18a476d | 120 | this->duration.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
scarter1 | 0:020db18a476d | 121 | this->duration.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
scarter1 | 0:020db18a476d | 122 | this->duration.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
scarter1 | 0:020db18a476d | 123 | offset += sizeof(this->duration.nsec); |
scarter1 | 0:020db18a476d | 124 | return offset; |
scarter1 | 0:020db18a476d | 125 | } |
scarter1 | 0:020db18a476d | 126 | |
scarter1 | 0:020db18a476d | 127 | const char * getType(){ return APPLYBODYWRENCH; }; |
scarter1 | 0:020db18a476d | 128 | const char * getMD5(){ return "e37e6adf97eba5095baa77dffb71e5bd"; }; |
scarter1 | 0:020db18a476d | 129 | |
scarter1 | 0:020db18a476d | 130 | }; |
scarter1 | 0:020db18a476d | 131 | |
scarter1 | 0:020db18a476d | 132 | class ApplyBodyWrenchResponse : public ros::Msg |
scarter1 | 0:020db18a476d | 133 | { |
scarter1 | 0:020db18a476d | 134 | public: |
scarter1 | 0:020db18a476d | 135 | typedef bool _success_type; |
scarter1 | 0:020db18a476d | 136 | _success_type success; |
scarter1 | 0:020db18a476d | 137 | typedef const char* _status_message_type; |
scarter1 | 0:020db18a476d | 138 | _status_message_type status_message; |
scarter1 | 0:020db18a476d | 139 | |
scarter1 | 0:020db18a476d | 140 | ApplyBodyWrenchResponse(): |
scarter1 | 0:020db18a476d | 141 | success(0), |
scarter1 | 0:020db18a476d | 142 | status_message("") |
scarter1 | 0:020db18a476d | 143 | { |
scarter1 | 0:020db18a476d | 144 | } |
scarter1 | 0:020db18a476d | 145 | |
scarter1 | 0:020db18a476d | 146 | virtual int serialize(unsigned char *outbuffer) const |
scarter1 | 0:020db18a476d | 147 | { |
scarter1 | 0:020db18a476d | 148 | int offset = 0; |
scarter1 | 0:020db18a476d | 149 | union { |
scarter1 | 0:020db18a476d | 150 | bool real; |
scarter1 | 0:020db18a476d | 151 | uint8_t base; |
scarter1 | 0:020db18a476d | 152 | } u_success; |
scarter1 | 0:020db18a476d | 153 | u_success.real = this->success; |
scarter1 | 0:020db18a476d | 154 | *(outbuffer + offset + 0) = (u_success.base >> (8 * 0)) & 0xFF; |
scarter1 | 0:020db18a476d | 155 | offset += sizeof(this->success); |
scarter1 | 0:020db18a476d | 156 | uint32_t length_status_message = strlen(this->status_message); |
scarter1 | 0:020db18a476d | 157 | varToArr(outbuffer + offset, length_status_message); |
scarter1 | 0:020db18a476d | 158 | offset += 4; |
scarter1 | 0:020db18a476d | 159 | memcpy(outbuffer + offset, this->status_message, length_status_message); |
scarter1 | 0:020db18a476d | 160 | offset += length_status_message; |
scarter1 | 0:020db18a476d | 161 | return offset; |
scarter1 | 0:020db18a476d | 162 | } |
scarter1 | 0:020db18a476d | 163 | |
scarter1 | 0:020db18a476d | 164 | virtual int deserialize(unsigned char *inbuffer) |
scarter1 | 0:020db18a476d | 165 | { |
scarter1 | 0:020db18a476d | 166 | int offset = 0; |
scarter1 | 0:020db18a476d | 167 | union { |
scarter1 | 0:020db18a476d | 168 | bool real; |
scarter1 | 0:020db18a476d | 169 | uint8_t base; |
scarter1 | 0:020db18a476d | 170 | } u_success; |
scarter1 | 0:020db18a476d | 171 | u_success.base = 0; |
scarter1 | 0:020db18a476d | 172 | u_success.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); |
scarter1 | 0:020db18a476d | 173 | this->success = u_success.real; |
scarter1 | 0:020db18a476d | 174 | offset += sizeof(this->success); |
scarter1 | 0:020db18a476d | 175 | uint32_t length_status_message; |
scarter1 | 0:020db18a476d | 176 | arrToVar(length_status_message, (inbuffer + offset)); |
scarter1 | 0:020db18a476d | 177 | offset += 4; |
scarter1 | 0:020db18a476d | 178 | for(unsigned int k= offset; k< offset+length_status_message; ++k){ |
scarter1 | 0:020db18a476d | 179 | inbuffer[k-1]=inbuffer[k]; |
scarter1 | 0:020db18a476d | 180 | } |
scarter1 | 0:020db18a476d | 181 | inbuffer[offset+length_status_message-1]=0; |
scarter1 | 0:020db18a476d | 182 | this->status_message = (char *)(inbuffer + offset-1); |
scarter1 | 0:020db18a476d | 183 | offset += length_status_message; |
scarter1 | 0:020db18a476d | 184 | return offset; |
scarter1 | 0:020db18a476d | 185 | } |
scarter1 | 0:020db18a476d | 186 | |
scarter1 | 0:020db18a476d | 187 | const char * getType(){ return APPLYBODYWRENCH; }; |
scarter1 | 0:020db18a476d | 188 | const char * getMD5(){ return "2ec6f3eff0161f4257b808b12bc830c2"; }; |
scarter1 | 0:020db18a476d | 189 | |
scarter1 | 0:020db18a476d | 190 | }; |
scarter1 | 0:020db18a476d | 191 | |
scarter1 | 0:020db18a476d | 192 | class ApplyBodyWrench { |
scarter1 | 0:020db18a476d | 193 | public: |
scarter1 | 0:020db18a476d | 194 | typedef ApplyBodyWrenchRequest Request; |
scarter1 | 0:020db18a476d | 195 | typedef ApplyBodyWrenchResponse Response; |
scarter1 | 0:020db18a476d | 196 | }; |
scarter1 | 0:020db18a476d | 197 | |
scarter1 | 0:020db18a476d | 198 | } |
scarter1 | 0:020db18a476d | 199 | #endif |