rosserial library for mbed Inspired by nucho's rosserial library This library is still under development

Dependencies:   MODSERIAL mbed

Dependents:   mbed_roshydro_test

Library still under development!

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?

UserRevisionLine numberNew contents of line
akashvibhute 0:30537dec6e0b 1 #ifndef _ROS_pcl_msgs_ModelCoefficients_h
akashvibhute 0:30537dec6e0b 2 #define _ROS_pcl_msgs_ModelCoefficients_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 "std_msgs/Header.h"
akashvibhute 0:30537dec6e0b 9
akashvibhute 0:30537dec6e0b 10 namespace pcl_msgs
akashvibhute 0:30537dec6e0b 11 {
akashvibhute 0:30537dec6e0b 12
akashvibhute 0:30537dec6e0b 13 class ModelCoefficients : public ros::Msg
akashvibhute 0:30537dec6e0b 14 {
akashvibhute 0:30537dec6e0b 15 public:
akashvibhute 0:30537dec6e0b 16 std_msgs::Header header;
akashvibhute 0:30537dec6e0b 17 uint8_t values_length;
akashvibhute 0:30537dec6e0b 18 float st_values;
akashvibhute 0:30537dec6e0b 19 float * values;
akashvibhute 0:30537dec6e0b 20
akashvibhute 0:30537dec6e0b 21 ModelCoefficients():
akashvibhute 0:30537dec6e0b 22 header(),
akashvibhute 0:30537dec6e0b 23 values_length(0), values(NULL)
akashvibhute 0:30537dec6e0b 24 {
akashvibhute 0:30537dec6e0b 25 }
akashvibhute 0:30537dec6e0b 26
akashvibhute 0:30537dec6e0b 27 virtual int serialize(unsigned char *outbuffer) const
akashvibhute 0:30537dec6e0b 28 {
akashvibhute 0:30537dec6e0b 29 int offset = 0;
akashvibhute 0:30537dec6e0b 30 offset += this->header.serialize(outbuffer + offset);
akashvibhute 0:30537dec6e0b 31 *(outbuffer + offset++) = values_length;
akashvibhute 0:30537dec6e0b 32 *(outbuffer + offset++) = 0;
akashvibhute 0:30537dec6e0b 33 *(outbuffer + offset++) = 0;
akashvibhute 0:30537dec6e0b 34 *(outbuffer + offset++) = 0;
akashvibhute 0:30537dec6e0b 35 for( uint8_t i = 0; i < values_length; i++){
akashvibhute 0:30537dec6e0b 36 union {
akashvibhute 0:30537dec6e0b 37 float real;
akashvibhute 0:30537dec6e0b 38 uint32_t base;
akashvibhute 0:30537dec6e0b 39 } u_valuesi;
akashvibhute 0:30537dec6e0b 40 u_valuesi.real = this->values[i];
akashvibhute 0:30537dec6e0b 41 *(outbuffer + offset + 0) = (u_valuesi.base >> (8 * 0)) & 0xFF;
akashvibhute 0:30537dec6e0b 42 *(outbuffer + offset + 1) = (u_valuesi.base >> (8 * 1)) & 0xFF;
akashvibhute 0:30537dec6e0b 43 *(outbuffer + offset + 2) = (u_valuesi.base >> (8 * 2)) & 0xFF;
akashvibhute 0:30537dec6e0b 44 *(outbuffer + offset + 3) = (u_valuesi.base >> (8 * 3)) & 0xFF;
akashvibhute 0:30537dec6e0b 45 offset += sizeof(this->values[i]);
akashvibhute 0:30537dec6e0b 46 }
akashvibhute 0:30537dec6e0b 47 return offset;
akashvibhute 0:30537dec6e0b 48 }
akashvibhute 0:30537dec6e0b 49
akashvibhute 0:30537dec6e0b 50 virtual int deserialize(unsigned char *inbuffer)
akashvibhute 0:30537dec6e0b 51 {
akashvibhute 0:30537dec6e0b 52 int offset = 0;
akashvibhute 0:30537dec6e0b 53 offset += this->header.deserialize(inbuffer + offset);
akashvibhute 0:30537dec6e0b 54 uint8_t values_lengthT = *(inbuffer + offset++);
akashvibhute 0:30537dec6e0b 55 if(values_lengthT > values_length)
akashvibhute 0:30537dec6e0b 56 this->values = (float*)realloc(this->values, values_lengthT * sizeof(float));
akashvibhute 0:30537dec6e0b 57 offset += 3;
akashvibhute 0:30537dec6e0b 58 values_length = values_lengthT;
akashvibhute 0:30537dec6e0b 59 for( uint8_t i = 0; i < values_length; i++){
akashvibhute 0:30537dec6e0b 60 union {
akashvibhute 0:30537dec6e0b 61 float real;
akashvibhute 0:30537dec6e0b 62 uint32_t base;
akashvibhute 0:30537dec6e0b 63 } u_st_values;
akashvibhute 0:30537dec6e0b 64 u_st_values.base = 0;
akashvibhute 0:30537dec6e0b 65 u_st_values.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
akashvibhute 0:30537dec6e0b 66 u_st_values.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
akashvibhute 0:30537dec6e0b 67 u_st_values.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
akashvibhute 0:30537dec6e0b 68 u_st_values.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
akashvibhute 0:30537dec6e0b 69 this->st_values = u_st_values.real;
akashvibhute 0:30537dec6e0b 70 offset += sizeof(this->st_values);
akashvibhute 0:30537dec6e0b 71 memcpy( &(this->values[i]), &(this->st_values), sizeof(float));
akashvibhute 0:30537dec6e0b 72 }
akashvibhute 0:30537dec6e0b 73 return offset;
akashvibhute 0:30537dec6e0b 74 }
akashvibhute 0:30537dec6e0b 75
akashvibhute 0:30537dec6e0b 76 const char * getType(){ return "pcl_msgs/ModelCoefficients"; };
akashvibhute 0:30537dec6e0b 77 const char * getMD5(){ return "ca27dea75e72cb894cd36f9e5005e93e"; };
akashvibhute 0:30537dec6e0b 78
akashvibhute 0:30537dec6e0b 79 };
akashvibhute 0:30537dec6e0b 80
akashvibhute 0:30537dec6e0b 81 }
akashvibhute 0:30537dec6e0b 82 #endif