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_Pose2D_h
nucho 3:1cf99502f396 2 #define _ROS_geometry_msgs_Pose2D_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
nucho 0:77afd7560544 9 namespace geometry_msgs
nucho 0:77afd7560544 10 {
nucho 0:77afd7560544 11
nucho 0:77afd7560544 12 class Pose2D : public ros::Msg
nucho 0:77afd7560544 13 {
nucho 0:77afd7560544 14 public:
nucho 0:77afd7560544 15 float x;
nucho 0:77afd7560544 16 float y;
nucho 0:77afd7560544 17 float theta;
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 3:1cf99502f396 22 int32_t * val_x = (long *) &(this->x);
nucho 3:1cf99502f396 23 int32_t exp_x = (((*val_x)>>23)&255);
nucho 0:77afd7560544 24 if(exp_x != 0)
nucho 0:77afd7560544 25 exp_x += 1023-127;
nucho 3:1cf99502f396 26 int32_t sig_x = *val_x;
nucho 0:77afd7560544 27 *(outbuffer + offset++) = 0;
nucho 0:77afd7560544 28 *(outbuffer + offset++) = 0;
nucho 0:77afd7560544 29 *(outbuffer + offset++) = 0;
nucho 0:77afd7560544 30 *(outbuffer + offset++) = (sig_x<<5) & 0xff;
nucho 0:77afd7560544 31 *(outbuffer + offset++) = (sig_x>>3) & 0xff;
nucho 0:77afd7560544 32 *(outbuffer + offset++) = (sig_x>>11) & 0xff;
nucho 0:77afd7560544 33 *(outbuffer + offset++) = ((exp_x<<4) & 0xF0) | ((sig_x>>19)&0x0F);
nucho 0:77afd7560544 34 *(outbuffer + offset++) = (exp_x>>4) & 0x7F;
nucho 0:77afd7560544 35 if(this->x < 0) *(outbuffer + offset -1) |= 0x80;
nucho 3:1cf99502f396 36 int32_t * val_y = (long *) &(this->y);
nucho 3:1cf99502f396 37 int32_t exp_y = (((*val_y)>>23)&255);
nucho 0:77afd7560544 38 if(exp_y != 0)
nucho 0:77afd7560544 39 exp_y += 1023-127;
nucho 3:1cf99502f396 40 int32_t sig_y = *val_y;
nucho 0:77afd7560544 41 *(outbuffer + offset++) = 0;
nucho 0:77afd7560544 42 *(outbuffer + offset++) = 0;
nucho 0:77afd7560544 43 *(outbuffer + offset++) = 0;
nucho 0:77afd7560544 44 *(outbuffer + offset++) = (sig_y<<5) & 0xff;
nucho 0:77afd7560544 45 *(outbuffer + offset++) = (sig_y>>3) & 0xff;
nucho 0:77afd7560544 46 *(outbuffer + offset++) = (sig_y>>11) & 0xff;
nucho 0:77afd7560544 47 *(outbuffer + offset++) = ((exp_y<<4) & 0xF0) | ((sig_y>>19)&0x0F);
nucho 0:77afd7560544 48 *(outbuffer + offset++) = (exp_y>>4) & 0x7F;
nucho 0:77afd7560544 49 if(this->y < 0) *(outbuffer + offset -1) |= 0x80;
nucho 3:1cf99502f396 50 int32_t * val_theta = (long *) &(this->theta);
nucho 3:1cf99502f396 51 int32_t exp_theta = (((*val_theta)>>23)&255);
nucho 0:77afd7560544 52 if(exp_theta != 0)
nucho 0:77afd7560544 53 exp_theta += 1023-127;
nucho 3:1cf99502f396 54 int32_t sig_theta = *val_theta;
nucho 0:77afd7560544 55 *(outbuffer + offset++) = 0;
nucho 0:77afd7560544 56 *(outbuffer + offset++) = 0;
nucho 0:77afd7560544 57 *(outbuffer + offset++) = 0;
nucho 0:77afd7560544 58 *(outbuffer + offset++) = (sig_theta<<5) & 0xff;
nucho 0:77afd7560544 59 *(outbuffer + offset++) = (sig_theta>>3) & 0xff;
nucho 0:77afd7560544 60 *(outbuffer + offset++) = (sig_theta>>11) & 0xff;
nucho 0:77afd7560544 61 *(outbuffer + offset++) = ((exp_theta<<4) & 0xF0) | ((sig_theta>>19)&0x0F);
nucho 0:77afd7560544 62 *(outbuffer + offset++) = (exp_theta>>4) & 0x7F;
nucho 0:77afd7560544 63 if(this->theta < 0) *(outbuffer + offset -1) |= 0x80;
nucho 0:77afd7560544 64 return offset;
nucho 0:77afd7560544 65 }
nucho 0:77afd7560544 66
nucho 0:77afd7560544 67 virtual int deserialize(unsigned char *inbuffer)
nucho 0:77afd7560544 68 {
nucho 0:77afd7560544 69 int offset = 0;
nucho 3:1cf99502f396 70 uint32_t * val_x = (uint32_t*) &(this->x);
nucho 0:77afd7560544 71 offset += 3;
nucho 3:1cf99502f396 72 *val_x = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07);
nucho 3:1cf99502f396 73 *val_x |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3;
nucho 3:1cf99502f396 74 *val_x |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11;
nucho 3:1cf99502f396 75 *val_x |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19;
nucho 3:1cf99502f396 76 uint32_t exp_x = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4;
nucho 3:1cf99502f396 77 exp_x |= ((uint32_t)(*(inbuffer + offset)) & 0x7f)<<4;
nucho 0:77afd7560544 78 if(exp_x !=0)
nucho 0:77afd7560544 79 *val_x |= ((exp_x)-1023+127)<<23;
nucho 0:77afd7560544 80 if( ((*(inbuffer+offset++)) & 0x80) > 0) this->x = -this->x;
nucho 3:1cf99502f396 81 uint32_t * val_y = (uint32_t*) &(this->y);
nucho 0:77afd7560544 82 offset += 3;
nucho 3:1cf99502f396 83 *val_y = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07);
nucho 3:1cf99502f396 84 *val_y |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3;
nucho 3:1cf99502f396 85 *val_y |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11;
nucho 3:1cf99502f396 86 *val_y |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19;
nucho 3:1cf99502f396 87 uint32_t exp_y = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4;
nucho 3:1cf99502f396 88 exp_y |= ((uint32_t)(*(inbuffer + offset)) & 0x7f)<<4;
nucho 0:77afd7560544 89 if(exp_y !=0)
nucho 0:77afd7560544 90 *val_y |= ((exp_y)-1023+127)<<23;
nucho 0:77afd7560544 91 if( ((*(inbuffer+offset++)) & 0x80) > 0) this->y = -this->y;
nucho 3:1cf99502f396 92 uint32_t * val_theta = (uint32_t*) &(this->theta);
nucho 0:77afd7560544 93 offset += 3;
nucho 3:1cf99502f396 94 *val_theta = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07);
nucho 3:1cf99502f396 95 *val_theta |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3;
nucho 3:1cf99502f396 96 *val_theta |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11;
nucho 3:1cf99502f396 97 *val_theta |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19;
nucho 3:1cf99502f396 98 uint32_t exp_theta = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4;
nucho 3:1cf99502f396 99 exp_theta |= ((uint32_t)(*(inbuffer + offset)) & 0x7f)<<4;
nucho 0:77afd7560544 100 if(exp_theta !=0)
nucho 0:77afd7560544 101 *val_theta |= ((exp_theta)-1023+127)<<23;
nucho 0:77afd7560544 102 if( ((*(inbuffer+offset++)) & 0x80) > 0) this->theta = -this->theta;
nucho 0:77afd7560544 103 return offset;
nucho 0:77afd7560544 104 }
nucho 0:77afd7560544 105
nucho 3:1cf99502f396 106 virtual const char * getType(){ return "geometry_msgs/Pose2D"; };
nucho 3:1cf99502f396 107 virtual const char * getMD5(){ return "938fa65709584ad8e77d238529be13b8"; };
nucho 0:77afd7560544 108
nucho 0:77afd7560544 109 };
nucho 0:77afd7560544 110
nucho 0:77afd7560544 111 }
nucho 0:77afd7560544 112 #endif