catchrobo2022 / Mbed 2 deprecated catchrobo2022_mbed

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ContactSensor.h Source File

ContactSensor.h

00001 #ifndef _ROS_jsk_recognition_msgs_ContactSensor_h
00002 #define _ROS_jsk_recognition_msgs_ContactSensor_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 #include "std_msgs/Header.h"
00009 
00010 namespace jsk_recognition_msgs
00011 {
00012 
00013   class ContactSensor : public ros::Msg
00014   {
00015     public:
00016       typedef std_msgs::Header _header_type;
00017       _header_type header;
00018       typedef bool _contact_type;
00019       _contact_type contact;
00020       typedef const char* _link_name_type;
00021       _link_name_type link_name;
00022 
00023     ContactSensor():
00024       header(),
00025       contact(0),
00026       link_name("")
00027     {
00028     }
00029 
00030     virtual int serialize(unsigned char *outbuffer) const
00031     {
00032       int offset = 0;
00033       offset += this->header.serialize(outbuffer + offset);
00034       union {
00035         bool real;
00036         uint8_t base;
00037       } u_contact;
00038       u_contact.real = this->contact;
00039       *(outbuffer + offset + 0) = (u_contact.base >> (8 * 0)) & 0xFF;
00040       offset += sizeof(this->contact);
00041       uint32_t length_link_name = strlen(this->link_name);
00042       varToArr(outbuffer + offset, length_link_name);
00043       offset += 4;
00044       memcpy(outbuffer + offset, this->link_name, length_link_name);
00045       offset += length_link_name;
00046       return offset;
00047     }
00048 
00049     virtual int deserialize(unsigned char *inbuffer)
00050     {
00051       int offset = 0;
00052       offset += this->header.deserialize(inbuffer + offset);
00053       union {
00054         bool real;
00055         uint8_t base;
00056       } u_contact;
00057       u_contact.base = 0;
00058       u_contact.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
00059       this->contact = u_contact.real;
00060       offset += sizeof(this->contact);
00061       uint32_t length_link_name;
00062       arrToVar(length_link_name, (inbuffer + offset));
00063       offset += 4;
00064       for(unsigned int k= offset; k< offset+length_link_name; ++k){
00065           inbuffer[k-1]=inbuffer[k];
00066       }
00067       inbuffer[offset+length_link_name-1]=0;
00068       this->link_name = (char *)(inbuffer + offset-1);
00069       offset += length_link_name;
00070      return offset;
00071     }
00072 
00073     virtual const char * getType(){ return "jsk_recognition_msgs/ContactSensor"; };
00074     virtual const char * getMD5(){ return "364b2b952a51d85dfa877e334264e361"; };
00075 
00076   };
00077 
00078 }
00079 #endif