catchrobo2022 mbed LPC1768 メインプログラム

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SparseOccupancyGridColumn.h Source File

SparseOccupancyGridColumn.h

00001 #ifndef _ROS_jsk_recognition_msgs_SparseOccupancyGridColumn_h
00002 #define _ROS_jsk_recognition_msgs_SparseOccupancyGridColumn_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 #include "jsk_recognition_msgs/SparseOccupancyGridCell.h"
00009 
00010 namespace jsk_recognition_msgs
00011 {
00012 
00013   class SparseOccupancyGridColumn : public ros::Msg
00014   {
00015     public:
00016       typedef int32_t _column_index_type;
00017       _column_index_type column_index;
00018       uint32_t cells_length;
00019       typedef jsk_recognition_msgs::SparseOccupancyGridCell _cells_type;
00020       _cells_type st_cells;
00021       _cells_type * cells;
00022 
00023     SparseOccupancyGridColumn():
00024       column_index(0),
00025       cells_length(0), cells(NULL)
00026     {
00027     }
00028 
00029     virtual int serialize(unsigned char *outbuffer) const
00030     {
00031       int offset = 0;
00032       union {
00033         int32_t real;
00034         uint32_t base;
00035       } u_column_index;
00036       u_column_index.real = this->column_index;
00037       *(outbuffer + offset + 0) = (u_column_index.base >> (8 * 0)) & 0xFF;
00038       *(outbuffer + offset + 1) = (u_column_index.base >> (8 * 1)) & 0xFF;
00039       *(outbuffer + offset + 2) = (u_column_index.base >> (8 * 2)) & 0xFF;
00040       *(outbuffer + offset + 3) = (u_column_index.base >> (8 * 3)) & 0xFF;
00041       offset += sizeof(this->column_index);
00042       *(outbuffer + offset + 0) = (this->cells_length >> (8 * 0)) & 0xFF;
00043       *(outbuffer + offset + 1) = (this->cells_length >> (8 * 1)) & 0xFF;
00044       *(outbuffer + offset + 2) = (this->cells_length >> (8 * 2)) & 0xFF;
00045       *(outbuffer + offset + 3) = (this->cells_length >> (8 * 3)) & 0xFF;
00046       offset += sizeof(this->cells_length);
00047       for( uint32_t i = 0; i < cells_length; i++){
00048       offset += this->cells[i].serialize(outbuffer + offset);
00049       }
00050       return offset;
00051     }
00052 
00053     virtual int deserialize(unsigned char *inbuffer)
00054     {
00055       int offset = 0;
00056       union {
00057         int32_t real;
00058         uint32_t base;
00059       } u_column_index;
00060       u_column_index.base = 0;
00061       u_column_index.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00062       u_column_index.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00063       u_column_index.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00064       u_column_index.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00065       this->column_index = u_column_index.real;
00066       offset += sizeof(this->column_index);
00067       uint32_t cells_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00068       cells_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00069       cells_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00070       cells_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00071       offset += sizeof(this->cells_length);
00072       if(cells_lengthT > cells_length)
00073         this->cells = (jsk_recognition_msgs::SparseOccupancyGridCell*)realloc(this->cells, cells_lengthT * sizeof(jsk_recognition_msgs::SparseOccupancyGridCell));
00074       cells_length = cells_lengthT;
00075       for( uint32_t i = 0; i < cells_length; i++){
00076       offset += this->st_cells.deserialize(inbuffer + offset);
00077         memcpy( &(this->cells[i]), &(this->st_cells), sizeof(jsk_recognition_msgs::SparseOccupancyGridCell));
00078       }
00079      return offset;
00080     }
00081 
00082     virtual const char * getType(){ return "jsk_recognition_msgs/SparseOccupancyGridColumn"; };
00083     virtual const char * getMD5(){ return "55074b193e722d5ead092ffe27f06522"; };
00084 
00085   };
00086 
00087 }
00088 #endif