Working towards recieving twists

Dependencies:   BufferedSerial

Fork of ros_lib_kinetic by Gary Servin

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ImageMarker.h Source File

ImageMarker.h

00001 #ifndef _ROS_visualization_msgs_ImageMarker_h
00002 #define _ROS_visualization_msgs_ImageMarker_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/Point.h"
00010 #include "std_msgs/ColorRGBA.h"
00011 #include "ros/duration.h"
00012 
00013 namespace visualization_msgs
00014 {
00015 
00016   class ImageMarker : public ros::Msg
00017   {
00018     public:
00019       typedef std_msgs::Header _header_type;
00020       _header_type header;
00021       typedef const char* _ns_type;
00022       _ns_type ns;
00023       typedef int32_t _id_type;
00024       _id_type id;
00025       typedef int32_t _type_type;
00026       _type_type type;
00027       typedef int32_t _action_type;
00028       _action_type action;
00029       typedef geometry_msgs::Point _position_type;
00030       _position_type position;
00031       typedef float _scale_type;
00032       _scale_type scale;
00033       typedef std_msgs::ColorRGBA _outline_color_type;
00034       _outline_color_type outline_color;
00035       typedef uint8_t _filled_type;
00036       _filled_type filled;
00037       typedef std_msgs::ColorRGBA _fill_color_type;
00038       _fill_color_type fill_color;
00039       typedef ros::Duration _lifetime_type;
00040       _lifetime_type lifetime;
00041       uint32_t points_length;
00042       typedef geometry_msgs::Point _points_type;
00043       _points_type st_points;
00044       _points_type * points;
00045       uint32_t outline_colors_length;
00046       typedef std_msgs::ColorRGBA _outline_colors_type;
00047       _outline_colors_type st_outline_colors;
00048       _outline_colors_type * outline_colors;
00049       enum { CIRCLE = 0 };
00050       enum { LINE_STRIP = 1 };
00051       enum { LINE_LIST = 2 };
00052       enum { POLYGON = 3 };
00053       enum { POINTS = 4 };
00054       enum { ADD = 0 };
00055       enum { REMOVE = 1 };
00056 
00057     ImageMarker():
00058       header(),
00059       ns(""),
00060       id(0),
00061       type(0),
00062       action(0),
00063       position(),
00064       scale(0),
00065       outline_color(),
00066       filled(0),
00067       fill_color(),
00068       lifetime(),
00069       points_length(0), points(NULL),
00070       outline_colors_length(0), outline_colors(NULL)
00071     {
00072     }
00073 
00074     virtual int serialize(unsigned char *outbuffer) const
00075     {
00076       int offset = 0;
00077       offset += this->header.serialize(outbuffer + offset);
00078       uint32_t length_ns = strlen(this->ns);
00079       varToArr(outbuffer + offset, length_ns);
00080       offset += 4;
00081       memcpy(outbuffer + offset, this->ns, length_ns);
00082       offset += length_ns;
00083       union {
00084         int32_t real;
00085         uint32_t base;
00086       } u_id;
00087       u_id.real = this->id;
00088       *(outbuffer + offset + 0) = (u_id.base >> (8 * 0)) & 0xFF;
00089       *(outbuffer + offset + 1) = (u_id.base >> (8 * 1)) & 0xFF;
00090       *(outbuffer + offset + 2) = (u_id.base >> (8 * 2)) & 0xFF;
00091       *(outbuffer + offset + 3) = (u_id.base >> (8 * 3)) & 0xFF;
00092       offset += sizeof(this->id);
00093       union {
00094         int32_t real;
00095         uint32_t base;
00096       } u_type;
00097       u_type.real = this->type;
00098       *(outbuffer + offset + 0) = (u_type.base >> (8 * 0)) & 0xFF;
00099       *(outbuffer + offset + 1) = (u_type.base >> (8 * 1)) & 0xFF;
00100       *(outbuffer + offset + 2) = (u_type.base >> (8 * 2)) & 0xFF;
00101       *(outbuffer + offset + 3) = (u_type.base >> (8 * 3)) & 0xFF;
00102       offset += sizeof(this->type);
00103       union {
00104         int32_t real;
00105         uint32_t base;
00106       } u_action;
00107       u_action.real = this->action;
00108       *(outbuffer + offset + 0) = (u_action.base >> (8 * 0)) & 0xFF;
00109       *(outbuffer + offset + 1) = (u_action.base >> (8 * 1)) & 0xFF;
00110       *(outbuffer + offset + 2) = (u_action.base >> (8 * 2)) & 0xFF;
00111       *(outbuffer + offset + 3) = (u_action.base >> (8 * 3)) & 0xFF;
00112       offset += sizeof(this->action);
00113       offset += this->position.serialize(outbuffer + offset);
00114       union {
00115         float real;
00116         uint32_t base;
00117       } u_scale;
00118       u_scale.real = this->scale;
00119       *(outbuffer + offset + 0) = (u_scale.base >> (8 * 0)) & 0xFF;
00120       *(outbuffer + offset + 1) = (u_scale.base >> (8 * 1)) & 0xFF;
00121       *(outbuffer + offset + 2) = (u_scale.base >> (8 * 2)) & 0xFF;
00122       *(outbuffer + offset + 3) = (u_scale.base >> (8 * 3)) & 0xFF;
00123       offset += sizeof(this->scale);
00124       offset += this->outline_color.serialize(outbuffer + offset);
00125       *(outbuffer + offset + 0) = (this->filled >> (8 * 0)) & 0xFF;
00126       offset += sizeof(this->filled);
00127       offset += this->fill_color.serialize(outbuffer + offset);
00128       *(outbuffer + offset + 0) = (this->lifetime.sec >> (8 * 0)) & 0xFF;
00129       *(outbuffer + offset + 1) = (this->lifetime.sec >> (8 * 1)) & 0xFF;
00130       *(outbuffer + offset + 2) = (this->lifetime.sec >> (8 * 2)) & 0xFF;
00131       *(outbuffer + offset + 3) = (this->lifetime.sec >> (8 * 3)) & 0xFF;
00132       offset += sizeof(this->lifetime.sec);
00133       *(outbuffer + offset + 0) = (this->lifetime.nsec >> (8 * 0)) & 0xFF;
00134       *(outbuffer + offset + 1) = (this->lifetime.nsec >> (8 * 1)) & 0xFF;
00135       *(outbuffer + offset + 2) = (this->lifetime.nsec >> (8 * 2)) & 0xFF;
00136       *(outbuffer + offset + 3) = (this->lifetime.nsec >> (8 * 3)) & 0xFF;
00137       offset += sizeof(this->lifetime.nsec);
00138       *(outbuffer + offset + 0) = (this->points_length >> (8 * 0)) & 0xFF;
00139       *(outbuffer + offset + 1) = (this->points_length >> (8 * 1)) & 0xFF;
00140       *(outbuffer + offset + 2) = (this->points_length >> (8 * 2)) & 0xFF;
00141       *(outbuffer + offset + 3) = (this->points_length >> (8 * 3)) & 0xFF;
00142       offset += sizeof(this->points_length);
00143       for( uint32_t i = 0; i < points_length; i++){
00144       offset += this->points[i].serialize(outbuffer + offset);
00145       }
00146       *(outbuffer + offset + 0) = (this->outline_colors_length >> (8 * 0)) & 0xFF;
00147       *(outbuffer + offset + 1) = (this->outline_colors_length >> (8 * 1)) & 0xFF;
00148       *(outbuffer + offset + 2) = (this->outline_colors_length >> (8 * 2)) & 0xFF;
00149       *(outbuffer + offset + 3) = (this->outline_colors_length >> (8 * 3)) & 0xFF;
00150       offset += sizeof(this->outline_colors_length);
00151       for( uint32_t i = 0; i < outline_colors_length; i++){
00152       offset += this->outline_colors[i].serialize(outbuffer + offset);
00153       }
00154       return offset;
00155     }
00156 
00157     virtual int deserialize(unsigned char *inbuffer)
00158     {
00159       int offset = 0;
00160       offset += this->header.deserialize(inbuffer + offset);
00161       uint32_t length_ns;
00162       arrToVar(length_ns, (inbuffer + offset));
00163       offset += 4;
00164       for(unsigned int k= offset; k< offset+length_ns; ++k){
00165           inbuffer[k-1]=inbuffer[k];
00166       }
00167       inbuffer[offset+length_ns-1]=0;
00168       this->ns = (char *)(inbuffer + offset-1);
00169       offset += length_ns;
00170       union {
00171         int32_t real;
00172         uint32_t base;
00173       } u_id;
00174       u_id.base = 0;
00175       u_id.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00176       u_id.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00177       u_id.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00178       u_id.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00179       this->id = u_id.real;
00180       offset += sizeof(this->id);
00181       union {
00182         int32_t real;
00183         uint32_t base;
00184       } u_type;
00185       u_type.base = 0;
00186       u_type.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00187       u_type.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00188       u_type.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00189       u_type.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00190       this->type = u_type.real;
00191       offset += sizeof(this->type);
00192       union {
00193         int32_t real;
00194         uint32_t base;
00195       } u_action;
00196       u_action.base = 0;
00197       u_action.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00198       u_action.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00199       u_action.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00200       u_action.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00201       this->action = u_action.real;
00202       offset += sizeof(this->action);
00203       offset += this->position.deserialize(inbuffer + offset);
00204       union {
00205         float real;
00206         uint32_t base;
00207       } u_scale;
00208       u_scale.base = 0;
00209       u_scale.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00210       u_scale.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00211       u_scale.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00212       u_scale.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00213       this->scale = u_scale.real;
00214       offset += sizeof(this->scale);
00215       offset += this->outline_color.deserialize(inbuffer + offset);
00216       this->filled =  ((uint8_t) (*(inbuffer + offset)));
00217       offset += sizeof(this->filled);
00218       offset += this->fill_color.deserialize(inbuffer + offset);
00219       this->lifetime.sec =  ((uint32_t) (*(inbuffer + offset)));
00220       this->lifetime.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00221       this->lifetime.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00222       this->lifetime.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00223       offset += sizeof(this->lifetime.sec);
00224       this->lifetime.nsec =  ((uint32_t) (*(inbuffer + offset)));
00225       this->lifetime.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00226       this->lifetime.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00227       this->lifetime.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00228       offset += sizeof(this->lifetime.nsec);
00229       uint32_t points_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00230       points_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00231       points_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00232       points_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00233       offset += sizeof(this->points_length);
00234       if(points_lengthT > points_length)
00235         this->points = (geometry_msgs::Point*)realloc(this->points, points_lengthT * sizeof(geometry_msgs::Point));
00236       points_length = points_lengthT;
00237       for( uint32_t i = 0; i < points_length; i++){
00238       offset += this->st_points.deserialize(inbuffer + offset);
00239         memcpy( &(this->points[i]), &(this->st_points), sizeof(geometry_msgs::Point));
00240       }
00241       uint32_t outline_colors_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00242       outline_colors_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00243       outline_colors_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00244       outline_colors_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00245       offset += sizeof(this->outline_colors_length);
00246       if(outline_colors_lengthT > outline_colors_length)
00247         this->outline_colors = (std_msgs::ColorRGBA*)realloc(this->outline_colors, outline_colors_lengthT * sizeof(std_msgs::ColorRGBA));
00248       outline_colors_length = outline_colors_lengthT;
00249       for( uint32_t i = 0; i < outline_colors_length; i++){
00250       offset += this->st_outline_colors.deserialize(inbuffer + offset);
00251         memcpy( &(this->outline_colors[i]), &(this->st_outline_colors), sizeof(std_msgs::ColorRGBA));
00252       }
00253      return offset;
00254     }
00255 
00256     const char * getType(){ return "visualization_msgs/ImageMarker"; };
00257     const char * getMD5(){ return "1de93c67ec8858b831025a08fbf1b35c"; };
00258 
00259   };
00260 
00261 }
00262 #endif