catchrobo2022 / Mbed 2 deprecated catchrobo2022_mbed

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Pictogram.h Source File

Pictogram.h

00001 #ifndef _ROS_jsk_rviz_plugins_Pictogram_h
00002 #define _ROS_jsk_rviz_plugins_Pictogram_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 #include "std_msgs/Header.h"
00009 #include "geometry_msgs/Pose.h"
00010 #include "std_msgs/ColorRGBA.h"
00011 
00012 namespace jsk_rviz_plugins
00013 {
00014 
00015   class Pictogram : public ros::Msg
00016   {
00017     public:
00018       typedef std_msgs::Header _header_type;
00019       _header_type header;
00020       typedef geometry_msgs::Pose _pose_type;
00021       _pose_type pose;
00022       typedef uint8_t _action_type;
00023       _action_type action;
00024       typedef uint8_t _mode_type;
00025       _mode_type mode;
00026       typedef const char* _character_type;
00027       _character_type character;
00028       typedef double _size_type;
00029       _size_type size;
00030       typedef double _ttl_type;
00031       _ttl_type ttl;
00032       typedef double _speed_type;
00033       _speed_type speed;
00034       typedef std_msgs::ColorRGBA _color_type;
00035       _color_type color;
00036       enum { ADD = 0 };
00037       enum { DELETE = 1 };
00038       enum { ROTATE_Z = 2 };
00039       enum { ROTATE_Y = 3 };
00040       enum { ROTATE_X = 4 };
00041       enum { JUMP = 5 };
00042       enum { JUMP_ONCE = 6 };
00043       enum { PICTOGRAM_MODE = 0 };
00044       enum { STRING_MODE = 1 };
00045 
00046     Pictogram():
00047       header(),
00048       pose(),
00049       action(0),
00050       mode(0),
00051       character(""),
00052       size(0),
00053       ttl(0),
00054       speed(0),
00055       color()
00056     {
00057     }
00058 
00059     virtual int serialize(unsigned char *outbuffer) const
00060     {
00061       int offset = 0;
00062       offset += this->header.serialize(outbuffer + offset);
00063       offset += this->pose.serialize(outbuffer + offset);
00064       *(outbuffer + offset + 0) = (this->action >> (8 * 0)) & 0xFF;
00065       offset += sizeof(this->action);
00066       *(outbuffer + offset + 0) = (this->mode >> (8 * 0)) & 0xFF;
00067       offset += sizeof(this->mode);
00068       uint32_t length_character = strlen(this->character);
00069       varToArr(outbuffer + offset, length_character);
00070       offset += 4;
00071       memcpy(outbuffer + offset, this->character, length_character);
00072       offset += length_character;
00073       union {
00074         double real;
00075         uint64_t base;
00076       } u_size;
00077       u_size.real = this->size;
00078       *(outbuffer + offset + 0) = (u_size.base >> (8 * 0)) & 0xFF;
00079       *(outbuffer + offset + 1) = (u_size.base >> (8 * 1)) & 0xFF;
00080       *(outbuffer + offset + 2) = (u_size.base >> (8 * 2)) & 0xFF;
00081       *(outbuffer + offset + 3) = (u_size.base >> (8 * 3)) & 0xFF;
00082       *(outbuffer + offset + 4) = (u_size.base >> (8 * 4)) & 0xFF;
00083       *(outbuffer + offset + 5) = (u_size.base >> (8 * 5)) & 0xFF;
00084       *(outbuffer + offset + 6) = (u_size.base >> (8 * 6)) & 0xFF;
00085       *(outbuffer + offset + 7) = (u_size.base >> (8 * 7)) & 0xFF;
00086       offset += sizeof(this->size);
00087       union {
00088         double real;
00089         uint64_t base;
00090       } u_ttl;
00091       u_ttl.real = this->ttl;
00092       *(outbuffer + offset + 0) = (u_ttl.base >> (8 * 0)) & 0xFF;
00093       *(outbuffer + offset + 1) = (u_ttl.base >> (8 * 1)) & 0xFF;
00094       *(outbuffer + offset + 2) = (u_ttl.base >> (8 * 2)) & 0xFF;
00095       *(outbuffer + offset + 3) = (u_ttl.base >> (8 * 3)) & 0xFF;
00096       *(outbuffer + offset + 4) = (u_ttl.base >> (8 * 4)) & 0xFF;
00097       *(outbuffer + offset + 5) = (u_ttl.base >> (8 * 5)) & 0xFF;
00098       *(outbuffer + offset + 6) = (u_ttl.base >> (8 * 6)) & 0xFF;
00099       *(outbuffer + offset + 7) = (u_ttl.base >> (8 * 7)) & 0xFF;
00100       offset += sizeof(this->ttl);
00101       union {
00102         double real;
00103         uint64_t base;
00104       } u_speed;
00105       u_speed.real = this->speed;
00106       *(outbuffer + offset + 0) = (u_speed.base >> (8 * 0)) & 0xFF;
00107       *(outbuffer + offset + 1) = (u_speed.base >> (8 * 1)) & 0xFF;
00108       *(outbuffer + offset + 2) = (u_speed.base >> (8 * 2)) & 0xFF;
00109       *(outbuffer + offset + 3) = (u_speed.base >> (8 * 3)) & 0xFF;
00110       *(outbuffer + offset + 4) = (u_speed.base >> (8 * 4)) & 0xFF;
00111       *(outbuffer + offset + 5) = (u_speed.base >> (8 * 5)) & 0xFF;
00112       *(outbuffer + offset + 6) = (u_speed.base >> (8 * 6)) & 0xFF;
00113       *(outbuffer + offset + 7) = (u_speed.base >> (8 * 7)) & 0xFF;
00114       offset += sizeof(this->speed);
00115       offset += this->color.serialize(outbuffer + offset);
00116       return offset;
00117     }
00118 
00119     virtual int deserialize(unsigned char *inbuffer)
00120     {
00121       int offset = 0;
00122       offset += this->header.deserialize(inbuffer + offset);
00123       offset += this->pose.deserialize(inbuffer + offset);
00124       this->action =  ((uint8_t) (*(inbuffer + offset)));
00125       offset += sizeof(this->action);
00126       this->mode =  ((uint8_t) (*(inbuffer + offset)));
00127       offset += sizeof(this->mode);
00128       uint32_t length_character;
00129       arrToVar(length_character, (inbuffer + offset));
00130       offset += 4;
00131       for(unsigned int k= offset; k< offset+length_character; ++k){
00132           inbuffer[k-1]=inbuffer[k];
00133       }
00134       inbuffer[offset+length_character-1]=0;
00135       this->character = (char *)(inbuffer + offset-1);
00136       offset += length_character;
00137       union {
00138         double real;
00139         uint64_t base;
00140       } u_size;
00141       u_size.base = 0;
00142       u_size.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
00143       u_size.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
00144       u_size.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
00145       u_size.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
00146       u_size.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
00147       u_size.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
00148       u_size.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
00149       u_size.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
00150       this->size = u_size.real;
00151       offset += sizeof(this->size);
00152       union {
00153         double real;
00154         uint64_t base;
00155       } u_ttl;
00156       u_ttl.base = 0;
00157       u_ttl.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
00158       u_ttl.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
00159       u_ttl.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
00160       u_ttl.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
00161       u_ttl.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
00162       u_ttl.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
00163       u_ttl.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
00164       u_ttl.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
00165       this->ttl = u_ttl.real;
00166       offset += sizeof(this->ttl);
00167       union {
00168         double real;
00169         uint64_t base;
00170       } u_speed;
00171       u_speed.base = 0;
00172       u_speed.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
00173       u_speed.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
00174       u_speed.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
00175       u_speed.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
00176       u_speed.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
00177       u_speed.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
00178       u_speed.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
00179       u_speed.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
00180       this->speed = u_speed.real;
00181       offset += sizeof(this->speed);
00182       offset += this->color.deserialize(inbuffer + offset);
00183      return offset;
00184     }
00185 
00186     virtual const char * getType(){ return "jsk_rviz_plugins/Pictogram"; };
00187     virtual const char * getMD5(){ return "29667e5652a8cfdc9c87d2ed97aa7bbc"; };
00188 
00189   };
00190 
00191 }
00192 #endif