This program is porting rosserial_arduino for mbed http://www.ros.org/wiki/rosserial_arduino This program supported the revision of 169 of rosserial.

Dependencies:  

Dependents:   rosserial_mbed robot_S2

Committer:
nucho
Date:
Wed Feb 29 23:00:21 2012 +0000
Revision:
4:684f39d0c346
Parent:
3:1cf99502f396

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nucho 3:1cf99502f396 1 #ifndef _ROS_geometry_msgs_TwistWithCovariance_h
nucho 3:1cf99502f396 2 #define _ROS_geometry_msgs_TwistWithCovariance_h
nucho 0:77afd7560544 3
nucho 0:77afd7560544 4 #include <stdint.h>
nucho 0:77afd7560544 5 #include <string.h>
nucho 0:77afd7560544 6 #include <stdlib.h>
nucho 3:1cf99502f396 7 #include "ros/msg.h"
nucho 0:77afd7560544 8 #include "geometry_msgs/Twist.h"
nucho 0:77afd7560544 9
nucho 0:77afd7560544 10 namespace geometry_msgs
nucho 0:77afd7560544 11 {
nucho 0:77afd7560544 12
nucho 0:77afd7560544 13 class TwistWithCovariance : public ros::Msg
nucho 0:77afd7560544 14 {
nucho 0:77afd7560544 15 public:
nucho 0:77afd7560544 16 geometry_msgs::Twist twist;
nucho 0:77afd7560544 17 float covariance[36];
nucho 0:77afd7560544 18
nucho 3:1cf99502f396 19 virtual int serialize(unsigned char *outbuffer) const
nucho 0:77afd7560544 20 {
nucho 0:77afd7560544 21 int offset = 0;
nucho 0:77afd7560544 22 offset += this->twist.serialize(outbuffer + offset);
nucho 0:77afd7560544 23 unsigned char * covariance_val = (unsigned char *) this->covariance;
nucho 3:1cf99502f396 24 for( uint8_t i = 0; i < 36; i++){
nucho 3:1cf99502f396 25 int32_t * val_covariancei = (long *) &(this->covariance[i]);
nucho 3:1cf99502f396 26 int32_t exp_covariancei = (((*val_covariancei)>>23)&255);
nucho 0:77afd7560544 27 if(exp_covariancei != 0)
nucho 0:77afd7560544 28 exp_covariancei += 1023-127;
nucho 3:1cf99502f396 29 int32_t sig_covariancei = *val_covariancei;
nucho 0:77afd7560544 30 *(outbuffer + offset++) = 0;
nucho 0:77afd7560544 31 *(outbuffer + offset++) = 0;
nucho 0:77afd7560544 32 *(outbuffer + offset++) = 0;
nucho 0:77afd7560544 33 *(outbuffer + offset++) = (sig_covariancei<<5) & 0xff;
nucho 0:77afd7560544 34 *(outbuffer + offset++) = (sig_covariancei>>3) & 0xff;
nucho 0:77afd7560544 35 *(outbuffer + offset++) = (sig_covariancei>>11) & 0xff;
nucho 0:77afd7560544 36 *(outbuffer + offset++) = ((exp_covariancei<<4) & 0xF0) | ((sig_covariancei>>19)&0x0F);
nucho 0:77afd7560544 37 *(outbuffer + offset++) = (exp_covariancei>>4) & 0x7F;
nucho 0:77afd7560544 38 if(this->covariance[i] < 0) *(outbuffer + offset -1) |= 0x80;
nucho 0:77afd7560544 39 }
nucho 0:77afd7560544 40 return offset;
nucho 0:77afd7560544 41 }
nucho 0:77afd7560544 42
nucho 0:77afd7560544 43 virtual int deserialize(unsigned char *inbuffer)
nucho 0:77afd7560544 44 {
nucho 0:77afd7560544 45 int offset = 0;
nucho 0:77afd7560544 46 offset += this->twist.deserialize(inbuffer + offset);
nucho 3:1cf99502f396 47 uint8_t * covariance_val = (uint8_t*) this->covariance;
nucho 3:1cf99502f396 48 for( uint8_t i = 0; i < 36; i++){
nucho 3:1cf99502f396 49 uint32_t * val_covariancei = (uint32_t*) &(this->covariance[i]);
nucho 0:77afd7560544 50 offset += 3;
nucho 3:1cf99502f396 51 *val_covariancei = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07);
nucho 3:1cf99502f396 52 *val_covariancei |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3;
nucho 3:1cf99502f396 53 *val_covariancei |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11;
nucho 3:1cf99502f396 54 *val_covariancei |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19;
nucho 3:1cf99502f396 55 uint32_t exp_covariancei = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4;
nucho 3:1cf99502f396 56 exp_covariancei |= ((uint32_t)(*(inbuffer + offset)) & 0x7f)<<4;
nucho 0:77afd7560544 57 if(exp_covariancei !=0)
nucho 0:77afd7560544 58 *val_covariancei |= ((exp_covariancei)-1023+127)<<23;
nucho 0:77afd7560544 59 if( ((*(inbuffer+offset++)) & 0x80) > 0) this->covariance[i] = -this->covariance[i];
nucho 0:77afd7560544 60 }
nucho 0:77afd7560544 61 return offset;
nucho 0:77afd7560544 62 }
nucho 0:77afd7560544 63
nucho 3:1cf99502f396 64 virtual const char * getType(){ return "geometry_msgs/TwistWithCovariance"; };
nucho 3:1cf99502f396 65 virtual const char * getMD5(){ return "1fe8a28e6890a4cc3ae4c3ca5c7d82e6"; };
nucho 0:77afd7560544 66
nucho 0:77afd7560544 67 };
nucho 0:77afd7560544 68
nucho 0:77afd7560544 69 }
nucho 0:77afd7560544 70 #endif