catchrobo2022 / Mbed 2 deprecated catchrobo2022_mbed

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers RecordCommand.h Source File

RecordCommand.h

00001 #ifndef _ROS_jsk_rviz_plugins_RecordCommand_h
00002 #define _ROS_jsk_rviz_plugins_RecordCommand_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 
00009 namespace jsk_rviz_plugins
00010 {
00011 
00012   class RecordCommand : public ros::Msg
00013   {
00014     public:
00015       typedef int8_t _command_type;
00016       _command_type command;
00017       typedef const char* _target_type;
00018       _target_type target;
00019       enum { RECORD = 0 };
00020       enum { RECORD_STOP = 1 };
00021       enum { PLAY = 2 };
00022 
00023     RecordCommand():
00024       command(0),
00025       target("")
00026     {
00027     }
00028 
00029     virtual int serialize(unsigned char *outbuffer) const
00030     {
00031       int offset = 0;
00032       union {
00033         int8_t real;
00034         uint8_t base;
00035       } u_command;
00036       u_command.real = this->command;
00037       *(outbuffer + offset + 0) = (u_command.base >> (8 * 0)) & 0xFF;
00038       offset += sizeof(this->command);
00039       uint32_t length_target = strlen(this->target);
00040       varToArr(outbuffer + offset, length_target);
00041       offset += 4;
00042       memcpy(outbuffer + offset, this->target, length_target);
00043       offset += length_target;
00044       return offset;
00045     }
00046 
00047     virtual int deserialize(unsigned char *inbuffer)
00048     {
00049       int offset = 0;
00050       union {
00051         int8_t real;
00052         uint8_t base;
00053       } u_command;
00054       u_command.base = 0;
00055       u_command.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
00056       this->command = u_command.real;
00057       offset += sizeof(this->command);
00058       uint32_t length_target;
00059       arrToVar(length_target, (inbuffer + offset));
00060       offset += 4;
00061       for(unsigned int k= offset; k< offset+length_target; ++k){
00062           inbuffer[k-1]=inbuffer[k];
00063       }
00064       inbuffer[offset+length_target-1]=0;
00065       this->target = (char *)(inbuffer + offset-1);
00066       offset += length_target;
00067      return offset;
00068     }
00069 
00070     virtual const char * getType(){ return "jsk_rviz_plugins/RecordCommand"; };
00071     virtual const char * getMD5(){ return "31931c62eab5500089183eef0161c139"; };
00072 
00073   };
00074 
00075 }
00076 #endif