rosserial library for mbed Inspired by nucho's rosserial library This library is still under development
Dependents: mbed_roshydro_test
Library still under development!
industrial_msgs/GetRobotInfo.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_SERVICE_GetRobotInfo_h |
akashvibhute | 0:30537dec6e0b | 2 | #define _ROS_SERVICE_GetRobotInfo_h |
akashvibhute | 0:30537dec6e0b | 3 | #include <stdint.h> |
akashvibhute | 0:30537dec6e0b | 4 | #include <string.h> |
akashvibhute | 0:30537dec6e0b | 5 | #include <stdlib.h> |
akashvibhute | 0:30537dec6e0b | 6 | #include "ros/msg.h" |
akashvibhute | 0:30537dec6e0b | 7 | #include "industrial_msgs/ServiceReturnCode.h" |
akashvibhute | 0:30537dec6e0b | 8 | #include "industrial_msgs/DeviceInfo.h" |
akashvibhute | 0:30537dec6e0b | 9 | |
akashvibhute | 0:30537dec6e0b | 10 | namespace industrial_msgs |
akashvibhute | 0:30537dec6e0b | 11 | { |
akashvibhute | 0:30537dec6e0b | 12 | |
akashvibhute | 0:30537dec6e0b | 13 | static const char GETROBOTINFO[] = "industrial_msgs/GetRobotInfo"; |
akashvibhute | 0:30537dec6e0b | 14 | |
akashvibhute | 0:30537dec6e0b | 15 | class GetRobotInfoRequest : public ros::Msg |
akashvibhute | 0:30537dec6e0b | 16 | { |
akashvibhute | 0:30537dec6e0b | 17 | public: |
akashvibhute | 0:30537dec6e0b | 18 | |
akashvibhute | 0:30537dec6e0b | 19 | GetRobotInfoRequest() |
akashvibhute | 0:30537dec6e0b | 20 | { |
akashvibhute | 0:30537dec6e0b | 21 | } |
akashvibhute | 0:30537dec6e0b | 22 | |
akashvibhute | 0:30537dec6e0b | 23 | virtual int serialize(unsigned char *outbuffer) const |
akashvibhute | 0:30537dec6e0b | 24 | { |
akashvibhute | 0:30537dec6e0b | 25 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 26 | return offset; |
akashvibhute | 0:30537dec6e0b | 27 | } |
akashvibhute | 0:30537dec6e0b | 28 | |
akashvibhute | 0:30537dec6e0b | 29 | virtual int deserialize(unsigned char *inbuffer) |
akashvibhute | 0:30537dec6e0b | 30 | { |
akashvibhute | 0:30537dec6e0b | 31 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 32 | return offset; |
akashvibhute | 0:30537dec6e0b | 33 | } |
akashvibhute | 0:30537dec6e0b | 34 | |
akashvibhute | 0:30537dec6e0b | 35 | const char * getType(){ return GETROBOTINFO; }; |
akashvibhute | 0:30537dec6e0b | 36 | const char * getMD5(){ return "d41d8cd98f00b204e9800998ecf8427e"; }; |
akashvibhute | 0:30537dec6e0b | 37 | |
akashvibhute | 0:30537dec6e0b | 38 | }; |
akashvibhute | 0:30537dec6e0b | 39 | |
akashvibhute | 0:30537dec6e0b | 40 | class GetRobotInfoResponse : public ros::Msg |
akashvibhute | 0:30537dec6e0b | 41 | { |
akashvibhute | 0:30537dec6e0b | 42 | public: |
akashvibhute | 0:30537dec6e0b | 43 | industrial_msgs::DeviceInfo controller; |
akashvibhute | 0:30537dec6e0b | 44 | uint8_t robots_length; |
akashvibhute | 0:30537dec6e0b | 45 | industrial_msgs::DeviceInfo st_robots; |
akashvibhute | 0:30537dec6e0b | 46 | industrial_msgs::DeviceInfo * robots; |
akashvibhute | 0:30537dec6e0b | 47 | industrial_msgs::ServiceReturnCode code; |
akashvibhute | 0:30537dec6e0b | 48 | |
akashvibhute | 0:30537dec6e0b | 49 | GetRobotInfoResponse(): |
akashvibhute | 0:30537dec6e0b | 50 | controller(), |
akashvibhute | 0:30537dec6e0b | 51 | robots_length(0), robots(NULL), |
akashvibhute | 0:30537dec6e0b | 52 | code() |
akashvibhute | 0:30537dec6e0b | 53 | { |
akashvibhute | 0:30537dec6e0b | 54 | } |
akashvibhute | 0:30537dec6e0b | 55 | |
akashvibhute | 0:30537dec6e0b | 56 | virtual int serialize(unsigned char *outbuffer) const |
akashvibhute | 0:30537dec6e0b | 57 | { |
akashvibhute | 0:30537dec6e0b | 58 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 59 | offset += this->controller.serialize(outbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 60 | *(outbuffer + offset++) = robots_length; |
akashvibhute | 0:30537dec6e0b | 61 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 62 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 63 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 64 | for( uint8_t i = 0; i < robots_length; i++){ |
akashvibhute | 0:30537dec6e0b | 65 | offset += this->robots[i].serialize(outbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 66 | } |
akashvibhute | 0:30537dec6e0b | 67 | offset += this->code.serialize(outbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 68 | return offset; |
akashvibhute | 0:30537dec6e0b | 69 | } |
akashvibhute | 0:30537dec6e0b | 70 | |
akashvibhute | 0:30537dec6e0b | 71 | virtual int deserialize(unsigned char *inbuffer) |
akashvibhute | 0:30537dec6e0b | 72 | { |
akashvibhute | 0:30537dec6e0b | 73 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 74 | offset += this->controller.deserialize(inbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 75 | uint8_t robots_lengthT = *(inbuffer + offset++); |
akashvibhute | 0:30537dec6e0b | 76 | if(robots_lengthT > robots_length) |
akashvibhute | 0:30537dec6e0b | 77 | this->robots = (industrial_msgs::DeviceInfo*)realloc(this->robots, robots_lengthT * sizeof(industrial_msgs::DeviceInfo)); |
akashvibhute | 0:30537dec6e0b | 78 | offset += 3; |
akashvibhute | 0:30537dec6e0b | 79 | robots_length = robots_lengthT; |
akashvibhute | 0:30537dec6e0b | 80 | for( uint8_t i = 0; i < robots_length; i++){ |
akashvibhute | 0:30537dec6e0b | 81 | offset += this->st_robots.deserialize(inbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 82 | memcpy( &(this->robots[i]), &(this->st_robots), sizeof(industrial_msgs::DeviceInfo)); |
akashvibhute | 0:30537dec6e0b | 83 | } |
akashvibhute | 0:30537dec6e0b | 84 | offset += this->code.deserialize(inbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 85 | return offset; |
akashvibhute | 0:30537dec6e0b | 86 | } |
akashvibhute | 0:30537dec6e0b | 87 | |
akashvibhute | 0:30537dec6e0b | 88 | const char * getType(){ return GETROBOTINFO; }; |
akashvibhute | 0:30537dec6e0b | 89 | const char * getMD5(){ return "5db3230b3e61c85a320b999ffd7f3b3f"; }; |
akashvibhute | 0:30537dec6e0b | 90 | |
akashvibhute | 0:30537dec6e0b | 91 | }; |
akashvibhute | 0:30537dec6e0b | 92 | |
akashvibhute | 0:30537dec6e0b | 93 | class GetRobotInfo { |
akashvibhute | 0:30537dec6e0b | 94 | public: |
akashvibhute | 0:30537dec6e0b | 95 | typedef GetRobotInfoRequest Request; |
akashvibhute | 0:30537dec6e0b | 96 | typedef GetRobotInfoResponse Response; |
akashvibhute | 0:30537dec6e0b | 97 | }; |
akashvibhute | 0:30537dec6e0b | 98 | |
akashvibhute | 0:30537dec6e0b | 99 | } |
akashvibhute | 0:30537dec6e0b | 100 | #endif |
akashvibhute | 0:30537dec6e0b | 101 |