rosserial library for mbed Inspired by nucho's rosserial library This library is still under development
Dependents: mbed_roshydro_test
Library still under development!
geometry_msgs/PoseWithCovariance.h@0:30537dec6e0b, 2015-02-15 (annotated)
- Committer:
- akashvibhute
- Date:
- Sun Feb 15 10:53:43 2015 +0000
- Revision:
- 0:30537dec6e0b
First commit; Library still need to be debugged, compilation issues with new mbed and modserial updates.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
akashvibhute | 0:30537dec6e0b | 1 | #ifndef _ROS_geometry_msgs_PoseWithCovariance_h |
akashvibhute | 0:30537dec6e0b | 2 | #define _ROS_geometry_msgs_PoseWithCovariance_h |
akashvibhute | 0:30537dec6e0b | 3 | |
akashvibhute | 0:30537dec6e0b | 4 | #include <stdint.h> |
akashvibhute | 0:30537dec6e0b | 5 | #include <string.h> |
akashvibhute | 0:30537dec6e0b | 6 | #include <stdlib.h> |
akashvibhute | 0:30537dec6e0b | 7 | #include "ros/msg.h" |
akashvibhute | 0:30537dec6e0b | 8 | #include "geometry_msgs/Pose.h" |
akashvibhute | 0:30537dec6e0b | 9 | |
akashvibhute | 0:30537dec6e0b | 10 | namespace geometry_msgs |
akashvibhute | 0:30537dec6e0b | 11 | { |
akashvibhute | 0:30537dec6e0b | 12 | |
akashvibhute | 0:30537dec6e0b | 13 | class PoseWithCovariance : public ros::Msg |
akashvibhute | 0:30537dec6e0b | 14 | { |
akashvibhute | 0:30537dec6e0b | 15 | public: |
akashvibhute | 0:30537dec6e0b | 16 | geometry_msgs::Pose pose; |
akashvibhute | 0:30537dec6e0b | 17 | float covariance[36]; |
akashvibhute | 0:30537dec6e0b | 18 | |
akashvibhute | 0:30537dec6e0b | 19 | virtual int serialize(unsigned char *outbuffer) const |
akashvibhute | 0:30537dec6e0b | 20 | { |
akashvibhute | 0:30537dec6e0b | 21 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 22 | offset += this->pose.serialize(outbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 23 | unsigned char * covariance_val = (unsigned char *) this->covariance; |
akashvibhute | 0:30537dec6e0b | 24 | for( uint8_t i = 0; i < 36; i++){ |
akashvibhute | 0:30537dec6e0b | 25 | int32_t * val_covariancei = (long *) &(this->covariance[i]); |
akashvibhute | 0:30537dec6e0b | 26 | int32_t exp_covariancei = (((*val_covariancei)>>23)&255); |
akashvibhute | 0:30537dec6e0b | 27 | if(exp_covariancei != 0) |
akashvibhute | 0:30537dec6e0b | 28 | exp_covariancei += 1023-127; |
akashvibhute | 0:30537dec6e0b | 29 | int32_t sig_covariancei = *val_covariancei; |
akashvibhute | 0:30537dec6e0b | 30 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 31 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 32 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 33 | *(outbuffer + offset++) = (sig_covariancei<<5) & 0xff; |
akashvibhute | 0:30537dec6e0b | 34 | *(outbuffer + offset++) = (sig_covariancei>>3) & 0xff; |
akashvibhute | 0:30537dec6e0b | 35 | *(outbuffer + offset++) = (sig_covariancei>>11) & 0xff; |
akashvibhute | 0:30537dec6e0b | 36 | *(outbuffer + offset++) = ((exp_covariancei<<4) & 0xF0) | ((sig_covariancei>>19)&0x0F); |
akashvibhute | 0:30537dec6e0b | 37 | *(outbuffer + offset++) = (exp_covariancei>>4) & 0x7F; |
akashvibhute | 0:30537dec6e0b | 38 | if(this->covariance[i] < 0) *(outbuffer + offset -1) |= 0x80; |
akashvibhute | 0:30537dec6e0b | 39 | } |
akashvibhute | 0:30537dec6e0b | 40 | return offset; |
akashvibhute | 0:30537dec6e0b | 41 | } |
akashvibhute | 0:30537dec6e0b | 42 | |
akashvibhute | 0:30537dec6e0b | 43 | virtual int deserialize(unsigned char *inbuffer) |
akashvibhute | 0:30537dec6e0b | 44 | { |
akashvibhute | 0:30537dec6e0b | 45 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 46 | offset += this->pose.deserialize(inbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 47 | uint8_t * covariance_val = (uint8_t*) this->covariance; |
akashvibhute | 0:30537dec6e0b | 48 | for( uint8_t i = 0; i < 36; i++){ |
akashvibhute | 0:30537dec6e0b | 49 | uint32_t * val_covariancei = (uint32_t*) &(this->covariance[i]); |
akashvibhute | 0:30537dec6e0b | 50 | offset += 3; |
akashvibhute | 0:30537dec6e0b | 51 | *val_covariancei = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07); |
akashvibhute | 0:30537dec6e0b | 52 | *val_covariancei |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3; |
akashvibhute | 0:30537dec6e0b | 53 | *val_covariancei |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11; |
akashvibhute | 0:30537dec6e0b | 54 | *val_covariancei |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19; |
akashvibhute | 0:30537dec6e0b | 55 | uint32_t exp_covariancei = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4; |
akashvibhute | 0:30537dec6e0b | 56 | exp_covariancei |= ((uint32_t)(*(inbuffer + offset)) & 0x7f)<<4; |
akashvibhute | 0:30537dec6e0b | 57 | if(exp_covariancei !=0) |
akashvibhute | 0:30537dec6e0b | 58 | *val_covariancei |= ((exp_covariancei)-1023+127)<<23; |
akashvibhute | 0:30537dec6e0b | 59 | if( ((*(inbuffer+offset++)) & 0x80) > 0) this->covariance[i] = -this->covariance[i]; |
akashvibhute | 0:30537dec6e0b | 60 | } |
akashvibhute | 0:30537dec6e0b | 61 | return offset; |
akashvibhute | 0:30537dec6e0b | 62 | } |
akashvibhute | 0:30537dec6e0b | 63 | |
akashvibhute | 0:30537dec6e0b | 64 | virtual const char * getType(){ return "geometry_msgs/PoseWithCovariance"; }; |
akashvibhute | 0:30537dec6e0b | 65 | virtual const char * getMD5(){ return "c23e848cf1b7533a8d7c259073a97e6f"; }; |
akashvibhute | 0:30537dec6e0b | 66 | |
akashvibhute | 0:30537dec6e0b | 67 | }; |
akashvibhute | 0:30537dec6e0b | 68 | |
akashvibhute | 0:30537dec6e0b | 69 | } |
akashvibhute | 0:30537dec6e0b | 70 | #endif |