LAB
Dependencies: BufferedSerial
Fork of ros_lib_indigo by
visualization_msgs/ImageMarker.h
- Committer:
- garyservin
- Date:
- 2016-03-31
- Revision:
- 0:fd24f7ca9688
File content as of revision 0:fd24f7ca9688:
#ifndef _ROS_visualization_msgs_ImageMarker_h #define _ROS_visualization_msgs_ImageMarker_h #include <stdint.h> #include <string.h> #include <stdlib.h> #include "ros/msg.h" #include "std_msgs/Header.h" #include "geometry_msgs/Point.h" #include "std_msgs/ColorRGBA.h" #include "ros/duration.h" namespace visualization_msgs { class ImageMarker : public ros::Msg { public: std_msgs::Header header; const char* ns; int32_t id; int32_t type; int32_t action; geometry_msgs::Point position; float scale; std_msgs::ColorRGBA outline_color; uint8_t filled; std_msgs::ColorRGBA fill_color; ros::Duration lifetime; uint8_t points_length; geometry_msgs::Point st_points; geometry_msgs::Point * points; uint8_t outline_colors_length; std_msgs::ColorRGBA st_outline_colors; std_msgs::ColorRGBA * outline_colors; enum { CIRCLE = 0 }; enum { LINE_STRIP = 1 }; enum { LINE_LIST = 2 }; enum { POLYGON = 3 }; enum { POINTS = 4 }; enum { ADD = 0 }; enum { REMOVE = 1 }; ImageMarker(): header(), ns(""), id(0), type(0), action(0), position(), scale(0), outline_color(), filled(0), fill_color(), lifetime(), points_length(0), points(NULL), outline_colors_length(0), outline_colors(NULL) { } virtual int serialize(unsigned char *outbuffer) const { int offset = 0; offset += this->header.serialize(outbuffer + offset); uint32_t length_ns = strlen(this->ns); memcpy(outbuffer + offset, &length_ns, sizeof(uint32_t)); offset += 4; memcpy(outbuffer + offset, this->ns, length_ns); offset += length_ns; union { int32_t real; uint32_t base; } u_id; u_id.real = this->id; *(outbuffer + offset + 0) = (u_id.base >> (8 * 0)) & 0xFF; *(outbuffer + offset + 1) = (u_id.base >> (8 * 1)) & 0xFF; *(outbuffer + offset + 2) = (u_id.base >> (8 * 2)) & 0xFF; *(outbuffer + offset + 3) = (u_id.base >> (8 * 3)) & 0xFF; offset += sizeof(this->id); union { int32_t real; uint32_t base; } u_type; u_type.real = this->type; *(outbuffer + offset + 0) = (u_type.base >> (8 * 0)) & 0xFF; *(outbuffer + offset + 1) = (u_type.base >> (8 * 1)) & 0xFF; *(outbuffer + offset + 2) = (u_type.base >> (8 * 2)) & 0xFF; *(outbuffer + offset + 3) = (u_type.base >> (8 * 3)) & 0xFF; offset += sizeof(this->type); union { int32_t real; uint32_t base; } u_action; u_action.real = this->action; *(outbuffer + offset + 0) = (u_action.base >> (8 * 0)) & 0xFF; *(outbuffer + offset + 1) = (u_action.base >> (8 * 1)) & 0xFF; *(outbuffer + offset + 2) = (u_action.base >> (8 * 2)) & 0xFF; *(outbuffer + offset + 3) = (u_action.base >> (8 * 3)) & 0xFF; offset += sizeof(this->action); offset += this->position.serialize(outbuffer + offset); union { float real; uint32_t base; } u_scale; u_scale.real = this->scale; *(outbuffer + offset + 0) = (u_scale.base >> (8 * 0)) & 0xFF; *(outbuffer + offset + 1) = (u_scale.base >> (8 * 1)) & 0xFF; *(outbuffer + offset + 2) = (u_scale.base >> (8 * 2)) & 0xFF; *(outbuffer + offset + 3) = (u_scale.base >> (8 * 3)) & 0xFF; offset += sizeof(this->scale); offset += this->outline_color.serialize(outbuffer + offset); *(outbuffer + offset + 0) = (this->filled >> (8 * 0)) & 0xFF; offset += sizeof(this->filled); offset += this->fill_color.serialize(outbuffer + offset); *(outbuffer + offset + 0) = (this->lifetime.sec >> (8 * 0)) & 0xFF; *(outbuffer + offset + 1) = (this->lifetime.sec >> (8 * 1)) & 0xFF; *(outbuffer + offset + 2) = (this->lifetime.sec >> (8 * 2)) & 0xFF; *(outbuffer + offset + 3) = (this->lifetime.sec >> (8 * 3)) & 0xFF; offset += sizeof(this->lifetime.sec); *(outbuffer + offset + 0) = (this->lifetime.nsec >> (8 * 0)) & 0xFF; *(outbuffer + offset + 1) = (this->lifetime.nsec >> (8 * 1)) & 0xFF; *(outbuffer + offset + 2) = (this->lifetime.nsec >> (8 * 2)) & 0xFF; *(outbuffer + offset + 3) = (this->lifetime.nsec >> (8 * 3)) & 0xFF; offset += sizeof(this->lifetime.nsec); *(outbuffer + offset++) = points_length; *(outbuffer + offset++) = 0; *(outbuffer + offset++) = 0; *(outbuffer + offset++) = 0; for( uint8_t i = 0; i < points_length; i++){ offset += this->points[i].serialize(outbuffer + offset); } *(outbuffer + offset++) = outline_colors_length; *(outbuffer + offset++) = 0; *(outbuffer + offset++) = 0; *(outbuffer + offset++) = 0; for( uint8_t i = 0; i < outline_colors_length; i++){ offset += this->outline_colors[i].serialize(outbuffer + offset); } return offset; } virtual int deserialize(unsigned char *inbuffer) { int offset = 0; offset += this->header.deserialize(inbuffer + offset); uint32_t length_ns; memcpy(&length_ns, (inbuffer + offset), sizeof(uint32_t)); offset += 4; for(unsigned int k= offset; k< offset+length_ns; ++k){ inbuffer[k-1]=inbuffer[k]; } inbuffer[offset+length_ns-1]=0; this->ns = (char *)(inbuffer + offset-1); offset += length_ns; union { int32_t real; uint32_t base; } u_id; u_id.base = 0; u_id.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); u_id.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); u_id.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); u_id.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); this->id = u_id.real; offset += sizeof(this->id); union { int32_t real; uint32_t base; } u_type; u_type.base = 0; u_type.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); u_type.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); u_type.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); u_type.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); this->type = u_type.real; offset += sizeof(this->type); union { int32_t real; uint32_t base; } u_action; u_action.base = 0; u_action.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); u_action.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); u_action.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); u_action.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); this->action = u_action.real; offset += sizeof(this->action); offset += this->position.deserialize(inbuffer + offset); union { float real; uint32_t base; } u_scale; u_scale.base = 0; u_scale.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); u_scale.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); u_scale.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); u_scale.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); this->scale = u_scale.real; offset += sizeof(this->scale); offset += this->outline_color.deserialize(inbuffer + offset); this->filled = ((uint8_t) (*(inbuffer + offset))); offset += sizeof(this->filled); offset += this->fill_color.deserialize(inbuffer + offset); this->lifetime.sec = ((uint32_t) (*(inbuffer + offset))); this->lifetime.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); this->lifetime.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); this->lifetime.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); offset += sizeof(this->lifetime.sec); this->lifetime.nsec = ((uint32_t) (*(inbuffer + offset))); this->lifetime.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); this->lifetime.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); this->lifetime.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); offset += sizeof(this->lifetime.nsec); uint8_t points_lengthT = *(inbuffer + offset++); if(points_lengthT > points_length) this->points = (geometry_msgs::Point*)realloc(this->points, points_lengthT * sizeof(geometry_msgs::Point)); offset += 3; points_length = points_lengthT; for( uint8_t i = 0; i < points_length; i++){ offset += this->st_points.deserialize(inbuffer + offset); memcpy( &(this->points[i]), &(this->st_points), sizeof(geometry_msgs::Point)); } uint8_t outline_colors_lengthT = *(inbuffer + offset++); if(outline_colors_lengthT > outline_colors_length) this->outline_colors = (std_msgs::ColorRGBA*)realloc(this->outline_colors, outline_colors_lengthT * sizeof(std_msgs::ColorRGBA)); offset += 3; outline_colors_length = outline_colors_lengthT; for( uint8_t i = 0; i < outline_colors_length; i++){ offset += this->st_outline_colors.deserialize(inbuffer + offset); memcpy( &(this->outline_colors[i]), &(this->st_outline_colors), sizeof(std_msgs::ColorRGBA)); } return offset; } const char * getType(){ return "visualization_msgs/ImageMarker"; }; const char * getMD5(){ return "1de93c67ec8858b831025a08fbf1b35c"; }; }; } #endif