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/CartesianGains.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_CartesianGains_h |
akashvibhute | 0:30537dec6e0b | 2 | #define _ROS_manipulation_msgs_CartesianGains_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 manipulation_msgs |
akashvibhute | 0:30537dec6e0b | 11 | { |
akashvibhute | 0:30537dec6e0b | 12 | |
akashvibhute | 0:30537dec6e0b | 13 | class CartesianGains : 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 gains_length; |
akashvibhute | 0:30537dec6e0b | 18 | float st_gains; |
akashvibhute | 0:30537dec6e0b | 19 | float * gains; |
akashvibhute | 0:30537dec6e0b | 20 | uint8_t fixed_frame_length; |
akashvibhute | 0:30537dec6e0b | 21 | float st_fixed_frame; |
akashvibhute | 0:30537dec6e0b | 22 | float * fixed_frame; |
akashvibhute | 0:30537dec6e0b | 23 | |
akashvibhute | 0:30537dec6e0b | 24 | CartesianGains(): |
akashvibhute | 0:30537dec6e0b | 25 | header(), |
akashvibhute | 0:30537dec6e0b | 26 | gains_length(0), gains(NULL), |
akashvibhute | 0:30537dec6e0b | 27 | fixed_frame_length(0), fixed_frame(NULL) |
akashvibhute | 0:30537dec6e0b | 28 | { |
akashvibhute | 0:30537dec6e0b | 29 | } |
akashvibhute | 0:30537dec6e0b | 30 | |
akashvibhute | 0:30537dec6e0b | 31 | virtual int serialize(unsigned char *outbuffer) const |
akashvibhute | 0:30537dec6e0b | 32 | { |
akashvibhute | 0:30537dec6e0b | 33 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 34 | offset += this->header.serialize(outbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 35 | *(outbuffer + offset++) = gains_length; |
akashvibhute | 0:30537dec6e0b | 36 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 37 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 38 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 39 | for( uint8_t i = 0; i < gains_length; i++){ |
akashvibhute | 0:30537dec6e0b | 40 | offset += serializeAvrFloat64(outbuffer + offset, this->gains[i]); |
akashvibhute | 0:30537dec6e0b | 41 | } |
akashvibhute | 0:30537dec6e0b | 42 | *(outbuffer + offset++) = fixed_frame_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 < fixed_frame_length; i++){ |
akashvibhute | 0:30537dec6e0b | 47 | offset += serializeAvrFloat64(outbuffer + offset, this->fixed_frame[i]); |
akashvibhute | 0:30537dec6e0b | 48 | } |
akashvibhute | 0:30537dec6e0b | 49 | return offset; |
akashvibhute | 0:30537dec6e0b | 50 | } |
akashvibhute | 0:30537dec6e0b | 51 | |
akashvibhute | 0:30537dec6e0b | 52 | virtual int deserialize(unsigned char *inbuffer) |
akashvibhute | 0:30537dec6e0b | 53 | { |
akashvibhute | 0:30537dec6e0b | 54 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 55 | offset += this->header.deserialize(inbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 56 | uint8_t gains_lengthT = *(inbuffer + offset++); |
akashvibhute | 0:30537dec6e0b | 57 | if(gains_lengthT > gains_length) |
akashvibhute | 0:30537dec6e0b | 58 | this->gains = (float*)realloc(this->gains, gains_lengthT * sizeof(float)); |
akashvibhute | 0:30537dec6e0b | 59 | offset += 3; |
akashvibhute | 0:30537dec6e0b | 60 | gains_length = gains_lengthT; |
akashvibhute | 0:30537dec6e0b | 61 | for( uint8_t i = 0; i < gains_length; i++){ |
akashvibhute | 0:30537dec6e0b | 62 | offset += deserializeAvrFloat64(inbuffer + offset, &(this->st_gains)); |
akashvibhute | 0:30537dec6e0b | 63 | memcpy( &(this->gains[i]), &(this->st_gains), sizeof(float)); |
akashvibhute | 0:30537dec6e0b | 64 | } |
akashvibhute | 0:30537dec6e0b | 65 | uint8_t fixed_frame_lengthT = *(inbuffer + offset++); |
akashvibhute | 0:30537dec6e0b | 66 | if(fixed_frame_lengthT > fixed_frame_length) |
akashvibhute | 0:30537dec6e0b | 67 | this->fixed_frame = (float*)realloc(this->fixed_frame, fixed_frame_lengthT * sizeof(float)); |
akashvibhute | 0:30537dec6e0b | 68 | offset += 3; |
akashvibhute | 0:30537dec6e0b | 69 | fixed_frame_length = fixed_frame_lengthT; |
akashvibhute | 0:30537dec6e0b | 70 | for( uint8_t i = 0; i < fixed_frame_length; i++){ |
akashvibhute | 0:30537dec6e0b | 71 | offset += deserializeAvrFloat64(inbuffer + offset, &(this->st_fixed_frame)); |
akashvibhute | 0:30537dec6e0b | 72 | memcpy( &(this->fixed_frame[i]), &(this->st_fixed_frame), sizeof(float)); |
akashvibhute | 0:30537dec6e0b | 73 | } |
akashvibhute | 0:30537dec6e0b | 74 | return offset; |
akashvibhute | 0:30537dec6e0b | 75 | } |
akashvibhute | 0:30537dec6e0b | 76 | |
akashvibhute | 0:30537dec6e0b | 77 | const char * getType(){ return "manipulation_msgs/CartesianGains"; }; |
akashvibhute | 0:30537dec6e0b | 78 | const char * getMD5(){ return "ab347f046ca5736a156ec424cbb63635"; }; |
akashvibhute | 0:30537dec6e0b | 79 | |
akashvibhute | 0:30537dec6e0b | 80 | }; |
akashvibhute | 0:30537dec6e0b | 81 | |
akashvibhute | 0:30537dec6e0b | 82 | } |
akashvibhute | 0:30537dec6e0b | 83 | #endif |