rosserial library for mbed Inspired by nucho's rosserial library This library is still under development
Dependents: mbed_roshydro_test
Library still under development!
object_recognition_msgs/RecognizedObjectArray.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_object_recognition_msgs_RecognizedObjectArray_h |
akashvibhute | 0:30537dec6e0b | 2 | #define _ROS_object_recognition_msgs_RecognizedObjectArray_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 | #include "object_recognition_msgs/RecognizedObject.h" |
akashvibhute | 0:30537dec6e0b | 10 | |
akashvibhute | 0:30537dec6e0b | 11 | namespace object_recognition_msgs |
akashvibhute | 0:30537dec6e0b | 12 | { |
akashvibhute | 0:30537dec6e0b | 13 | |
akashvibhute | 0:30537dec6e0b | 14 | class RecognizedObjectArray : public ros::Msg |
akashvibhute | 0:30537dec6e0b | 15 | { |
akashvibhute | 0:30537dec6e0b | 16 | public: |
akashvibhute | 0:30537dec6e0b | 17 | std_msgs::Header header; |
akashvibhute | 0:30537dec6e0b | 18 | uint8_t objects_length; |
akashvibhute | 0:30537dec6e0b | 19 | object_recognition_msgs::RecognizedObject st_objects; |
akashvibhute | 0:30537dec6e0b | 20 | object_recognition_msgs::RecognizedObject * objects; |
akashvibhute | 0:30537dec6e0b | 21 | uint8_t cooccurrence_length; |
akashvibhute | 0:30537dec6e0b | 22 | float st_cooccurrence; |
akashvibhute | 0:30537dec6e0b | 23 | float * cooccurrence; |
akashvibhute | 0:30537dec6e0b | 24 | |
akashvibhute | 0:30537dec6e0b | 25 | RecognizedObjectArray(): |
akashvibhute | 0:30537dec6e0b | 26 | header(), |
akashvibhute | 0:30537dec6e0b | 27 | objects_length(0), objects(NULL), |
akashvibhute | 0:30537dec6e0b | 28 | cooccurrence_length(0), cooccurrence(NULL) |
akashvibhute | 0:30537dec6e0b | 29 | { |
akashvibhute | 0:30537dec6e0b | 30 | } |
akashvibhute | 0:30537dec6e0b | 31 | |
akashvibhute | 0:30537dec6e0b | 32 | virtual int serialize(unsigned char *outbuffer) const |
akashvibhute | 0:30537dec6e0b | 33 | { |
akashvibhute | 0:30537dec6e0b | 34 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 35 | offset += this->header.serialize(outbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 36 | *(outbuffer + offset++) = objects_length; |
akashvibhute | 0:30537dec6e0b | 37 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 38 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 39 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 40 | for( uint8_t i = 0; i < objects_length; i++){ |
akashvibhute | 0:30537dec6e0b | 41 | offset += this->objects[i].serialize(outbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 42 | } |
akashvibhute | 0:30537dec6e0b | 43 | *(outbuffer + offset++) = cooccurrence_length; |
akashvibhute | 0:30537dec6e0b | 44 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 45 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 46 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 47 | for( uint8_t i = 0; i < cooccurrence_length; i++){ |
akashvibhute | 0:30537dec6e0b | 48 | union { |
akashvibhute | 0:30537dec6e0b | 49 | float real; |
akashvibhute | 0:30537dec6e0b | 50 | uint32_t base; |
akashvibhute | 0:30537dec6e0b | 51 | } u_cooccurrencei; |
akashvibhute | 0:30537dec6e0b | 52 | u_cooccurrencei.real = this->cooccurrence[i]; |
akashvibhute | 0:30537dec6e0b | 53 | *(outbuffer + offset + 0) = (u_cooccurrencei.base >> (8 * 0)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 54 | *(outbuffer + offset + 1) = (u_cooccurrencei.base >> (8 * 1)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 55 | *(outbuffer + offset + 2) = (u_cooccurrencei.base >> (8 * 2)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 56 | *(outbuffer + offset + 3) = (u_cooccurrencei.base >> (8 * 3)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 57 | offset += sizeof(this->cooccurrence[i]); |
akashvibhute | 0:30537dec6e0b | 58 | } |
akashvibhute | 0:30537dec6e0b | 59 | return offset; |
akashvibhute | 0:30537dec6e0b | 60 | } |
akashvibhute | 0:30537dec6e0b | 61 | |
akashvibhute | 0:30537dec6e0b | 62 | virtual int deserialize(unsigned char *inbuffer) |
akashvibhute | 0:30537dec6e0b | 63 | { |
akashvibhute | 0:30537dec6e0b | 64 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 65 | offset += this->header.deserialize(inbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 66 | uint8_t objects_lengthT = *(inbuffer + offset++); |
akashvibhute | 0:30537dec6e0b | 67 | if(objects_lengthT > objects_length) |
akashvibhute | 0:30537dec6e0b | 68 | this->objects = (object_recognition_msgs::RecognizedObject*)realloc(this->objects, objects_lengthT * sizeof(object_recognition_msgs::RecognizedObject)); |
akashvibhute | 0:30537dec6e0b | 69 | offset += 3; |
akashvibhute | 0:30537dec6e0b | 70 | objects_length = objects_lengthT; |
akashvibhute | 0:30537dec6e0b | 71 | for( uint8_t i = 0; i < objects_length; i++){ |
akashvibhute | 0:30537dec6e0b | 72 | offset += this->st_objects.deserialize(inbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 73 | memcpy( &(this->objects[i]), &(this->st_objects), sizeof(object_recognition_msgs::RecognizedObject)); |
akashvibhute | 0:30537dec6e0b | 74 | } |
akashvibhute | 0:30537dec6e0b | 75 | uint8_t cooccurrence_lengthT = *(inbuffer + offset++); |
akashvibhute | 0:30537dec6e0b | 76 | if(cooccurrence_lengthT > cooccurrence_length) |
akashvibhute | 0:30537dec6e0b | 77 | this->cooccurrence = (float*)realloc(this->cooccurrence, cooccurrence_lengthT * sizeof(float)); |
akashvibhute | 0:30537dec6e0b | 78 | offset += 3; |
akashvibhute | 0:30537dec6e0b | 79 | cooccurrence_length = cooccurrence_lengthT; |
akashvibhute | 0:30537dec6e0b | 80 | for( uint8_t i = 0; i < cooccurrence_length; i++){ |
akashvibhute | 0:30537dec6e0b | 81 | union { |
akashvibhute | 0:30537dec6e0b | 82 | float real; |
akashvibhute | 0:30537dec6e0b | 83 | uint32_t base; |
akashvibhute | 0:30537dec6e0b | 84 | } u_st_cooccurrence; |
akashvibhute | 0:30537dec6e0b | 85 | u_st_cooccurrence.base = 0; |
akashvibhute | 0:30537dec6e0b | 86 | u_st_cooccurrence.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
akashvibhute | 0:30537dec6e0b | 87 | u_st_cooccurrence.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
akashvibhute | 0:30537dec6e0b | 88 | u_st_cooccurrence.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
akashvibhute | 0:30537dec6e0b | 89 | u_st_cooccurrence.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
akashvibhute | 0:30537dec6e0b | 90 | this->st_cooccurrence = u_st_cooccurrence.real; |
akashvibhute | 0:30537dec6e0b | 91 | offset += sizeof(this->st_cooccurrence); |
akashvibhute | 0:30537dec6e0b | 92 | memcpy( &(this->cooccurrence[i]), &(this->st_cooccurrence), sizeof(float)); |
akashvibhute | 0:30537dec6e0b | 93 | } |
akashvibhute | 0:30537dec6e0b | 94 | return offset; |
akashvibhute | 0:30537dec6e0b | 95 | } |
akashvibhute | 0:30537dec6e0b | 96 | |
akashvibhute | 0:30537dec6e0b | 97 | const char * getType(){ return "object_recognition_msgs/RecognizedObjectArray"; }; |
akashvibhute | 0:30537dec6e0b | 98 | const char * getMD5(){ return "bad6b1546b9ebcabb49fb3b858d78964"; }; |
akashvibhute | 0:30537dec6e0b | 99 | |
akashvibhute | 0:30537dec6e0b | 100 | }; |
akashvibhute | 0:30537dec6e0b | 101 | |
akashvibhute | 0:30537dec6e0b | 102 | } |
akashvibhute | 0:30537dec6e0b | 103 | #endif |