catchrobo2022 / Mbed 2 deprecated catchrobo2022_mbed

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers OverlayText.h Source File

OverlayText.h

00001 #ifndef _ROS_jsk_rviz_plugins_OverlayText_h
00002 #define _ROS_jsk_rviz_plugins_OverlayText_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 #include "std_msgs/ColorRGBA.h"
00009 
00010 namespace jsk_rviz_plugins
00011 {
00012 
00013   class OverlayText : public ros::Msg
00014   {
00015     public:
00016       typedef uint8_t _action_type;
00017       _action_type action;
00018       typedef int32_t _width_type;
00019       _width_type width;
00020       typedef int32_t _height_type;
00021       _height_type height;
00022       typedef int32_t _left_type;
00023       _left_type left;
00024       typedef int32_t _top_type;
00025       _top_type top;
00026       typedef std_msgs::ColorRGBA _bg_color_type;
00027       _bg_color_type bg_color;
00028       typedef int32_t _line_width_type;
00029       _line_width_type line_width;
00030       typedef float _text_size_type;
00031       _text_size_type text_size;
00032       typedef const char* _font_type;
00033       _font_type font;
00034       typedef std_msgs::ColorRGBA _fg_color_type;
00035       _fg_color_type fg_color;
00036       typedef const char* _text_type;
00037       _text_type text;
00038       enum { ADD =  0 };
00039       enum { DELETE =  1 };
00040 
00041     OverlayText():
00042       action(0),
00043       width(0),
00044       height(0),
00045       left(0),
00046       top(0),
00047       bg_color(),
00048       line_width(0),
00049       text_size(0),
00050       font(""),
00051       fg_color(),
00052       text("")
00053     {
00054     }
00055 
00056     virtual int serialize(unsigned char *outbuffer) const
00057     {
00058       int offset = 0;
00059       *(outbuffer + offset + 0) = (this->action >> (8 * 0)) & 0xFF;
00060       offset += sizeof(this->action);
00061       union {
00062         int32_t real;
00063         uint32_t base;
00064       } u_width;
00065       u_width.real = this->width;
00066       *(outbuffer + offset + 0) = (u_width.base >> (8 * 0)) & 0xFF;
00067       *(outbuffer + offset + 1) = (u_width.base >> (8 * 1)) & 0xFF;
00068       *(outbuffer + offset + 2) = (u_width.base >> (8 * 2)) & 0xFF;
00069       *(outbuffer + offset + 3) = (u_width.base >> (8 * 3)) & 0xFF;
00070       offset += sizeof(this->width);
00071       union {
00072         int32_t real;
00073         uint32_t base;
00074       } u_height;
00075       u_height.real = this->height;
00076       *(outbuffer + offset + 0) = (u_height.base >> (8 * 0)) & 0xFF;
00077       *(outbuffer + offset + 1) = (u_height.base >> (8 * 1)) & 0xFF;
00078       *(outbuffer + offset + 2) = (u_height.base >> (8 * 2)) & 0xFF;
00079       *(outbuffer + offset + 3) = (u_height.base >> (8 * 3)) & 0xFF;
00080       offset += sizeof(this->height);
00081       union {
00082         int32_t real;
00083         uint32_t base;
00084       } u_left;
00085       u_left.real = this->left;
00086       *(outbuffer + offset + 0) = (u_left.base >> (8 * 0)) & 0xFF;
00087       *(outbuffer + offset + 1) = (u_left.base >> (8 * 1)) & 0xFF;
00088       *(outbuffer + offset + 2) = (u_left.base >> (8 * 2)) & 0xFF;
00089       *(outbuffer + offset + 3) = (u_left.base >> (8 * 3)) & 0xFF;
00090       offset += sizeof(this->left);
00091       union {
00092         int32_t real;
00093         uint32_t base;
00094       } u_top;
00095       u_top.real = this->top;
00096       *(outbuffer + offset + 0) = (u_top.base >> (8 * 0)) & 0xFF;
00097       *(outbuffer + offset + 1) = (u_top.base >> (8 * 1)) & 0xFF;
00098       *(outbuffer + offset + 2) = (u_top.base >> (8 * 2)) & 0xFF;
00099       *(outbuffer + offset + 3) = (u_top.base >> (8 * 3)) & 0xFF;
00100       offset += sizeof(this->top);
00101       offset += this->bg_color.serialize(outbuffer + offset);
00102       union {
00103         int32_t real;
00104         uint32_t base;
00105       } u_line_width;
00106       u_line_width.real = this->line_width;
00107       *(outbuffer + offset + 0) = (u_line_width.base >> (8 * 0)) & 0xFF;
00108       *(outbuffer + offset + 1) = (u_line_width.base >> (8 * 1)) & 0xFF;
00109       *(outbuffer + offset + 2) = (u_line_width.base >> (8 * 2)) & 0xFF;
00110       *(outbuffer + offset + 3) = (u_line_width.base >> (8 * 3)) & 0xFF;
00111       offset += sizeof(this->line_width);
00112       union {
00113         float real;
00114         uint32_t base;
00115       } u_text_size;
00116       u_text_size.real = this->text_size;
00117       *(outbuffer + offset + 0) = (u_text_size.base >> (8 * 0)) & 0xFF;
00118       *(outbuffer + offset + 1) = (u_text_size.base >> (8 * 1)) & 0xFF;
00119       *(outbuffer + offset + 2) = (u_text_size.base >> (8 * 2)) & 0xFF;
00120       *(outbuffer + offset + 3) = (u_text_size.base >> (8 * 3)) & 0xFF;
00121       offset += sizeof(this->text_size);
00122       uint32_t length_font = strlen(this->font);
00123       varToArr(outbuffer + offset, length_font);
00124       offset += 4;
00125       memcpy(outbuffer + offset, this->font, length_font);
00126       offset += length_font;
00127       offset += this->fg_color.serialize(outbuffer + offset);
00128       uint32_t length_text = strlen(this->text);
00129       varToArr(outbuffer + offset, length_text);
00130       offset += 4;
00131       memcpy(outbuffer + offset, this->text, length_text);
00132       offset += length_text;
00133       return offset;
00134     }
00135 
00136     virtual int deserialize(unsigned char *inbuffer)
00137     {
00138       int offset = 0;
00139       this->action =  ((uint8_t) (*(inbuffer + offset)));
00140       offset += sizeof(this->action);
00141       union {
00142         int32_t real;
00143         uint32_t base;
00144       } u_width;
00145       u_width.base = 0;
00146       u_width.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00147       u_width.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00148       u_width.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00149       u_width.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00150       this->width = u_width.real;
00151       offset += sizeof(this->width);
00152       union {
00153         int32_t real;
00154         uint32_t base;
00155       } u_height;
00156       u_height.base = 0;
00157       u_height.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00158       u_height.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00159       u_height.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00160       u_height.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00161       this->height = u_height.real;
00162       offset += sizeof(this->height);
00163       union {
00164         int32_t real;
00165         uint32_t base;
00166       } u_left;
00167       u_left.base = 0;
00168       u_left.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00169       u_left.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00170       u_left.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00171       u_left.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00172       this->left = u_left.real;
00173       offset += sizeof(this->left);
00174       union {
00175         int32_t real;
00176         uint32_t base;
00177       } u_top;
00178       u_top.base = 0;
00179       u_top.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00180       u_top.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00181       u_top.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00182       u_top.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00183       this->top = u_top.real;
00184       offset += sizeof(this->top);
00185       offset += this->bg_color.deserialize(inbuffer + offset);
00186       union {
00187         int32_t real;
00188         uint32_t base;
00189       } u_line_width;
00190       u_line_width.base = 0;
00191       u_line_width.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00192       u_line_width.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00193       u_line_width.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00194       u_line_width.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00195       this->line_width = u_line_width.real;
00196       offset += sizeof(this->line_width);
00197       union {
00198         float real;
00199         uint32_t base;
00200       } u_text_size;
00201       u_text_size.base = 0;
00202       u_text_size.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00203       u_text_size.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00204       u_text_size.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00205       u_text_size.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00206       this->text_size = u_text_size.real;
00207       offset += sizeof(this->text_size);
00208       uint32_t length_font;
00209       arrToVar(length_font, (inbuffer + offset));
00210       offset += 4;
00211       for(unsigned int k= offset; k< offset+length_font; ++k){
00212           inbuffer[k-1]=inbuffer[k];
00213       }
00214       inbuffer[offset+length_font-1]=0;
00215       this->font = (char *)(inbuffer + offset-1);
00216       offset += length_font;
00217       offset += this->fg_color.deserialize(inbuffer + offset);
00218       uint32_t length_text;
00219       arrToVar(length_text, (inbuffer + offset));
00220       offset += 4;
00221       for(unsigned int k= offset; k< offset+length_text; ++k){
00222           inbuffer[k-1]=inbuffer[k];
00223       }
00224       inbuffer[offset+length_text-1]=0;
00225       this->text = (char *)(inbuffer + offset-1);
00226       offset += length_text;
00227      return offset;
00228     }
00229 
00230     virtual const char * getType(){ return "jsk_rviz_plugins/OverlayText"; };
00231     virtual const char * getMD5(){ return "7efc1ed34881f913afcee6ba02aa1242"; };
00232 
00233   };
00234 
00235 }
00236 #endif