rosserial library for mbed Inspired by nucho's rosserial library This library is still under development
Dependents: mbed_roshydro_test
Library still under development!
manipulation_msgs/GraspableObjectList.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_manipulation_msgs_GraspableObjectList_h |
akashvibhute | 0:30537dec6e0b | 2 | #define _ROS_manipulation_msgs_GraspableObjectList_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 "manipulation_msgs/GraspableObject.h" |
akashvibhute | 0:30537dec6e0b | 9 | #include "sensor_msgs/Image.h" |
akashvibhute | 0:30537dec6e0b | 10 | #include "sensor_msgs/CameraInfo.h" |
akashvibhute | 0:30537dec6e0b | 11 | #include "shape_msgs/Mesh.h" |
akashvibhute | 0:30537dec6e0b | 12 | #include "geometry_msgs/Pose.h" |
akashvibhute | 0:30537dec6e0b | 13 | |
akashvibhute | 0:30537dec6e0b | 14 | namespace manipulation_msgs |
akashvibhute | 0:30537dec6e0b | 15 | { |
akashvibhute | 0:30537dec6e0b | 16 | |
akashvibhute | 0:30537dec6e0b | 17 | class GraspableObjectList : public ros::Msg |
akashvibhute | 0:30537dec6e0b | 18 | { |
akashvibhute | 0:30537dec6e0b | 19 | public: |
akashvibhute | 0:30537dec6e0b | 20 | uint8_t graspable_objects_length; |
akashvibhute | 0:30537dec6e0b | 21 | manipulation_msgs::GraspableObject st_graspable_objects; |
akashvibhute | 0:30537dec6e0b | 22 | manipulation_msgs::GraspableObject * graspable_objects; |
akashvibhute | 0:30537dec6e0b | 23 | sensor_msgs::Image image; |
akashvibhute | 0:30537dec6e0b | 24 | sensor_msgs::CameraInfo camera_info; |
akashvibhute | 0:30537dec6e0b | 25 | uint8_t meshes_length; |
akashvibhute | 0:30537dec6e0b | 26 | shape_msgs::Mesh st_meshes; |
akashvibhute | 0:30537dec6e0b | 27 | shape_msgs::Mesh * meshes; |
akashvibhute | 0:30537dec6e0b | 28 | geometry_msgs::Pose reference_to_camera; |
akashvibhute | 0:30537dec6e0b | 29 | |
akashvibhute | 0:30537dec6e0b | 30 | GraspableObjectList(): |
akashvibhute | 0:30537dec6e0b | 31 | graspable_objects_length(0), graspable_objects(NULL), |
akashvibhute | 0:30537dec6e0b | 32 | image(), |
akashvibhute | 0:30537dec6e0b | 33 | camera_info(), |
akashvibhute | 0:30537dec6e0b | 34 | meshes_length(0), meshes(NULL), |
akashvibhute | 0:30537dec6e0b | 35 | reference_to_camera() |
akashvibhute | 0:30537dec6e0b | 36 | { |
akashvibhute | 0:30537dec6e0b | 37 | } |
akashvibhute | 0:30537dec6e0b | 38 | |
akashvibhute | 0:30537dec6e0b | 39 | virtual int serialize(unsigned char *outbuffer) const |
akashvibhute | 0:30537dec6e0b | 40 | { |
akashvibhute | 0:30537dec6e0b | 41 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 42 | *(outbuffer + offset++) = graspable_objects_length; |
akashvibhute | 0:30537dec6e0b | 43 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 44 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 45 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 46 | for( uint8_t i = 0; i < graspable_objects_length; i++){ |
akashvibhute | 0:30537dec6e0b | 47 | offset += this->graspable_objects[i].serialize(outbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 48 | } |
akashvibhute | 0:30537dec6e0b | 49 | offset += this->image.serialize(outbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 50 | offset += this->camera_info.serialize(outbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 51 | *(outbuffer + offset++) = meshes_length; |
akashvibhute | 0:30537dec6e0b | 52 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 53 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 54 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 55 | for( uint8_t i = 0; i < meshes_length; i++){ |
akashvibhute | 0:30537dec6e0b | 56 | offset += this->meshes[i].serialize(outbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 57 | } |
akashvibhute | 0:30537dec6e0b | 58 | offset += this->reference_to_camera.serialize(outbuffer + offset); |
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 | uint8_t graspable_objects_lengthT = *(inbuffer + offset++); |
akashvibhute | 0:30537dec6e0b | 66 | if(graspable_objects_lengthT > graspable_objects_length) |
akashvibhute | 0:30537dec6e0b | 67 | this->graspable_objects = (manipulation_msgs::GraspableObject*)realloc(this->graspable_objects, graspable_objects_lengthT * sizeof(manipulation_msgs::GraspableObject)); |
akashvibhute | 0:30537dec6e0b | 68 | offset += 3; |
akashvibhute | 0:30537dec6e0b | 69 | graspable_objects_length = graspable_objects_lengthT; |
akashvibhute | 0:30537dec6e0b | 70 | for( uint8_t i = 0; i < graspable_objects_length; i++){ |
akashvibhute | 0:30537dec6e0b | 71 | offset += this->st_graspable_objects.deserialize(inbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 72 | memcpy( &(this->graspable_objects[i]), &(this->st_graspable_objects), sizeof(manipulation_msgs::GraspableObject)); |
akashvibhute | 0:30537dec6e0b | 73 | } |
akashvibhute | 0:30537dec6e0b | 74 | offset += this->image.deserialize(inbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 75 | offset += this->camera_info.deserialize(inbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 76 | uint8_t meshes_lengthT = *(inbuffer + offset++); |
akashvibhute | 0:30537dec6e0b | 77 | if(meshes_lengthT > meshes_length) |
akashvibhute | 0:30537dec6e0b | 78 | this->meshes = (shape_msgs::Mesh*)realloc(this->meshes, meshes_lengthT * sizeof(shape_msgs::Mesh)); |
akashvibhute | 0:30537dec6e0b | 79 | offset += 3; |
akashvibhute | 0:30537dec6e0b | 80 | meshes_length = meshes_lengthT; |
akashvibhute | 0:30537dec6e0b | 81 | for( uint8_t i = 0; i < meshes_length; i++){ |
akashvibhute | 0:30537dec6e0b | 82 | offset += this->st_meshes.deserialize(inbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 83 | memcpy( &(this->meshes[i]), &(this->st_meshes), sizeof(shape_msgs::Mesh)); |
akashvibhute | 0:30537dec6e0b | 84 | } |
akashvibhute | 0:30537dec6e0b | 85 | offset += this->reference_to_camera.deserialize(inbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 86 | return offset; |
akashvibhute | 0:30537dec6e0b | 87 | } |
akashvibhute | 0:30537dec6e0b | 88 | |
akashvibhute | 0:30537dec6e0b | 89 | const char * getType(){ return "manipulation_msgs/GraspableObjectList"; }; |
akashvibhute | 0:30537dec6e0b | 90 | const char * getMD5(){ return "d67571f2982f1b7115de1e0027319109"; }; |
akashvibhute | 0:30537dec6e0b | 91 | |
akashvibhute | 0:30537dec6e0b | 92 | }; |
akashvibhute | 0:30537dec6e0b | 93 | |
akashvibhute | 0:30537dec6e0b | 94 | } |
akashvibhute | 0:30537dec6e0b | 95 | #endif |