catchrobo2022 / Mbed 2 deprecated catchrobo2022_mbed

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MyRosCmdArray.h Source File

MyRosCmdArray.h

00001 #ifndef _ROS_catchrobo_msgs_MyRosCmdArray_h
00002 #define _ROS_catchrobo_msgs_MyRosCmdArray_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 #include "catchrobo_msgs/MyRosCmd.h"
00009 
00010 namespace catchrobo_msgs
00011 {
00012 
00013   class MyRosCmdArray : public ros::Msg
00014   {
00015     public:
00016       uint32_t command_array_length;
00017       typedef catchrobo_msgs::MyRosCmd _command_array_type;
00018       _command_array_type st_command_array;
00019       _command_array_type * command_array;
00020 
00021     MyRosCmdArray():
00022       command_array_length(0), command_array(NULL)
00023     {
00024     }
00025 
00026     virtual int serialize(unsigned char *outbuffer) const
00027     {
00028       int offset = 0;
00029       *(outbuffer + offset + 0) = (this->command_array_length >> (8 * 0)) & 0xFF;
00030       *(outbuffer + offset + 1) = (this->command_array_length >> (8 * 1)) & 0xFF;
00031       *(outbuffer + offset + 2) = (this->command_array_length >> (8 * 2)) & 0xFF;
00032       *(outbuffer + offset + 3) = (this->command_array_length >> (8 * 3)) & 0xFF;
00033       offset += sizeof(this->command_array_length);
00034       for( uint32_t i = 0; i < command_array_length; i++){
00035       offset += this->command_array[i].serialize(outbuffer + offset);
00036       }
00037       return offset;
00038     }
00039 
00040     virtual int deserialize(unsigned char *inbuffer)
00041     {
00042       int offset = 0;
00043       uint32_t command_array_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00044       command_array_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00045       command_array_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00046       command_array_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00047       offset += sizeof(this->command_array_length);
00048       if(command_array_lengthT > command_array_length)
00049         this->command_array = (catchrobo_msgs::MyRosCmd*)realloc(this->command_array, command_array_lengthT * sizeof(catchrobo_msgs::MyRosCmd));
00050       command_array_length = command_array_lengthT;
00051       for( uint32_t i = 0; i < command_array_length; i++){
00052       offset += this->st_command_array.deserialize(inbuffer + offset);
00053         memcpy( &(this->command_array[i]), &(this->st_command_array), sizeof(catchrobo_msgs::MyRosCmd));
00054       }
00055      return offset;
00056     }
00057 
00058     virtual const char * getType(){ return "catchrobo_msgs/MyRosCmdArray"; };
00059     virtual const char * getMD5(){ return "9cc28e913d9d86366e7efe81e2393470"; };
00060 
00061   };
00062 
00063 }
00064 #endif