Working towards recieving twists

Dependencies:   BufferedSerial

Fork of ros_lib_kinetic by Gary Servin

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TwistWithCovariance.h Source File

TwistWithCovariance.h

00001 #ifndef _ROS_geometry_msgs_TwistWithCovariance_h
00002 #define _ROS_geometry_msgs_TwistWithCovariance_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 #include "geometry_msgs/Twist.h"
00009 
00010 namespace geometry_msgs
00011 {
00012 
00013   class TwistWithCovariance : public ros::Msg
00014   {
00015     public:
00016       typedef geometry_msgs::Twist _twist_type;
00017       _twist_type twist;
00018       double covariance[36];
00019 
00020     TwistWithCovariance():
00021       twist(),
00022       covariance()
00023     {
00024     }
00025 
00026     virtual int serialize(unsigned char *outbuffer) const
00027     {
00028       int offset = 0;
00029       offset += this->twist.serialize(outbuffer + offset);
00030       for( uint32_t i = 0; i < 36; i++){
00031       union {
00032         double real;
00033         uint64_t base;
00034       } u_covariancei;
00035       u_covariancei.real = this->covariance[i];
00036       *(outbuffer + offset + 0) = (u_covariancei.base >> (8 * 0)) & 0xFF;
00037       *(outbuffer + offset + 1) = (u_covariancei.base >> (8 * 1)) & 0xFF;
00038       *(outbuffer + offset + 2) = (u_covariancei.base >> (8 * 2)) & 0xFF;
00039       *(outbuffer + offset + 3) = (u_covariancei.base >> (8 * 3)) & 0xFF;
00040       *(outbuffer + offset + 4) = (u_covariancei.base >> (8 * 4)) & 0xFF;
00041       *(outbuffer + offset + 5) = (u_covariancei.base >> (8 * 5)) & 0xFF;
00042       *(outbuffer + offset + 6) = (u_covariancei.base >> (8 * 6)) & 0xFF;
00043       *(outbuffer + offset + 7) = (u_covariancei.base >> (8 * 7)) & 0xFF;
00044       offset += sizeof(this->covariance[i]);
00045       }
00046       return offset;
00047     }
00048 
00049     virtual int deserialize(unsigned char *inbuffer)
00050     {
00051       int offset = 0;
00052       offset += this->twist.deserialize(inbuffer + offset);
00053       for( uint32_t i = 0; i < 36; i++){
00054       union {
00055         double real;
00056         uint64_t base;
00057       } u_covariancei;
00058       u_covariancei.base = 0;
00059       u_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
00060       u_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
00061       u_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
00062       u_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
00063       u_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
00064       u_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
00065       u_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
00066       u_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
00067       this->covariance[i] = u_covariancei.real;
00068       offset += sizeof(this->covariance[i]);
00069       }
00070      return offset;
00071     }
00072 
00073     const char * getType(){ return "geometry_msgs/TwistWithCovariance"; };
00074     const char * getMD5(){ return "1fe8a28e6890a4cc3ae4c3ca5c7d82e6"; };
00075 
00076   };
00077 
00078 }
00079 #endif