Fork of ROS Serial Library
Dependencies: BufferedSerial
Diff: turtlesim/Color.h
- Revision:
- 0:9e9b7db60fd5
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/turtlesim/Color.h Sat Dec 31 00:48:34 2016 +0000 @@ -0,0 +1,59 @@ +#ifndef _ROS_turtlesim_Color_h +#define _ROS_turtlesim_Color_h + +#include <stdint.h> +#include <string.h> +#include <stdlib.h> +#include "ros/msg.h" + +namespace turtlesim +{ + + class Color : public ros::Msg + { + public: + typedef uint8_t _r_type; + _r_type r; + typedef uint8_t _g_type; + _g_type g; + typedef uint8_t _b_type; + _b_type b; + + Color(): + r(0), + g(0), + b(0) + { + } + + virtual int serialize(unsigned char *outbuffer) const + { + int offset = 0; + *(outbuffer + offset + 0) = (this->r >> (8 * 0)) & 0xFF; + offset += sizeof(this->r); + *(outbuffer + offset + 0) = (this->g >> (8 * 0)) & 0xFF; + offset += sizeof(this->g); + *(outbuffer + offset + 0) = (this->b >> (8 * 0)) & 0xFF; + offset += sizeof(this->b); + return offset; + } + + virtual int deserialize(unsigned char *inbuffer) + { + int offset = 0; + this->r = ((uint8_t) (*(inbuffer + offset))); + offset += sizeof(this->r); + this->g = ((uint8_t) (*(inbuffer + offset))); + offset += sizeof(this->g); + this->b = ((uint8_t) (*(inbuffer + offset))); + offset += sizeof(this->b); + return offset; + } + + const char * getType(){ return "turtlesim/Color"; }; + const char * getMD5(){ return "353891e354491c51aabe32df673fb446"; }; + + }; + +} +#endif \ No newline at end of file