Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: RobotFeedback mobileRobotITU
Fork of ros_lib_indigo by
dynamic_reconfigure/BoolParameter.h@0:fd24f7ca9688, 2016-03-31 (annotated)
- Committer:
- garyservin
- Date:
- Thu Mar 31 14:22:59 2016 +0000
- Revision:
- 0:fd24f7ca9688
Initial commit, generated based on a clean indigo-desktop-full
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| garyservin | 0:fd24f7ca9688 | 1 | #ifndef _ROS_dynamic_reconfigure_BoolParameter_h |
| garyservin | 0:fd24f7ca9688 | 2 | #define _ROS_dynamic_reconfigure_BoolParameter_h |
| garyservin | 0:fd24f7ca9688 | 3 | |
| garyservin | 0:fd24f7ca9688 | 4 | #include <stdint.h> |
| garyservin | 0:fd24f7ca9688 | 5 | #include <string.h> |
| garyservin | 0:fd24f7ca9688 | 6 | #include <stdlib.h> |
| garyservin | 0:fd24f7ca9688 | 7 | #include "ros/msg.h" |
| garyservin | 0:fd24f7ca9688 | 8 | |
| garyservin | 0:fd24f7ca9688 | 9 | namespace dynamic_reconfigure |
| garyservin | 0:fd24f7ca9688 | 10 | { |
| garyservin | 0:fd24f7ca9688 | 11 | |
| garyservin | 0:fd24f7ca9688 | 12 | class BoolParameter : public ros::Msg |
| garyservin | 0:fd24f7ca9688 | 13 | { |
| garyservin | 0:fd24f7ca9688 | 14 | public: |
| garyservin | 0:fd24f7ca9688 | 15 | const char* name; |
| garyservin | 0:fd24f7ca9688 | 16 | bool value; |
| garyservin | 0:fd24f7ca9688 | 17 | |
| garyservin | 0:fd24f7ca9688 | 18 | BoolParameter(): |
| garyservin | 0:fd24f7ca9688 | 19 | name(""), |
| garyservin | 0:fd24f7ca9688 | 20 | value(0) |
| garyservin | 0:fd24f7ca9688 | 21 | { |
| garyservin | 0:fd24f7ca9688 | 22 | } |
| garyservin | 0:fd24f7ca9688 | 23 | |
| garyservin | 0:fd24f7ca9688 | 24 | virtual int serialize(unsigned char *outbuffer) const |
| garyservin | 0:fd24f7ca9688 | 25 | { |
| garyservin | 0:fd24f7ca9688 | 26 | int offset = 0; |
| garyservin | 0:fd24f7ca9688 | 27 | uint32_t length_name = strlen(this->name); |
| garyservin | 0:fd24f7ca9688 | 28 | memcpy(outbuffer + offset, &length_name, sizeof(uint32_t)); |
| garyservin | 0:fd24f7ca9688 | 29 | offset += 4; |
| garyservin | 0:fd24f7ca9688 | 30 | memcpy(outbuffer + offset, this->name, length_name); |
| garyservin | 0:fd24f7ca9688 | 31 | offset += length_name; |
| garyservin | 0:fd24f7ca9688 | 32 | union { |
| garyservin | 0:fd24f7ca9688 | 33 | bool real; |
| garyservin | 0:fd24f7ca9688 | 34 | uint8_t base; |
| garyservin | 0:fd24f7ca9688 | 35 | } u_value; |
| garyservin | 0:fd24f7ca9688 | 36 | u_value.real = this->value; |
| garyservin | 0:fd24f7ca9688 | 37 | *(outbuffer + offset + 0) = (u_value.base >> (8 * 0)) & 0xFF; |
| garyservin | 0:fd24f7ca9688 | 38 | offset += sizeof(this->value); |
| garyservin | 0:fd24f7ca9688 | 39 | return offset; |
| garyservin | 0:fd24f7ca9688 | 40 | } |
| garyservin | 0:fd24f7ca9688 | 41 | |
| garyservin | 0:fd24f7ca9688 | 42 | virtual int deserialize(unsigned char *inbuffer) |
| garyservin | 0:fd24f7ca9688 | 43 | { |
| garyservin | 0:fd24f7ca9688 | 44 | int offset = 0; |
| garyservin | 0:fd24f7ca9688 | 45 | uint32_t length_name; |
| garyservin | 0:fd24f7ca9688 | 46 | memcpy(&length_name, (inbuffer + offset), sizeof(uint32_t)); |
| garyservin | 0:fd24f7ca9688 | 47 | offset += 4; |
| garyservin | 0:fd24f7ca9688 | 48 | for(unsigned int k= offset; k< offset+length_name; ++k){ |
| garyservin | 0:fd24f7ca9688 | 49 | inbuffer[k-1]=inbuffer[k]; |
| garyservin | 0:fd24f7ca9688 | 50 | } |
| garyservin | 0:fd24f7ca9688 | 51 | inbuffer[offset+length_name-1]=0; |
| garyservin | 0:fd24f7ca9688 | 52 | this->name = (char *)(inbuffer + offset-1); |
| garyservin | 0:fd24f7ca9688 | 53 | offset += length_name; |
| garyservin | 0:fd24f7ca9688 | 54 | union { |
| garyservin | 0:fd24f7ca9688 | 55 | bool real; |
| garyservin | 0:fd24f7ca9688 | 56 | uint8_t base; |
| garyservin | 0:fd24f7ca9688 | 57 | } u_value; |
| garyservin | 0:fd24f7ca9688 | 58 | u_value.base = 0; |
| garyservin | 0:fd24f7ca9688 | 59 | u_value.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); |
| garyservin | 0:fd24f7ca9688 | 60 | this->value = u_value.real; |
| garyservin | 0:fd24f7ca9688 | 61 | offset += sizeof(this->value); |
| garyservin | 0:fd24f7ca9688 | 62 | return offset; |
| garyservin | 0:fd24f7ca9688 | 63 | } |
| garyservin | 0:fd24f7ca9688 | 64 | |
| garyservin | 0:fd24f7ca9688 | 65 | const char * getType(){ return "dynamic_reconfigure/BoolParameter"; }; |
| garyservin | 0:fd24f7ca9688 | 66 | const char * getMD5(){ return "23f05028c1a699fb83e22401228c3a9e"; }; |
| garyservin | 0:fd24f7ca9688 | 67 | |
| garyservin | 0:fd24f7ca9688 | 68 | }; |
| garyservin | 0:fd24f7ca9688 | 69 | |
| garyservin | 0:fd24f7ca9688 | 70 | } |
| garyservin | 0:fd24f7ca9688 | 71 | #endif |
