catchrobo2022 / Mbed 2 deprecated catchrobo2022_mbed

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers StateStruct.h Source File

StateStruct.h

00001 #ifndef _ROS_catchrobo_msgs_StateStruct_h
00002 #define _ROS_catchrobo_msgs_StateStruct_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 StateStruct : public ros::Msg
00013   {
00014     public:
00015       typedef int32_t _id_type;
00016       _id_type id;
00017       typedef double _position_type;
00018       _position_type position;
00019       typedef double _velocity_type;
00020       _velocity_type velocity;
00021       typedef double _torque_type;
00022       _torque_type torque;
00023 
00024     StateStruct():
00025       id(0),
00026       position(0),
00027       velocity(0),
00028       torque(0)
00029     {
00030     }
00031 
00032     virtual int serialize(unsigned char *outbuffer) const
00033     {
00034       int offset = 0;
00035       union {
00036         int32_t real;
00037         uint32_t base;
00038       } u_id;
00039       u_id.real = this->id;
00040       *(outbuffer + offset + 0) = (u_id.base >> (8 * 0)) & 0xFF;
00041       *(outbuffer + offset + 1) = (u_id.base >> (8 * 1)) & 0xFF;
00042       *(outbuffer + offset + 2) = (u_id.base >> (8 * 2)) & 0xFF;
00043       *(outbuffer + offset + 3) = (u_id.base >> (8 * 3)) & 0xFF;
00044       offset += sizeof(this->id);
00045       union {
00046         double real;
00047         uint64_t base;
00048       } u_position;
00049       u_position.real = this->position;
00050       *(outbuffer + offset + 0) = (u_position.base >> (8 * 0)) & 0xFF;
00051       *(outbuffer + offset + 1) = (u_position.base >> (8 * 1)) & 0xFF;
00052       *(outbuffer + offset + 2) = (u_position.base >> (8 * 2)) & 0xFF;
00053       *(outbuffer + offset + 3) = (u_position.base >> (8 * 3)) & 0xFF;
00054       *(outbuffer + offset + 4) = (u_position.base >> (8 * 4)) & 0xFF;
00055       *(outbuffer + offset + 5) = (u_position.base >> (8 * 5)) & 0xFF;
00056       *(outbuffer + offset + 6) = (u_position.base >> (8 * 6)) & 0xFF;
00057       *(outbuffer + offset + 7) = (u_position.base >> (8 * 7)) & 0xFF;
00058       offset += sizeof(this->position);
00059       union {
00060         double real;
00061         uint64_t base;
00062       } u_velocity;
00063       u_velocity.real = this->velocity;
00064       *(outbuffer + offset + 0) = (u_velocity.base >> (8 * 0)) & 0xFF;
00065       *(outbuffer + offset + 1) = (u_velocity.base >> (8 * 1)) & 0xFF;
00066       *(outbuffer + offset + 2) = (u_velocity.base >> (8 * 2)) & 0xFF;
00067       *(outbuffer + offset + 3) = (u_velocity.base >> (8 * 3)) & 0xFF;
00068       *(outbuffer + offset + 4) = (u_velocity.base >> (8 * 4)) & 0xFF;
00069       *(outbuffer + offset + 5) = (u_velocity.base >> (8 * 5)) & 0xFF;
00070       *(outbuffer + offset + 6) = (u_velocity.base >> (8 * 6)) & 0xFF;
00071       *(outbuffer + offset + 7) = (u_velocity.base >> (8 * 7)) & 0xFF;
00072       offset += sizeof(this->velocity);
00073       union {
00074         double real;
00075         uint64_t base;
00076       } u_torque;
00077       u_torque.real = this->torque;
00078       *(outbuffer + offset + 0) = (u_torque.base >> (8 * 0)) & 0xFF;
00079       *(outbuffer + offset + 1) = (u_torque.base >> (8 * 1)) & 0xFF;
00080       *(outbuffer + offset + 2) = (u_torque.base >> (8 * 2)) & 0xFF;
00081       *(outbuffer + offset + 3) = (u_torque.base >> (8 * 3)) & 0xFF;
00082       *(outbuffer + offset + 4) = (u_torque.base >> (8 * 4)) & 0xFF;
00083       *(outbuffer + offset + 5) = (u_torque.base >> (8 * 5)) & 0xFF;
00084       *(outbuffer + offset + 6) = (u_torque.base >> (8 * 6)) & 0xFF;
00085       *(outbuffer + offset + 7) = (u_torque.base >> (8 * 7)) & 0xFF;
00086       offset += sizeof(this->torque);
00087       return offset;
00088     }
00089 
00090     virtual int deserialize(unsigned char *inbuffer)
00091     {
00092       int offset = 0;
00093       union {
00094         int32_t real;
00095         uint32_t base;
00096       } u_id;
00097       u_id.base = 0;
00098       u_id.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00099       u_id.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00100       u_id.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00101       u_id.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00102       this->id = u_id.real;
00103       offset += sizeof(this->id);
00104       union {
00105         double real;
00106         uint64_t base;
00107       } u_position;
00108       u_position.base = 0;
00109       u_position.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
00110       u_position.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
00111       u_position.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
00112       u_position.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
00113       u_position.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
00114       u_position.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
00115       u_position.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
00116       u_position.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
00117       this->position = u_position.real;
00118       offset += sizeof(this->position);
00119       union {
00120         double real;
00121         uint64_t base;
00122       } u_velocity;
00123       u_velocity.base = 0;
00124       u_velocity.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
00125       u_velocity.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
00126       u_velocity.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
00127       u_velocity.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
00128       u_velocity.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
00129       u_velocity.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
00130       u_velocity.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
00131       u_velocity.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
00132       this->velocity = u_velocity.real;
00133       offset += sizeof(this->velocity);
00134       union {
00135         double real;
00136         uint64_t base;
00137       } u_torque;
00138       u_torque.base = 0;
00139       u_torque.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
00140       u_torque.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
00141       u_torque.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
00142       u_torque.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
00143       u_torque.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
00144       u_torque.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
00145       u_torque.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
00146       u_torque.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
00147       this->torque = u_torque.real;
00148       offset += sizeof(this->torque);
00149      return offset;
00150     }
00151 
00152     virtual const char * getType(){ return "catchrobo_msgs/StateStruct"; };
00153     virtual const char * getMD5(){ return "08201bc0324dade56d4c8aa1ed222913"; };
00154 
00155   };
00156 
00157 }
00158 #endif