Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
MyRosCmd.h
00001 #ifndef _ROS_catchrobo_msgs_MyRosCmd_h 00002 #define _ROS_catchrobo_msgs_MyRosCmd_h 00003 00004 #include <stdint.h> 00005 #include <string.h> 00006 #include <stdlib.h> 00007 #include "ros/msg.h" 00008 00009 namespace catchrobo_msgs 00010 { 00011 00012 class MyRosCmd : public ros::Msg 00013 { 00014 public: 00015 typedef uint8_t _id_type; 00016 _id_type id; 00017 typedef uint8_t _mode_type; 00018 _mode_type mode; 00019 typedef float _position_type; 00020 _position_type position; 00021 typedef float _velocity_type; 00022 _velocity_type velocity; 00023 typedef float _effort_type; 00024 _effort_type effort; 00025 typedef float _net_inertia_type; 00026 _net_inertia_type net_inertia; 00027 typedef float _position_min_type; 00028 _position_min_type position_min; 00029 typedef float _position_max_type; 00030 _position_max_type position_max; 00031 typedef float _velocity_limit_type; 00032 _velocity_limit_type velocity_limit; 00033 typedef float _acceleration_limit_type; 00034 _acceleration_limit_type acceleration_limit; 00035 typedef float _jerk_limit_type; 00036 _jerk_limit_type jerk_limit; 00037 typedef float _kp_type; 00038 _kp_type kp; 00039 typedef float _kd_type; 00040 _kd_type kd; 00041 enum { DIRECT_CTRL_MODE = 0 }; 00042 enum { POSITION_CTRL_MODE = 1 }; 00043 enum { PEG_IN_HOLE_MODE = 2 }; 00044 enum { GO_ORIGIN_MODE = 3 }; 00045 enum { VELOCITY_CTRL_MODE = 4 }; 00046 00047 MyRosCmd(): 00048 id(0), 00049 mode(0), 00050 position(0), 00051 velocity(0), 00052 effort(0), 00053 net_inertia(0), 00054 position_min(0), 00055 position_max(0), 00056 velocity_limit(0), 00057 acceleration_limit(0), 00058 jerk_limit(0), 00059 kp(0), 00060 kd(0) 00061 { 00062 } 00063 00064 virtual int serialize(unsigned char *outbuffer) const 00065 { 00066 int offset = 0; 00067 *(outbuffer + offset + 0) = (this->id >> (8 * 0)) & 0xFF; 00068 offset += sizeof(this->id); 00069 *(outbuffer + offset + 0) = (this->mode >> (8 * 0)) & 0xFF; 00070 offset += sizeof(this->mode); 00071 union { 00072 float real; 00073 uint32_t base; 00074 } u_position; 00075 u_position.real = this->position; 00076 *(outbuffer + offset + 0) = (u_position.base >> (8 * 0)) & 0xFF; 00077 *(outbuffer + offset + 1) = (u_position.base >> (8 * 1)) & 0xFF; 00078 *(outbuffer + offset + 2) = (u_position.base >> (8 * 2)) & 0xFF; 00079 *(outbuffer + offset + 3) = (u_position.base >> (8 * 3)) & 0xFF; 00080 offset += sizeof(this->position); 00081 union { 00082 float real; 00083 uint32_t base; 00084 } u_velocity; 00085 u_velocity.real = this->velocity; 00086 *(outbuffer + offset + 0) = (u_velocity.base >> (8 * 0)) & 0xFF; 00087 *(outbuffer + offset + 1) = (u_velocity.base >> (8 * 1)) & 0xFF; 00088 *(outbuffer + offset + 2) = (u_velocity.base >> (8 * 2)) & 0xFF; 00089 *(outbuffer + offset + 3) = (u_velocity.base >> (8 * 3)) & 0xFF; 00090 offset += sizeof(this->velocity); 00091 union { 00092 float real; 00093 uint32_t base; 00094 } u_effort; 00095 u_effort.real = this->effort; 00096 *(outbuffer + offset + 0) = (u_effort.base >> (8 * 0)) & 0xFF; 00097 *(outbuffer + offset + 1) = (u_effort.base >> (8 * 1)) & 0xFF; 00098 *(outbuffer + offset + 2) = (u_effort.base >> (8 * 2)) & 0xFF; 00099 *(outbuffer + offset + 3) = (u_effort.base >> (8 * 3)) & 0xFF; 00100 offset += sizeof(this->effort); 00101 union { 00102 float real; 00103 uint32_t base; 00104 } u_net_inertia; 00105 u_net_inertia.real = this->net_inertia; 00106 *(outbuffer + offset + 0) = (u_net_inertia.base >> (8 * 0)) & 0xFF; 00107 *(outbuffer + offset + 1) = (u_net_inertia.base >> (8 * 1)) & 0xFF; 00108 *(outbuffer + offset + 2) = (u_net_inertia.base >> (8 * 2)) & 0xFF; 00109 *(outbuffer + offset + 3) = (u_net_inertia.base >> (8 * 3)) & 0xFF; 00110 offset += sizeof(this->net_inertia); 00111 union { 00112 float real; 00113 uint32_t base; 00114 } u_position_min; 00115 u_position_min.real = this->position_min; 00116 *(outbuffer + offset + 0) = (u_position_min.base >> (8 * 0)) & 0xFF; 00117 *(outbuffer + offset + 1) = (u_position_min.base >> (8 * 1)) & 0xFF; 00118 *(outbuffer + offset + 2) = (u_position_min.base >> (8 * 2)) & 0xFF; 00119 *(outbuffer + offset + 3) = (u_position_min.base >> (8 * 3)) & 0xFF; 00120 offset += sizeof(this->position_min); 00121 union { 00122 float real; 00123 uint32_t base; 00124 } u_position_max; 00125 u_position_max.real = this->position_max; 00126 *(outbuffer + offset + 0) = (u_position_max.base >> (8 * 0)) & 0xFF; 00127 *(outbuffer + offset + 1) = (u_position_max.base >> (8 * 1)) & 0xFF; 00128 *(outbuffer + offset + 2) = (u_position_max.base >> (8 * 2)) & 0xFF; 00129 *(outbuffer + offset + 3) = (u_position_max.base >> (8 * 3)) & 0xFF; 00130 offset += sizeof(this->position_max); 00131 union { 00132 float real; 00133 uint32_t base; 00134 } u_velocity_limit; 00135 u_velocity_limit.real = this->velocity_limit; 00136 *(outbuffer + offset + 0) = (u_velocity_limit.base >> (8 * 0)) & 0xFF; 00137 *(outbuffer + offset + 1) = (u_velocity_limit.base >> (8 * 1)) & 0xFF; 00138 *(outbuffer + offset + 2) = (u_velocity_limit.base >> (8 * 2)) & 0xFF; 00139 *(outbuffer + offset + 3) = (u_velocity_limit.base >> (8 * 3)) & 0xFF; 00140 offset += sizeof(this->velocity_limit); 00141 union { 00142 float real; 00143 uint32_t base; 00144 } u_acceleration_limit; 00145 u_acceleration_limit.real = this->acceleration_limit; 00146 *(outbuffer + offset + 0) = (u_acceleration_limit.base >> (8 * 0)) & 0xFF; 00147 *(outbuffer + offset + 1) = (u_acceleration_limit.base >> (8 * 1)) & 0xFF; 00148 *(outbuffer + offset + 2) = (u_acceleration_limit.base >> (8 * 2)) & 0xFF; 00149 *(outbuffer + offset + 3) = (u_acceleration_limit.base >> (8 * 3)) & 0xFF; 00150 offset += sizeof(this->acceleration_limit); 00151 union { 00152 float real; 00153 uint32_t base; 00154 } u_jerk_limit; 00155 u_jerk_limit.real = this->jerk_limit; 00156 *(outbuffer + offset + 0) = (u_jerk_limit.base >> (8 * 0)) & 0xFF; 00157 *(outbuffer + offset + 1) = (u_jerk_limit.base >> (8 * 1)) & 0xFF; 00158 *(outbuffer + offset + 2) = (u_jerk_limit.base >> (8 * 2)) & 0xFF; 00159 *(outbuffer + offset + 3) = (u_jerk_limit.base >> (8 * 3)) & 0xFF; 00160 offset += sizeof(this->jerk_limit); 00161 union { 00162 float real; 00163 uint32_t base; 00164 } u_kp; 00165 u_kp.real = this->kp; 00166 *(outbuffer + offset + 0) = (u_kp.base >> (8 * 0)) & 0xFF; 00167 *(outbuffer + offset + 1) = (u_kp.base >> (8 * 1)) & 0xFF; 00168 *(outbuffer + offset + 2) = (u_kp.base >> (8 * 2)) & 0xFF; 00169 *(outbuffer + offset + 3) = (u_kp.base >> (8 * 3)) & 0xFF; 00170 offset += sizeof(this->kp); 00171 union { 00172 float real; 00173 uint32_t base; 00174 } u_kd; 00175 u_kd.real = this->kd; 00176 *(outbuffer + offset + 0) = (u_kd.base >> (8 * 0)) & 0xFF; 00177 *(outbuffer + offset + 1) = (u_kd.base >> (8 * 1)) & 0xFF; 00178 *(outbuffer + offset + 2) = (u_kd.base >> (8 * 2)) & 0xFF; 00179 *(outbuffer + offset + 3) = (u_kd.base >> (8 * 3)) & 0xFF; 00180 offset += sizeof(this->kd); 00181 return offset; 00182 } 00183 00184 virtual int deserialize(unsigned char *inbuffer) 00185 { 00186 int offset = 0; 00187 this->id = ((uint8_t) (*(inbuffer + offset))); 00188 offset += sizeof(this->id); 00189 this->mode = ((uint8_t) (*(inbuffer + offset))); 00190 offset += sizeof(this->mode); 00191 union { 00192 float real; 00193 uint32_t base; 00194 } u_position; 00195 u_position.base = 0; 00196 u_position.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00197 u_position.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00198 u_position.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00199 u_position.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00200 this->position = u_position.real; 00201 offset += sizeof(this->position); 00202 union { 00203 float real; 00204 uint32_t base; 00205 } u_velocity; 00206 u_velocity.base = 0; 00207 u_velocity.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00208 u_velocity.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00209 u_velocity.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00210 u_velocity.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00211 this->velocity = u_velocity.real; 00212 offset += sizeof(this->velocity); 00213 union { 00214 float real; 00215 uint32_t base; 00216 } u_effort; 00217 u_effort.base = 0; 00218 u_effort.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00219 u_effort.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00220 u_effort.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00221 u_effort.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00222 this->effort = u_effort.real; 00223 offset += sizeof(this->effort); 00224 union { 00225 float real; 00226 uint32_t base; 00227 } u_net_inertia; 00228 u_net_inertia.base = 0; 00229 u_net_inertia.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00230 u_net_inertia.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00231 u_net_inertia.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00232 u_net_inertia.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00233 this->net_inertia = u_net_inertia.real; 00234 offset += sizeof(this->net_inertia); 00235 union { 00236 float real; 00237 uint32_t base; 00238 } u_position_min; 00239 u_position_min.base = 0; 00240 u_position_min.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00241 u_position_min.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00242 u_position_min.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00243 u_position_min.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00244 this->position_min = u_position_min.real; 00245 offset += sizeof(this->position_min); 00246 union { 00247 float real; 00248 uint32_t base; 00249 } u_position_max; 00250 u_position_max.base = 0; 00251 u_position_max.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00252 u_position_max.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00253 u_position_max.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00254 u_position_max.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00255 this->position_max = u_position_max.real; 00256 offset += sizeof(this->position_max); 00257 union { 00258 float real; 00259 uint32_t base; 00260 } u_velocity_limit; 00261 u_velocity_limit.base = 0; 00262 u_velocity_limit.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00263 u_velocity_limit.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00264 u_velocity_limit.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00265 u_velocity_limit.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00266 this->velocity_limit = u_velocity_limit.real; 00267 offset += sizeof(this->velocity_limit); 00268 union { 00269 float real; 00270 uint32_t base; 00271 } u_acceleration_limit; 00272 u_acceleration_limit.base = 0; 00273 u_acceleration_limit.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00274 u_acceleration_limit.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00275 u_acceleration_limit.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00276 u_acceleration_limit.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00277 this->acceleration_limit = u_acceleration_limit.real; 00278 offset += sizeof(this->acceleration_limit); 00279 union { 00280 float real; 00281 uint32_t base; 00282 } u_jerk_limit; 00283 u_jerk_limit.base = 0; 00284 u_jerk_limit.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00285 u_jerk_limit.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00286 u_jerk_limit.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00287 u_jerk_limit.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00288 this->jerk_limit = u_jerk_limit.real; 00289 offset += sizeof(this->jerk_limit); 00290 union { 00291 float real; 00292 uint32_t base; 00293 } u_kp; 00294 u_kp.base = 0; 00295 u_kp.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00296 u_kp.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00297 u_kp.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00298 u_kp.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00299 this->kp = u_kp.real; 00300 offset += sizeof(this->kp); 00301 union { 00302 float real; 00303 uint32_t base; 00304 } u_kd; 00305 u_kd.base = 0; 00306 u_kd.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00307 u_kd.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00308 u_kd.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00309 u_kd.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00310 this->kd = u_kd.real; 00311 offset += sizeof(this->kd); 00312 return offset; 00313 } 00314 00315 virtual const char * getType(){ return "catchrobo_msgs/MyRosCmd"; }; 00316 virtual const char * getMD5(){ return "6ab164ce9b4b573bf5693e427e5544eb"; }; 00317 00318 }; 00319 00320 } 00321 #endif
Generated on Mon Sep 26 2022 13:47:02 by
