catchrobo2022 mbed LPC1768 メインプログラム

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MultiTouch.h Source File

MultiTouch.h

00001 #ifndef _ROS_jsk_gui_msgs_MultiTouch_h
00002 #define _ROS_jsk_gui_msgs_MultiTouch_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 #include "jsk_gui_msgs/Touch.h"
00009 
00010 namespace jsk_gui_msgs
00011 {
00012 
00013   class MultiTouch : public ros::Msg
00014   {
00015     public:
00016       uint32_t touches_length;
00017       typedef jsk_gui_msgs::Touch _touches_type;
00018       _touches_type st_touches;
00019       _touches_type * touches;
00020 
00021     MultiTouch():
00022       touches_length(0), touches(NULL)
00023     {
00024     }
00025 
00026     virtual int serialize(unsigned char *outbuffer) const
00027     {
00028       int offset = 0;
00029       *(outbuffer + offset + 0) = (this->touches_length >> (8 * 0)) & 0xFF;
00030       *(outbuffer + offset + 1) = (this->touches_length >> (8 * 1)) & 0xFF;
00031       *(outbuffer + offset + 2) = (this->touches_length >> (8 * 2)) & 0xFF;
00032       *(outbuffer + offset + 3) = (this->touches_length >> (8 * 3)) & 0xFF;
00033       offset += sizeof(this->touches_length);
00034       for( uint32_t i = 0; i < touches_length; i++){
00035       offset += this->touches[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 touches_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00044       touches_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00045       touches_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00046       touches_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00047       offset += sizeof(this->touches_length);
00048       if(touches_lengthT > touches_length)
00049         this->touches = (jsk_gui_msgs::Touch*)realloc(this->touches, touches_lengthT * sizeof(jsk_gui_msgs::Touch));
00050       touches_length = touches_lengthT;
00051       for( uint32_t i = 0; i < touches_length; i++){
00052       offset += this->st_touches.deserialize(inbuffer + offset);
00053         memcpy( &(this->touches[i]), &(this->st_touches), sizeof(jsk_gui_msgs::Touch));
00054       }
00055      return offset;
00056     }
00057 
00058     virtual const char * getType(){ return "jsk_gui_msgs/MultiTouch"; };
00059     virtual const char * getMD5(){ return "9f4a309588ef669e69a71aa5601ea65e"; };
00060 
00061   };
00062 
00063 }
00064 #endif