rosserial for Hydro
Fork of rosserial_mbed_lib by
std_msgs/Float32.h@1:ff0ec969dad1, 2011-10-16 (annotated)
- Committer:
- nucho
- Date:
- Sun Oct 16 07:19:36 2011 +0000
- Revision:
- 1:ff0ec969dad1
- Parent:
- 0:77afd7560544
- Child:
- 3:1cf99502f396
This program supported the revision of 143 of rosserial.
And the bug fix of receive of array data.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nucho | 0:77afd7560544 | 1 | #ifndef ros_Float32_h |
nucho | 0:77afd7560544 | 2 | #define ros_Float32_h |
nucho | 0:77afd7560544 | 3 | |
nucho | 0:77afd7560544 | 4 | #include <stdint.h> |
nucho | 0:77afd7560544 | 5 | #include <string.h> |
nucho | 0:77afd7560544 | 6 | #include <stdlib.h> |
nucho | 0:77afd7560544 | 7 | #include "../ros/msg.h" |
nucho | 0:77afd7560544 | 8 | |
nucho | 0:77afd7560544 | 9 | namespace std_msgs |
nucho | 0:77afd7560544 | 10 | { |
nucho | 0:77afd7560544 | 11 | |
nucho | 0:77afd7560544 | 12 | class Float32 : public ros::Msg |
nucho | 0:77afd7560544 | 13 | { |
nucho | 0:77afd7560544 | 14 | public: |
nucho | 0:77afd7560544 | 15 | float data; |
nucho | 0:77afd7560544 | 16 | |
nucho | 0:77afd7560544 | 17 | virtual int serialize(unsigned char *outbuffer) |
nucho | 0:77afd7560544 | 18 | { |
nucho | 0:77afd7560544 | 19 | int offset = 0; |
nucho | 0:77afd7560544 | 20 | union { |
nucho | 0:77afd7560544 | 21 | float real; |
nucho | 1:ff0ec969dad1 | 22 | uint32_t base; |
nucho | 0:77afd7560544 | 23 | } u_data; |
nucho | 0:77afd7560544 | 24 | u_data.real = this->data; |
nucho | 0:77afd7560544 | 25 | *(outbuffer + offset + 0) = (u_data.base >> (8 * 0)) & 0xFF; |
nucho | 0:77afd7560544 | 26 | *(outbuffer + offset + 1) = (u_data.base >> (8 * 1)) & 0xFF; |
nucho | 0:77afd7560544 | 27 | *(outbuffer + offset + 2) = (u_data.base >> (8 * 2)) & 0xFF; |
nucho | 0:77afd7560544 | 28 | *(outbuffer + offset + 3) = (u_data.base >> (8 * 3)) & 0xFF; |
nucho | 0:77afd7560544 | 29 | offset += sizeof(this->data); |
nucho | 0:77afd7560544 | 30 | return offset; |
nucho | 0:77afd7560544 | 31 | } |
nucho | 0:77afd7560544 | 32 | |
nucho | 0:77afd7560544 | 33 | virtual int deserialize(unsigned char *inbuffer) |
nucho | 0:77afd7560544 | 34 | { |
nucho | 0:77afd7560544 | 35 | int offset = 0; |
nucho | 0:77afd7560544 | 36 | union { |
nucho | 0:77afd7560544 | 37 | float real; |
nucho | 1:ff0ec969dad1 | 38 | uint32_t base; |
nucho | 0:77afd7560544 | 39 | } u_data; |
nucho | 0:77afd7560544 | 40 | u_data.base = 0; |
nucho | 0:77afd7560544 | 41 | u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 0))) << (8 * 0); |
nucho | 0:77afd7560544 | 42 | u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 1))) << (8 * 1); |
nucho | 0:77afd7560544 | 43 | u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 2))) << (8 * 2); |
nucho | 0:77afd7560544 | 44 | u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 3))) << (8 * 3); |
nucho | 0:77afd7560544 | 45 | this->data = u_data.real; |
nucho | 0:77afd7560544 | 46 | offset += sizeof(this->data); |
nucho | 0:77afd7560544 | 47 | return offset; |
nucho | 0:77afd7560544 | 48 | } |
nucho | 0:77afd7560544 | 49 | |
nucho | 0:77afd7560544 | 50 | virtual const char * getType(){ return "std_msgs/Float32"; }; |
nucho | 0:77afd7560544 | 51 | |
nucho | 0:77afd7560544 | 52 | }; |
nucho | 0:77afd7560544 | 53 | |
nucho | 0:77afd7560544 | 54 | } |
nucho | 0:77afd7560544 | 55 | #endif |