This program is porting rosserial_arduino for mbed http://www.ros.org/wiki/rosserial_arduino This program supported the revision of 169 of rosserial. This program contains an example.
Dependencies: rosserial_mbed_lib mbed Servo
tf/FrameGraph.h@3:dff241b66f84, 2011-11-12 (annotated)
- Committer:
- nucho
- Date:
- Sat Nov 12 23:53:04 2011 +0000
- Revision:
- 3:dff241b66f84
- Parent:
- 0:06fc856e99ca
This program supported the revision of 167 of rosserial.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nucho | 3:dff241b66f84 | 1 | #ifndef _ROS_SERVICE_FrameGraph_h |
nucho | 3:dff241b66f84 | 2 | #define _ROS_SERVICE_FrameGraph_h |
nucho | 0:06fc856e99ca | 3 | #include <stdint.h> |
nucho | 0:06fc856e99ca | 4 | #include <string.h> |
nucho | 0:06fc856e99ca | 5 | #include <stdlib.h> |
nucho | 3:dff241b66f84 | 6 | #include "ros/msg.h" |
nucho | 0:06fc856e99ca | 7 | |
nucho | 0:06fc856e99ca | 8 | namespace tf |
nucho | 0:06fc856e99ca | 9 | { |
nucho | 0:06fc856e99ca | 10 | |
nucho | 0:06fc856e99ca | 11 | static const char FRAMEGRAPH[] = "tf/FrameGraph"; |
nucho | 0:06fc856e99ca | 12 | |
nucho | 0:06fc856e99ca | 13 | class FrameGraphRequest : public ros::Msg |
nucho | 0:06fc856e99ca | 14 | { |
nucho | 0:06fc856e99ca | 15 | public: |
nucho | 0:06fc856e99ca | 16 | |
nucho | 3:dff241b66f84 | 17 | virtual int serialize(unsigned char *outbuffer) const |
nucho | 0:06fc856e99ca | 18 | { |
nucho | 0:06fc856e99ca | 19 | int offset = 0; |
nucho | 0:06fc856e99ca | 20 | return offset; |
nucho | 0:06fc856e99ca | 21 | } |
nucho | 0:06fc856e99ca | 22 | |
nucho | 0:06fc856e99ca | 23 | virtual int deserialize(unsigned char *inbuffer) |
nucho | 0:06fc856e99ca | 24 | { |
nucho | 0:06fc856e99ca | 25 | int offset = 0; |
nucho | 0:06fc856e99ca | 26 | return offset; |
nucho | 0:06fc856e99ca | 27 | } |
nucho | 0:06fc856e99ca | 28 | |
nucho | 3:dff241b66f84 | 29 | virtual const char * getType(){ return FRAMEGRAPH; }; |
nucho | 3:dff241b66f84 | 30 | virtual const char * getMD5(){ return "d41d8cd98f00b204e9800998ecf8427e"; }; |
nucho | 0:06fc856e99ca | 31 | |
nucho | 0:06fc856e99ca | 32 | }; |
nucho | 0:06fc856e99ca | 33 | |
nucho | 0:06fc856e99ca | 34 | class FrameGraphResponse : public ros::Msg |
nucho | 0:06fc856e99ca | 35 | { |
nucho | 0:06fc856e99ca | 36 | public: |
nucho | 0:06fc856e99ca | 37 | char * dot_graph; |
nucho | 0:06fc856e99ca | 38 | |
nucho | 3:dff241b66f84 | 39 | virtual int serialize(unsigned char *outbuffer) const |
nucho | 0:06fc856e99ca | 40 | { |
nucho | 0:06fc856e99ca | 41 | int offset = 0; |
nucho | 3:dff241b66f84 | 42 | uint32_t * length_dot_graph = (uint32_t *)(outbuffer + offset); |
nucho | 0:06fc856e99ca | 43 | *length_dot_graph = strlen( (const char*) this->dot_graph); |
nucho | 0:06fc856e99ca | 44 | offset += 4; |
nucho | 0:06fc856e99ca | 45 | memcpy(outbuffer + offset, this->dot_graph, *length_dot_graph); |
nucho | 0:06fc856e99ca | 46 | offset += *length_dot_graph; |
nucho | 0:06fc856e99ca | 47 | return offset; |
nucho | 0:06fc856e99ca | 48 | } |
nucho | 0:06fc856e99ca | 49 | |
nucho | 0:06fc856e99ca | 50 | virtual int deserialize(unsigned char *inbuffer) |
nucho | 0:06fc856e99ca | 51 | { |
nucho | 0:06fc856e99ca | 52 | int offset = 0; |
nucho | 0:06fc856e99ca | 53 | uint32_t length_dot_graph = *(uint32_t *)(inbuffer + offset); |
nucho | 0:06fc856e99ca | 54 | offset += 4; |
nucho | 0:06fc856e99ca | 55 | for(unsigned int k= offset; k< offset+length_dot_graph; ++k){ |
nucho | 0:06fc856e99ca | 56 | inbuffer[k-1]=inbuffer[k]; |
nucho | 3:dff241b66f84 | 57 | } |
nucho | 0:06fc856e99ca | 58 | inbuffer[offset+length_dot_graph-1]=0; |
nucho | 0:06fc856e99ca | 59 | this->dot_graph = (char *)(inbuffer + offset-1); |
nucho | 0:06fc856e99ca | 60 | offset += length_dot_graph; |
nucho | 0:06fc856e99ca | 61 | return offset; |
nucho | 0:06fc856e99ca | 62 | } |
nucho | 0:06fc856e99ca | 63 | |
nucho | 3:dff241b66f84 | 64 | virtual const char * getType(){ return FRAMEGRAPH; }; |
nucho | 3:dff241b66f84 | 65 | virtual const char * getMD5(){ return "c4af9ac907e58e906eb0b6e3c58478c0"; }; |
nucho | 3:dff241b66f84 | 66 | |
nucho | 3:dff241b66f84 | 67 | }; |
nucho | 0:06fc856e99ca | 68 | |
nucho | 3:dff241b66f84 | 69 | class FrameGraph { |
nucho | 3:dff241b66f84 | 70 | public: |
nucho | 3:dff241b66f84 | 71 | typedef FrameGraphRequest Request; |
nucho | 3:dff241b66f84 | 72 | typedef FrameGraphResponse Response; |
nucho | 0:06fc856e99ca | 73 | }; |
nucho | 0:06fc856e99ca | 74 | |
nucho | 0:06fc856e99ca | 75 | } |
nucho | 0:06fc856e99ca | 76 | #endif |