Status.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *   http://www.apache.org/licenses/LICENSE-2.0
00009 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016  
00017 
00018 #ifndef _ROS_cob_hand_bridge_Status_h
00019 #define _ROS_cob_hand_bridge_Status_h
00020 
00021 #include <stdint.h>
00022 #include <string.h>
00023 #include <stdlib.h>
00024 #include "ros/msg.h"
00025 #include "ros/time.h"
00026 #include "cob_hand_bridge/JointValues.h"
00027 
00028 namespace cob_hand_bridge
00029 {
00030 
00031   class Status : public ros::Msg
00032   {
00033     public:
00034       uint32_t seq;
00035       ros::Time stamp;
00036       uint8_t status;
00037       uint8_t rc;
00038       uint32_t pins;
00039       cob_hand_bridge::JointValues joints;
00040       enum { NOT_INITIALIZED = 0 };
00041       enum { MASK_FINGER_READY = 1 };
00042       enum { MASK_GPIO_READY = 2 };
00043       enum { MASK_ERROR = 4 };
00044       enum { RC_OK = 0 };
00045 
00046     Status():
00047       seq(0),
00048       stamp(),
00049       status(0),
00050       rc(0),
00051       pins(0),
00052       joints()
00053     {
00054     }
00055 
00056     virtual int serialize(unsigned char *outbuffer) const
00057     {
00058       int offset = 0;
00059       *(outbuffer + offset + 0) = (this->seq >> (8 * 0)) & 0xFF;
00060       *(outbuffer + offset + 1) = (this->seq >> (8 * 1)) & 0xFF;
00061       *(outbuffer + offset + 2) = (this->seq >> (8 * 2)) & 0xFF;
00062       *(outbuffer + offset + 3) = (this->seq >> (8 * 3)) & 0xFF;
00063       offset += sizeof(this->seq);
00064       *(outbuffer + offset + 0) = (this->stamp.sec >> (8 * 0)) & 0xFF;
00065       *(outbuffer + offset + 1) = (this->stamp.sec >> (8 * 1)) & 0xFF;
00066       *(outbuffer + offset + 2) = (this->stamp.sec >> (8 * 2)) & 0xFF;
00067       *(outbuffer + offset + 3) = (this->stamp.sec >> (8 * 3)) & 0xFF;
00068       offset += sizeof(this->stamp.sec);
00069       *(outbuffer + offset + 0) = (this->stamp.nsec >> (8 * 0)) & 0xFF;
00070       *(outbuffer + offset + 1) = (this->stamp.nsec >> (8 * 1)) & 0xFF;
00071       *(outbuffer + offset + 2) = (this->stamp.nsec >> (8 * 2)) & 0xFF;
00072       *(outbuffer + offset + 3) = (this->stamp.nsec >> (8 * 3)) & 0xFF;
00073       offset += sizeof(this->stamp.nsec);
00074       *(outbuffer + offset + 0) = (this->status >> (8 * 0)) & 0xFF;
00075       offset += sizeof(this->status);
00076       *(outbuffer + offset + 0) = (this->rc >> (8 * 0)) & 0xFF;
00077       offset += sizeof(this->rc);
00078       *(outbuffer + offset + 0) = (this->pins >> (8 * 0)) & 0xFF;
00079       *(outbuffer + offset + 1) = (this->pins >> (8 * 1)) & 0xFF;
00080       *(outbuffer + offset + 2) = (this->pins >> (8 * 2)) & 0xFF;
00081       *(outbuffer + offset + 3) = (this->pins >> (8 * 3)) & 0xFF;
00082       offset += sizeof(this->pins);
00083       offset += this->joints.serialize(outbuffer + offset);
00084       return offset;
00085     }
00086 
00087     virtual int deserialize(unsigned char *inbuffer)
00088     {
00089       int offset = 0;
00090       this->seq =  ((uint32_t) (*(inbuffer + offset)));
00091       this->seq |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00092       this->seq |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00093       this->seq |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00094       offset += sizeof(this->seq);
00095       this->stamp.sec =  ((uint32_t) (*(inbuffer + offset)));
00096       this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00097       this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00098       this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00099       offset += sizeof(this->stamp.sec);
00100       this->stamp.nsec =  ((uint32_t) (*(inbuffer + offset)));
00101       this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00102       this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00103       this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00104       offset += sizeof(this->stamp.nsec);
00105       this->status =  ((uint8_t) (*(inbuffer + offset)));
00106       offset += sizeof(this->status);
00107       this->rc =  ((uint8_t) (*(inbuffer + offset)));
00108       offset += sizeof(this->rc);
00109       this->pins =  ((uint32_t) (*(inbuffer + offset)));
00110       this->pins |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00111       this->pins |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00112       this->pins |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00113       offset += sizeof(this->pins);
00114       offset += this->joints.deserialize(inbuffer + offset);
00115      return offset;
00116     }
00117 
00118     const char * getType(){ return "cob_hand_bridge/Status"; };
00119     const char * getMD5(){ return "d1e9c755cdcb7c29d72650239e9eb91a"; };
00120 
00121   };
00122 
00123 }
00124 #endif


cob_hand_bridge
Author(s): Mathias Lüdtke
autogenerated on Thu Jun 6 2019 20:43:57