JointValues.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_JointValues_h
00019 #define _ROS_cob_hand_bridge_JointValues_h
00020 
00021 #include <stdint.h>
00022 #include <string.h>
00023 #include <stdlib.h>
00024 #include "ros/msg.h"
00025 
00026 namespace cob_hand_bridge
00027 {
00028 
00029   class JointValues : public ros::Msg
00030   {
00031     public:
00032       int16_t position_cdeg[2];
00033       int16_t velocity_cdeg_s[2];
00034       int16_t current_100uA[2];
00035 
00036     JointValues():
00037       position_cdeg(),
00038       velocity_cdeg_s(),
00039       current_100uA()
00040     {
00041     }
00042 
00043     virtual int serialize(unsigned char *outbuffer) const
00044     {
00045       int offset = 0;
00046       for( uint8_t i = 0; i < 2; i++){
00047       union {
00048         int16_t real;
00049         uint16_t base;
00050       } u_position_cdegi;
00051       u_position_cdegi.real = this->position_cdeg[i];
00052       *(outbuffer + offset + 0) = (u_position_cdegi.base >> (8 * 0)) & 0xFF;
00053       *(outbuffer + offset + 1) = (u_position_cdegi.base >> (8 * 1)) & 0xFF;
00054       offset += sizeof(this->position_cdeg[i]);
00055       }
00056       for( uint8_t i = 0; i < 2; i++){
00057       union {
00058         int16_t real;
00059         uint16_t base;
00060       } u_velocity_cdeg_si;
00061       u_velocity_cdeg_si.real = this->velocity_cdeg_s[i];
00062       *(outbuffer + offset + 0) = (u_velocity_cdeg_si.base >> (8 * 0)) & 0xFF;
00063       *(outbuffer + offset + 1) = (u_velocity_cdeg_si.base >> (8 * 1)) & 0xFF;
00064       offset += sizeof(this->velocity_cdeg_s[i]);
00065       }
00066       for( uint8_t i = 0; i < 2; i++){
00067       union {
00068         int16_t real;
00069         uint16_t base;
00070       } u_current_100uAi;
00071       u_current_100uAi.real = this->current_100uA[i];
00072       *(outbuffer + offset + 0) = (u_current_100uAi.base >> (8 * 0)) & 0xFF;
00073       *(outbuffer + offset + 1) = (u_current_100uAi.base >> (8 * 1)) & 0xFF;
00074       offset += sizeof(this->current_100uA[i]);
00075       }
00076       return offset;
00077     }
00078 
00079     virtual int deserialize(unsigned char *inbuffer)
00080     {
00081       int offset = 0;
00082       for( uint8_t i = 0; i < 2; i++){
00083       union {
00084         int16_t real;
00085         uint16_t base;
00086       } u_position_cdegi;
00087       u_position_cdegi.base = 0;
00088       u_position_cdegi.base |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
00089       u_position_cdegi.base |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
00090       this->position_cdeg[i] = u_position_cdegi.real;
00091       offset += sizeof(this->position_cdeg[i]);
00092       }
00093       for( uint8_t i = 0; i < 2; i++){
00094       union {
00095         int16_t real;
00096         uint16_t base;
00097       } u_velocity_cdeg_si;
00098       u_velocity_cdeg_si.base = 0;
00099       u_velocity_cdeg_si.base |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
00100       u_velocity_cdeg_si.base |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
00101       this->velocity_cdeg_s[i] = u_velocity_cdeg_si.real;
00102       offset += sizeof(this->velocity_cdeg_s[i]);
00103       }
00104       for( uint8_t i = 0; i < 2; i++){
00105       union {
00106         int16_t real;
00107         uint16_t base;
00108       } u_current_100uAi;
00109       u_current_100uAi.base = 0;
00110       u_current_100uAi.base |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
00111       u_current_100uAi.base |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
00112       this->current_100uA[i] = u_current_100uAi.real;
00113       offset += sizeof(this->current_100uA[i]);
00114       }
00115      return offset;
00116     }
00117 
00118     const char * getType(){ return "cob_hand_bridge/JointValues"; };
00119     const char * getMD5(){ return "a8168eaf63b3492bbb7dcd4942c4f1c0"; };
00120 
00121   };
00122 
00123 }
00124 #endif


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