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 MenuEntry.h Source File

MenuEntry.h

00001 #ifndef _ROS_visualization_msgs_MenuEntry_h
00002 #define _ROS_visualization_msgs_MenuEntry_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 
00009 namespace visualization_msgs
00010 {
00011 
00012   class MenuEntry : public ros::Msg
00013   {
00014     public:
00015       typedef uint32_t _id_type;
00016       _id_type id;
00017       typedef uint32_t _parent_id_type;
00018       _parent_id_type parent_id;
00019       typedef const char* _title_type;
00020       _title_type title;
00021       typedef const char* _command_type;
00022       _command_type command;
00023       typedef uint8_t _command_type_type;
00024       _command_type_type command_type;
00025       enum { FEEDBACK = 0 };
00026       enum { ROSRUN = 1 };
00027       enum { ROSLAUNCH = 2 };
00028 
00029     MenuEntry():
00030       id(0),
00031       parent_id(0),
00032       title(""),
00033       command(""),
00034       command_type(0)
00035     {
00036     }
00037 
00038     virtual int serialize(unsigned char *outbuffer) const
00039     {
00040       int offset = 0;
00041       *(outbuffer + offset + 0) = (this->id >> (8 * 0)) & 0xFF;
00042       *(outbuffer + offset + 1) = (this->id >> (8 * 1)) & 0xFF;
00043       *(outbuffer + offset + 2) = (this->id >> (8 * 2)) & 0xFF;
00044       *(outbuffer + offset + 3) = (this->id >> (8 * 3)) & 0xFF;
00045       offset += sizeof(this->id);
00046       *(outbuffer + offset + 0) = (this->parent_id >> (8 * 0)) & 0xFF;
00047       *(outbuffer + offset + 1) = (this->parent_id >> (8 * 1)) & 0xFF;
00048       *(outbuffer + offset + 2) = (this->parent_id >> (8 * 2)) & 0xFF;
00049       *(outbuffer + offset + 3) = (this->parent_id >> (8 * 3)) & 0xFF;
00050       offset += sizeof(this->parent_id);
00051       uint32_t length_title = strlen(this->title);
00052       varToArr(outbuffer + offset, length_title);
00053       offset += 4;
00054       memcpy(outbuffer + offset, this->title, length_title);
00055       offset += length_title;
00056       uint32_t length_command = strlen(this->command);
00057       varToArr(outbuffer + offset, length_command);
00058       offset += 4;
00059       memcpy(outbuffer + offset, this->command, length_command);
00060       offset += length_command;
00061       *(outbuffer + offset + 0) = (this->command_type >> (8 * 0)) & 0xFF;
00062       offset += sizeof(this->command_type);
00063       return offset;
00064     }
00065 
00066     virtual int deserialize(unsigned char *inbuffer)
00067     {
00068       int offset = 0;
00069       this->id =  ((uint32_t) (*(inbuffer + offset)));
00070       this->id |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00071       this->id |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00072       this->id |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00073       offset += sizeof(this->id);
00074       this->parent_id =  ((uint32_t) (*(inbuffer + offset)));
00075       this->parent_id |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00076       this->parent_id |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00077       this->parent_id |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00078       offset += sizeof(this->parent_id);
00079       uint32_t length_title;
00080       arrToVar(length_title, (inbuffer + offset));
00081       offset += 4;
00082       for(unsigned int k= offset; k< offset+length_title; ++k){
00083           inbuffer[k-1]=inbuffer[k];
00084       }
00085       inbuffer[offset+length_title-1]=0;
00086       this->title = (char *)(inbuffer + offset-1);
00087       offset += length_title;
00088       uint32_t length_command;
00089       arrToVar(length_command, (inbuffer + offset));
00090       offset += 4;
00091       for(unsigned int k= offset; k< offset+length_command; ++k){
00092           inbuffer[k-1]=inbuffer[k];
00093       }
00094       inbuffer[offset+length_command-1]=0;
00095       this->command = (char *)(inbuffer + offset-1);
00096       offset += length_command;
00097       this->command_type =  ((uint8_t) (*(inbuffer + offset)));
00098       offset += sizeof(this->command_type);
00099      return offset;
00100     }
00101 
00102     const char * getType(){ return "visualization_msgs/MenuEntry"; };
00103     const char * getMD5(){ return "b90ec63024573de83b57aa93eb39be2d"; };
00104 
00105   };
00106 
00107 }
00108 #endif