ozgur erbulan / ros_kinetic

Dependencies:   BufferedSerial

Fork of ros_lib_kinetic by Gary Servin

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mobileRobot.h Source File

mobileRobot.h

00001 #ifndef _ROS_openlab_mobileRobot_h
00002 #define _ROS_openlab_mobileRobot_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 
00009 namespace openlab
00010 {
00011 
00012   class mobileRobot : public ros::Msg
00013   {
00014     public:
00015       typedef float _cmd_velocity_linx_type;
00016       _cmd_velocity_linx_type cmd_velocity_linx;
00017       typedef float _cmd_velocity_angz_type;
00018       _cmd_velocity_angz_type cmd_velocity_angz;
00019       typedef float _real_velocity_linx_type;
00020       _real_velocity_linx_type real_velocity_linx;
00021       typedef float _real_velocity_angz_type;
00022       _real_velocity_angz_type real_velocity_angz;
00023       typedef float _pwm_1_type;
00024       _pwm_1_type pwm_1;
00025       typedef float _pwm_2_type;
00026       _pwm_2_type pwm_2;
00027       typedef float _dc_current_1_type;
00028       _dc_current_1_type dc_current_1;
00029       typedef float _dc_current_2_type;
00030       _dc_current_2_type dc_current_2;
00031       typedef int32_t _encoder_1_type;
00032       _encoder_1_type encoder_1;
00033       typedef int32_t _encoder_2_type;
00034       _encoder_2_type encoder_2;
00035 
00036     mobileRobot():
00037       cmd_velocity_linx(0),
00038       cmd_velocity_angz(0),
00039       real_velocity_linx(0),
00040       real_velocity_angz(0),
00041       pwm_1(0),
00042       pwm_2(0),
00043       dc_current_1(0),
00044       dc_current_2(0),
00045       encoder_1(0),
00046       encoder_2(0)
00047     {
00048     }
00049 
00050     virtual int serialize(unsigned char *outbuffer) const
00051     {
00052       int offset = 0;
00053       union {
00054         float real;
00055         uint32_t base;
00056       } u_cmd_velocity_linx;
00057       u_cmd_velocity_linx.real = this->cmd_velocity_linx;
00058       *(outbuffer + offset + 0) = (u_cmd_velocity_linx.base >> (8 * 0)) & 0xFF;
00059       *(outbuffer + offset + 1) = (u_cmd_velocity_linx.base >> (8 * 1)) & 0xFF;
00060       *(outbuffer + offset + 2) = (u_cmd_velocity_linx.base >> (8 * 2)) & 0xFF;
00061       *(outbuffer + offset + 3) = (u_cmd_velocity_linx.base >> (8 * 3)) & 0xFF;
00062       offset += sizeof(this->cmd_velocity_linx);
00063       union {
00064         float real;
00065         uint32_t base;
00066       } u_cmd_velocity_angz;
00067       u_cmd_velocity_angz.real = this->cmd_velocity_angz;
00068       *(outbuffer + offset + 0) = (u_cmd_velocity_angz.base >> (8 * 0)) & 0xFF;
00069       *(outbuffer + offset + 1) = (u_cmd_velocity_angz.base >> (8 * 1)) & 0xFF;
00070       *(outbuffer + offset + 2) = (u_cmd_velocity_angz.base >> (8 * 2)) & 0xFF;
00071       *(outbuffer + offset + 3) = (u_cmd_velocity_angz.base >> (8 * 3)) & 0xFF;
00072       offset += sizeof(this->cmd_velocity_angz);
00073       union {
00074         float real;
00075         uint32_t base;
00076       } u_real_velocity_linx;
00077       u_real_velocity_linx.real = this->real_velocity_linx;
00078       *(outbuffer + offset + 0) = (u_real_velocity_linx.base >> (8 * 0)) & 0xFF;
00079       *(outbuffer + offset + 1) = (u_real_velocity_linx.base >> (8 * 1)) & 0xFF;
00080       *(outbuffer + offset + 2) = (u_real_velocity_linx.base >> (8 * 2)) & 0xFF;
00081       *(outbuffer + offset + 3) = (u_real_velocity_linx.base >> (8 * 3)) & 0xFF;
00082       offset += sizeof(this->real_velocity_linx);
00083       union {
00084         float real;
00085         uint32_t base;
00086       } u_real_velocity_angz;
00087       u_real_velocity_angz.real = this->real_velocity_angz;
00088       *(outbuffer + offset + 0) = (u_real_velocity_angz.base >> (8 * 0)) & 0xFF;
00089       *(outbuffer + offset + 1) = (u_real_velocity_angz.base >> (8 * 1)) & 0xFF;
00090       *(outbuffer + offset + 2) = (u_real_velocity_angz.base >> (8 * 2)) & 0xFF;
00091       *(outbuffer + offset + 3) = (u_real_velocity_angz.base >> (8 * 3)) & 0xFF;
00092       offset += sizeof(this->real_velocity_angz);
00093       union {
00094         float real;
00095         uint32_t base;
00096       } u_pwm_1;
00097       u_pwm_1.real = this->pwm_1;
00098       *(outbuffer + offset + 0) = (u_pwm_1.base >> (8 * 0)) & 0xFF;
00099       *(outbuffer + offset + 1) = (u_pwm_1.base >> (8 * 1)) & 0xFF;
00100       *(outbuffer + offset + 2) = (u_pwm_1.base >> (8 * 2)) & 0xFF;
00101       *(outbuffer + offset + 3) = (u_pwm_1.base >> (8 * 3)) & 0xFF;
00102       offset += sizeof(this->pwm_1);
00103       union {
00104         float real;
00105         uint32_t base;
00106       } u_pwm_2;
00107       u_pwm_2.real = this->pwm_2;
00108       *(outbuffer + offset + 0) = (u_pwm_2.base >> (8 * 0)) & 0xFF;
00109       *(outbuffer + offset + 1) = (u_pwm_2.base >> (8 * 1)) & 0xFF;
00110       *(outbuffer + offset + 2) = (u_pwm_2.base >> (8 * 2)) & 0xFF;
00111       *(outbuffer + offset + 3) = (u_pwm_2.base >> (8 * 3)) & 0xFF;
00112       offset += sizeof(this->pwm_2);
00113       union {
00114         float real;
00115         uint32_t base;
00116       } u_dc_current_1;
00117       u_dc_current_1.real = this->dc_current_1;
00118       *(outbuffer + offset + 0) = (u_dc_current_1.base >> (8 * 0)) & 0xFF;
00119       *(outbuffer + offset + 1) = (u_dc_current_1.base >> (8 * 1)) & 0xFF;
00120       *(outbuffer + offset + 2) = (u_dc_current_1.base >> (8 * 2)) & 0xFF;
00121       *(outbuffer + offset + 3) = (u_dc_current_1.base >> (8 * 3)) & 0xFF;
00122       offset += sizeof(this->dc_current_1);
00123       union {
00124         float real;
00125         uint32_t base;
00126       } u_dc_current_2;
00127       u_dc_current_2.real = this->dc_current_2;
00128       *(outbuffer + offset + 0) = (u_dc_current_2.base >> (8 * 0)) & 0xFF;
00129       *(outbuffer + offset + 1) = (u_dc_current_2.base >> (8 * 1)) & 0xFF;
00130       *(outbuffer + offset + 2) = (u_dc_current_2.base >> (8 * 2)) & 0xFF;
00131       *(outbuffer + offset + 3) = (u_dc_current_2.base >> (8 * 3)) & 0xFF;
00132       offset += sizeof(this->dc_current_2);
00133       union {
00134         int32_t real;
00135         uint32_t base;
00136       } u_encoder_1;
00137       u_encoder_1.real = this->encoder_1;
00138       *(outbuffer + offset + 0) = (u_encoder_1.base >> (8 * 0)) & 0xFF;
00139       *(outbuffer + offset + 1) = (u_encoder_1.base >> (8 * 1)) & 0xFF;
00140       *(outbuffer + offset + 2) = (u_encoder_1.base >> (8 * 2)) & 0xFF;
00141       *(outbuffer + offset + 3) = (u_encoder_1.base >> (8 * 3)) & 0xFF;
00142       offset += sizeof(this->encoder_1);
00143       union {
00144         int32_t real;
00145         uint32_t base;
00146       } u_encoder_2;
00147       u_encoder_2.real = this->encoder_2;
00148       *(outbuffer + offset + 0) = (u_encoder_2.base >> (8 * 0)) & 0xFF;
00149       *(outbuffer + offset + 1) = (u_encoder_2.base >> (8 * 1)) & 0xFF;
00150       *(outbuffer + offset + 2) = (u_encoder_2.base >> (8 * 2)) & 0xFF;
00151       *(outbuffer + offset + 3) = (u_encoder_2.base >> (8 * 3)) & 0xFF;
00152       offset += sizeof(this->encoder_2);
00153       return offset;
00154     }
00155 
00156     virtual int deserialize(unsigned char *inbuffer)
00157     {
00158       int offset = 0;
00159       union {
00160         float real;
00161         uint32_t base;
00162       } u_cmd_velocity_linx;
00163       u_cmd_velocity_linx.base = 0;
00164       u_cmd_velocity_linx.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00165       u_cmd_velocity_linx.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00166       u_cmd_velocity_linx.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00167       u_cmd_velocity_linx.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00168       this->cmd_velocity_linx = u_cmd_velocity_linx.real;
00169       offset += sizeof(this->cmd_velocity_linx);
00170       union {
00171         float real;
00172         uint32_t base;
00173       } u_cmd_velocity_angz;
00174       u_cmd_velocity_angz.base = 0;
00175       u_cmd_velocity_angz.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00176       u_cmd_velocity_angz.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00177       u_cmd_velocity_angz.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00178       u_cmd_velocity_angz.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00179       this->cmd_velocity_angz = u_cmd_velocity_angz.real;
00180       offset += sizeof(this->cmd_velocity_angz);
00181       union {
00182         float real;
00183         uint32_t base;
00184       } u_real_velocity_linx;
00185       u_real_velocity_linx.base = 0;
00186       u_real_velocity_linx.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00187       u_real_velocity_linx.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00188       u_real_velocity_linx.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00189       u_real_velocity_linx.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00190       this->real_velocity_linx = u_real_velocity_linx.real;
00191       offset += sizeof(this->real_velocity_linx);
00192       union {
00193         float real;
00194         uint32_t base;
00195       } u_real_velocity_angz;
00196       u_real_velocity_angz.base = 0;
00197       u_real_velocity_angz.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00198       u_real_velocity_angz.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00199       u_real_velocity_angz.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00200       u_real_velocity_angz.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00201       this->real_velocity_angz = u_real_velocity_angz.real;
00202       offset += sizeof(this->real_velocity_angz);
00203       union {
00204         float real;
00205         uint32_t base;
00206       } u_pwm_1;
00207       u_pwm_1.base = 0;
00208       u_pwm_1.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00209       u_pwm_1.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00210       u_pwm_1.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00211       u_pwm_1.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00212       this->pwm_1 = u_pwm_1.real;
00213       offset += sizeof(this->pwm_1);
00214       union {
00215         float real;
00216         uint32_t base;
00217       } u_pwm_2;
00218       u_pwm_2.base = 0;
00219       u_pwm_2.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00220       u_pwm_2.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00221       u_pwm_2.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00222       u_pwm_2.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00223       this->pwm_2 = u_pwm_2.real;
00224       offset += sizeof(this->pwm_2);
00225       union {
00226         float real;
00227         uint32_t base;
00228       } u_dc_current_1;
00229       u_dc_current_1.base = 0;
00230       u_dc_current_1.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00231       u_dc_current_1.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00232       u_dc_current_1.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00233       u_dc_current_1.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00234       this->dc_current_1 = u_dc_current_1.real;
00235       offset += sizeof(this->dc_current_1);
00236       union {
00237         float real;
00238         uint32_t base;
00239       } u_dc_current_2;
00240       u_dc_current_2.base = 0;
00241       u_dc_current_2.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00242       u_dc_current_2.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00243       u_dc_current_2.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00244       u_dc_current_2.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00245       this->dc_current_2 = u_dc_current_2.real;
00246       offset += sizeof(this->dc_current_2);
00247       union {
00248         int32_t real;
00249         uint32_t base;
00250       } u_encoder_1;
00251       u_encoder_1.base = 0;
00252       u_encoder_1.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00253       u_encoder_1.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00254       u_encoder_1.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00255       u_encoder_1.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00256       this->encoder_1 = u_encoder_1.real;
00257       offset += sizeof(this->encoder_1);
00258       union {
00259         int32_t real;
00260         uint32_t base;
00261       } u_encoder_2;
00262       u_encoder_2.base = 0;
00263       u_encoder_2.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00264       u_encoder_2.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00265       u_encoder_2.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00266       u_encoder_2.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00267       this->encoder_2 = u_encoder_2.real;
00268       offset += sizeof(this->encoder_2);
00269      return offset;
00270     }
00271 
00272     const char * getType(){ return "openlab/mobileRobot"; };
00273     const char * getMD5(){ return "5e54beb06e233db01abe11e2006b8b2e"; };
00274 
00275   };
00276 
00277 }
00278 #endif