rosserial library for mbed Inspired by nucho's rosserial library This library is still under development
Dependents: mbed_roshydro_test
Library still under development!
visualization_msgs/InteractiveMarkerControl.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_visualization_msgs_InteractiveMarkerControl_h |
akashvibhute | 0:30537dec6e0b | 2 | #define _ROS_visualization_msgs_InteractiveMarkerControl_h |
akashvibhute | 0:30537dec6e0b | 3 | |
akashvibhute | 0:30537dec6e0b | 4 | #include <stdint.h> |
akashvibhute | 0:30537dec6e0b | 5 | #include <string.h> |
akashvibhute | 0:30537dec6e0b | 6 | #include <stdlib.h> |
akashvibhute | 0:30537dec6e0b | 7 | #include "ros/msg.h" |
akashvibhute | 0:30537dec6e0b | 8 | #include "geometry_msgs/Quaternion.h" |
akashvibhute | 0:30537dec6e0b | 9 | #include "visualization_msgs/Marker.h" |
akashvibhute | 0:30537dec6e0b | 10 | |
akashvibhute | 0:30537dec6e0b | 11 | namespace visualization_msgs |
akashvibhute | 0:30537dec6e0b | 12 | { |
akashvibhute | 0:30537dec6e0b | 13 | |
akashvibhute | 0:30537dec6e0b | 14 | class InteractiveMarkerControl : public ros::Msg |
akashvibhute | 0:30537dec6e0b | 15 | { |
akashvibhute | 0:30537dec6e0b | 16 | public: |
akashvibhute | 0:30537dec6e0b | 17 | const char* name; |
akashvibhute | 0:30537dec6e0b | 18 | geometry_msgs::Quaternion orientation; |
akashvibhute | 0:30537dec6e0b | 19 | uint8_t orientation_mode; |
akashvibhute | 0:30537dec6e0b | 20 | uint8_t interaction_mode; |
akashvibhute | 0:30537dec6e0b | 21 | bool always_visible; |
akashvibhute | 0:30537dec6e0b | 22 | uint8_t markers_length; |
akashvibhute | 0:30537dec6e0b | 23 | visualization_msgs::Marker st_markers; |
akashvibhute | 0:30537dec6e0b | 24 | visualization_msgs::Marker * markers; |
akashvibhute | 0:30537dec6e0b | 25 | bool independent_marker_orientation; |
akashvibhute | 0:30537dec6e0b | 26 | const char* description; |
akashvibhute | 0:30537dec6e0b | 27 | enum { INHERIT = 0 }; |
akashvibhute | 0:30537dec6e0b | 28 | enum { FIXED = 1 }; |
akashvibhute | 0:30537dec6e0b | 29 | enum { VIEW_FACING = 2 }; |
akashvibhute | 0:30537dec6e0b | 30 | enum { NONE = 0 }; |
akashvibhute | 0:30537dec6e0b | 31 | enum { MENU = 1 }; |
akashvibhute | 0:30537dec6e0b | 32 | enum { BUTTON = 2 }; |
akashvibhute | 0:30537dec6e0b | 33 | enum { MOVE_AXIS = 3 }; |
akashvibhute | 0:30537dec6e0b | 34 | enum { MOVE_PLANE = 4 }; |
akashvibhute | 0:30537dec6e0b | 35 | enum { ROTATE_AXIS = 5 }; |
akashvibhute | 0:30537dec6e0b | 36 | enum { MOVE_ROTATE = 6 }; |
akashvibhute | 0:30537dec6e0b | 37 | enum { MOVE_3D = 7 }; |
akashvibhute | 0:30537dec6e0b | 38 | enum { ROTATE_3D = 8 }; |
akashvibhute | 0:30537dec6e0b | 39 | enum { MOVE_ROTATE_3D = 9 }; |
akashvibhute | 0:30537dec6e0b | 40 | |
akashvibhute | 0:30537dec6e0b | 41 | InteractiveMarkerControl(): |
akashvibhute | 0:30537dec6e0b | 42 | name(""), |
akashvibhute | 0:30537dec6e0b | 43 | orientation(), |
akashvibhute | 0:30537dec6e0b | 44 | orientation_mode(0), |
akashvibhute | 0:30537dec6e0b | 45 | interaction_mode(0), |
akashvibhute | 0:30537dec6e0b | 46 | always_visible(0), |
akashvibhute | 0:30537dec6e0b | 47 | markers_length(0), markers(NULL), |
akashvibhute | 0:30537dec6e0b | 48 | independent_marker_orientation(0), |
akashvibhute | 0:30537dec6e0b | 49 | description("") |
akashvibhute | 0:30537dec6e0b | 50 | { |
akashvibhute | 0:30537dec6e0b | 51 | } |
akashvibhute | 0:30537dec6e0b | 52 | |
akashvibhute | 0:30537dec6e0b | 53 | virtual int serialize(unsigned char *outbuffer) const |
akashvibhute | 0:30537dec6e0b | 54 | { |
akashvibhute | 0:30537dec6e0b | 55 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 56 | uint32_t length_name = strlen(this->name); |
akashvibhute | 0:30537dec6e0b | 57 | memcpy(outbuffer + offset, &length_name, sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 58 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 59 | memcpy(outbuffer + offset, this->name, length_name); |
akashvibhute | 0:30537dec6e0b | 60 | offset += length_name; |
akashvibhute | 0:30537dec6e0b | 61 | offset += this->orientation.serialize(outbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 62 | *(outbuffer + offset + 0) = (this->orientation_mode >> (8 * 0)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 63 | offset += sizeof(this->orientation_mode); |
akashvibhute | 0:30537dec6e0b | 64 | *(outbuffer + offset + 0) = (this->interaction_mode >> (8 * 0)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 65 | offset += sizeof(this->interaction_mode); |
akashvibhute | 0:30537dec6e0b | 66 | union { |
akashvibhute | 0:30537dec6e0b | 67 | bool real; |
akashvibhute | 0:30537dec6e0b | 68 | uint8_t base; |
akashvibhute | 0:30537dec6e0b | 69 | } u_always_visible; |
akashvibhute | 0:30537dec6e0b | 70 | u_always_visible.real = this->always_visible; |
akashvibhute | 0:30537dec6e0b | 71 | *(outbuffer + offset + 0) = (u_always_visible.base >> (8 * 0)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 72 | offset += sizeof(this->always_visible); |
akashvibhute | 0:30537dec6e0b | 73 | *(outbuffer + offset++) = markers_length; |
akashvibhute | 0:30537dec6e0b | 74 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 75 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 76 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 77 | for( uint8_t i = 0; i < markers_length; i++){ |
akashvibhute | 0:30537dec6e0b | 78 | offset += this->markers[i].serialize(outbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 79 | } |
akashvibhute | 0:30537dec6e0b | 80 | union { |
akashvibhute | 0:30537dec6e0b | 81 | bool real; |
akashvibhute | 0:30537dec6e0b | 82 | uint8_t base; |
akashvibhute | 0:30537dec6e0b | 83 | } u_independent_marker_orientation; |
akashvibhute | 0:30537dec6e0b | 84 | u_independent_marker_orientation.real = this->independent_marker_orientation; |
akashvibhute | 0:30537dec6e0b | 85 | *(outbuffer + offset + 0) = (u_independent_marker_orientation.base >> (8 * 0)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 86 | offset += sizeof(this->independent_marker_orientation); |
akashvibhute | 0:30537dec6e0b | 87 | uint32_t length_description = strlen(this->description); |
akashvibhute | 0:30537dec6e0b | 88 | memcpy(outbuffer + offset, &length_description, sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 89 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 90 | memcpy(outbuffer + offset, this->description, length_description); |
akashvibhute | 0:30537dec6e0b | 91 | offset += length_description; |
akashvibhute | 0:30537dec6e0b | 92 | return offset; |
akashvibhute | 0:30537dec6e0b | 93 | } |
akashvibhute | 0:30537dec6e0b | 94 | |
akashvibhute | 0:30537dec6e0b | 95 | virtual int deserialize(unsigned char *inbuffer) |
akashvibhute | 0:30537dec6e0b | 96 | { |
akashvibhute | 0:30537dec6e0b | 97 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 98 | uint32_t length_name; |
akashvibhute | 0:30537dec6e0b | 99 | memcpy(&length_name, (inbuffer + offset), sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 100 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 101 | for(unsigned int k= offset; k< offset+length_name; ++k){ |
akashvibhute | 0:30537dec6e0b | 102 | inbuffer[k-1]=inbuffer[k]; |
akashvibhute | 0:30537dec6e0b | 103 | } |
akashvibhute | 0:30537dec6e0b | 104 | inbuffer[offset+length_name-1]=0; |
akashvibhute | 0:30537dec6e0b | 105 | this->name = (char *)(inbuffer + offset-1); |
akashvibhute | 0:30537dec6e0b | 106 | offset += length_name; |
akashvibhute | 0:30537dec6e0b | 107 | offset += this->orientation.deserialize(inbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 108 | this->orientation_mode = ((uint8_t) (*(inbuffer + offset))); |
akashvibhute | 0:30537dec6e0b | 109 | offset += sizeof(this->orientation_mode); |
akashvibhute | 0:30537dec6e0b | 110 | this->interaction_mode = ((uint8_t) (*(inbuffer + offset))); |
akashvibhute | 0:30537dec6e0b | 111 | offset += sizeof(this->interaction_mode); |
akashvibhute | 0:30537dec6e0b | 112 | union { |
akashvibhute | 0:30537dec6e0b | 113 | bool real; |
akashvibhute | 0:30537dec6e0b | 114 | uint8_t base; |
akashvibhute | 0:30537dec6e0b | 115 | } u_always_visible; |
akashvibhute | 0:30537dec6e0b | 116 | u_always_visible.base = 0; |
akashvibhute | 0:30537dec6e0b | 117 | u_always_visible.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); |
akashvibhute | 0:30537dec6e0b | 118 | this->always_visible = u_always_visible.real; |
akashvibhute | 0:30537dec6e0b | 119 | offset += sizeof(this->always_visible); |
akashvibhute | 0:30537dec6e0b | 120 | uint8_t markers_lengthT = *(inbuffer + offset++); |
akashvibhute | 0:30537dec6e0b | 121 | if(markers_lengthT > markers_length) |
akashvibhute | 0:30537dec6e0b | 122 | this->markers = (visualization_msgs::Marker*)realloc(this->markers, markers_lengthT * sizeof(visualization_msgs::Marker)); |
akashvibhute | 0:30537dec6e0b | 123 | offset += 3; |
akashvibhute | 0:30537dec6e0b | 124 | markers_length = markers_lengthT; |
akashvibhute | 0:30537dec6e0b | 125 | for( uint8_t i = 0; i < markers_length; i++){ |
akashvibhute | 0:30537dec6e0b | 126 | offset += this->st_markers.deserialize(inbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 127 | memcpy( &(this->markers[i]), &(this->st_markers), sizeof(visualization_msgs::Marker)); |
akashvibhute | 0:30537dec6e0b | 128 | } |
akashvibhute | 0:30537dec6e0b | 129 | union { |
akashvibhute | 0:30537dec6e0b | 130 | bool real; |
akashvibhute | 0:30537dec6e0b | 131 | uint8_t base; |
akashvibhute | 0:30537dec6e0b | 132 | } u_independent_marker_orientation; |
akashvibhute | 0:30537dec6e0b | 133 | u_independent_marker_orientation.base = 0; |
akashvibhute | 0:30537dec6e0b | 134 | u_independent_marker_orientation.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); |
akashvibhute | 0:30537dec6e0b | 135 | this->independent_marker_orientation = u_independent_marker_orientation.real; |
akashvibhute | 0:30537dec6e0b | 136 | offset += sizeof(this->independent_marker_orientation); |
akashvibhute | 0:30537dec6e0b | 137 | uint32_t length_description; |
akashvibhute | 0:30537dec6e0b | 138 | memcpy(&length_description, (inbuffer + offset), sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 139 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 140 | for(unsigned int k= offset; k< offset+length_description; ++k){ |
akashvibhute | 0:30537dec6e0b | 141 | inbuffer[k-1]=inbuffer[k]; |
akashvibhute | 0:30537dec6e0b | 142 | } |
akashvibhute | 0:30537dec6e0b | 143 | inbuffer[offset+length_description-1]=0; |
akashvibhute | 0:30537dec6e0b | 144 | this->description = (char *)(inbuffer + offset-1); |
akashvibhute | 0:30537dec6e0b | 145 | offset += length_description; |
akashvibhute | 0:30537dec6e0b | 146 | return offset; |
akashvibhute | 0:30537dec6e0b | 147 | } |
akashvibhute | 0:30537dec6e0b | 148 | |
akashvibhute | 0:30537dec6e0b | 149 | const char * getType(){ return "visualization_msgs/InteractiveMarkerControl"; }; |
akashvibhute | 0:30537dec6e0b | 150 | const char * getMD5(){ return "e3a939c98cdd4f709d8e1dec2a9c3f37"; }; |
akashvibhute | 0:30537dec6e0b | 151 | |
akashvibhute | 0:30537dec6e0b | 152 | }; |
akashvibhute | 0:30537dec6e0b | 153 | |
akashvibhute | 0:30537dec6e0b | 154 | } |
akashvibhute | 0:30537dec6e0b | 155 | #endif |