rosserial library for mbed Inspired by nucho's rosserial library This library is still under development
Dependents: mbed_roshydro_test
Library still under development!
gazebo_msgs/ContactState.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_gazebo_msgs_ContactState_h |
akashvibhute | 0:30537dec6e0b | 2 | #define _ROS_gazebo_msgs_ContactState_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/Wrench.h" |
akashvibhute | 0:30537dec6e0b | 9 | #include "geometry_msgs/Vector3.h" |
akashvibhute | 0:30537dec6e0b | 10 | |
akashvibhute | 0:30537dec6e0b | 11 | namespace gazebo_msgs |
akashvibhute | 0:30537dec6e0b | 12 | { |
akashvibhute | 0:30537dec6e0b | 13 | |
akashvibhute | 0:30537dec6e0b | 14 | class ContactState : public ros::Msg |
akashvibhute | 0:30537dec6e0b | 15 | { |
akashvibhute | 0:30537dec6e0b | 16 | public: |
akashvibhute | 0:30537dec6e0b | 17 | const char* info; |
akashvibhute | 0:30537dec6e0b | 18 | const char* collision1_name; |
akashvibhute | 0:30537dec6e0b | 19 | const char* collision2_name; |
akashvibhute | 0:30537dec6e0b | 20 | uint8_t wrenches_length; |
akashvibhute | 0:30537dec6e0b | 21 | geometry_msgs::Wrench st_wrenches; |
akashvibhute | 0:30537dec6e0b | 22 | geometry_msgs::Wrench * wrenches; |
akashvibhute | 0:30537dec6e0b | 23 | geometry_msgs::Wrench total_wrench; |
akashvibhute | 0:30537dec6e0b | 24 | uint8_t contact_positions_length; |
akashvibhute | 0:30537dec6e0b | 25 | geometry_msgs::Vector3 st_contact_positions; |
akashvibhute | 0:30537dec6e0b | 26 | geometry_msgs::Vector3 * contact_positions; |
akashvibhute | 0:30537dec6e0b | 27 | uint8_t contact_normals_length; |
akashvibhute | 0:30537dec6e0b | 28 | geometry_msgs::Vector3 st_contact_normals; |
akashvibhute | 0:30537dec6e0b | 29 | geometry_msgs::Vector3 * contact_normals; |
akashvibhute | 0:30537dec6e0b | 30 | uint8_t depths_length; |
akashvibhute | 0:30537dec6e0b | 31 | float st_depths; |
akashvibhute | 0:30537dec6e0b | 32 | float * depths; |
akashvibhute | 0:30537dec6e0b | 33 | |
akashvibhute | 0:30537dec6e0b | 34 | ContactState(): |
akashvibhute | 0:30537dec6e0b | 35 | info(""), |
akashvibhute | 0:30537dec6e0b | 36 | collision1_name(""), |
akashvibhute | 0:30537dec6e0b | 37 | collision2_name(""), |
akashvibhute | 0:30537dec6e0b | 38 | wrenches_length(0), wrenches(NULL), |
akashvibhute | 0:30537dec6e0b | 39 | total_wrench(), |
akashvibhute | 0:30537dec6e0b | 40 | contact_positions_length(0), contact_positions(NULL), |
akashvibhute | 0:30537dec6e0b | 41 | contact_normals_length(0), contact_normals(NULL), |
akashvibhute | 0:30537dec6e0b | 42 | depths_length(0), depths(NULL) |
akashvibhute | 0:30537dec6e0b | 43 | { |
akashvibhute | 0:30537dec6e0b | 44 | } |
akashvibhute | 0:30537dec6e0b | 45 | |
akashvibhute | 0:30537dec6e0b | 46 | virtual int serialize(unsigned char *outbuffer) const |
akashvibhute | 0:30537dec6e0b | 47 | { |
akashvibhute | 0:30537dec6e0b | 48 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 49 | uint32_t length_info = strlen(this->info); |
akashvibhute | 0:30537dec6e0b | 50 | memcpy(outbuffer + offset, &length_info, sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 51 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 52 | memcpy(outbuffer + offset, this->info, length_info); |
akashvibhute | 0:30537dec6e0b | 53 | offset += length_info; |
akashvibhute | 0:30537dec6e0b | 54 | uint32_t length_collision1_name = strlen(this->collision1_name); |
akashvibhute | 0:30537dec6e0b | 55 | memcpy(outbuffer + offset, &length_collision1_name, sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 56 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 57 | memcpy(outbuffer + offset, this->collision1_name, length_collision1_name); |
akashvibhute | 0:30537dec6e0b | 58 | offset += length_collision1_name; |
akashvibhute | 0:30537dec6e0b | 59 | uint32_t length_collision2_name = strlen(this->collision2_name); |
akashvibhute | 0:30537dec6e0b | 60 | memcpy(outbuffer + offset, &length_collision2_name, sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 61 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 62 | memcpy(outbuffer + offset, this->collision2_name, length_collision2_name); |
akashvibhute | 0:30537dec6e0b | 63 | offset += length_collision2_name; |
akashvibhute | 0:30537dec6e0b | 64 | *(outbuffer + offset++) = wrenches_length; |
akashvibhute | 0:30537dec6e0b | 65 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 66 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 67 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 68 | for( uint8_t i = 0; i < wrenches_length; i++){ |
akashvibhute | 0:30537dec6e0b | 69 | offset += this->wrenches[i].serialize(outbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 70 | } |
akashvibhute | 0:30537dec6e0b | 71 | offset += this->total_wrench.serialize(outbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 72 | *(outbuffer + offset++) = contact_positions_length; |
akashvibhute | 0:30537dec6e0b | 73 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 74 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 75 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 76 | for( uint8_t i = 0; i < contact_positions_length; i++){ |
akashvibhute | 0:30537dec6e0b | 77 | offset += this->contact_positions[i].serialize(outbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 78 | } |
akashvibhute | 0:30537dec6e0b | 79 | *(outbuffer + offset++) = contact_normals_length; |
akashvibhute | 0:30537dec6e0b | 80 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 81 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 82 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 83 | for( uint8_t i = 0; i < contact_normals_length; i++){ |
akashvibhute | 0:30537dec6e0b | 84 | offset += this->contact_normals[i].serialize(outbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 85 | } |
akashvibhute | 0:30537dec6e0b | 86 | *(outbuffer + offset++) = depths_length; |
akashvibhute | 0:30537dec6e0b | 87 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 88 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 89 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 90 | for( uint8_t i = 0; i < depths_length; i++){ |
akashvibhute | 0:30537dec6e0b | 91 | offset += serializeAvrFloat64(outbuffer + offset, this->depths[i]); |
akashvibhute | 0:30537dec6e0b | 92 | } |
akashvibhute | 0:30537dec6e0b | 93 | return offset; |
akashvibhute | 0:30537dec6e0b | 94 | } |
akashvibhute | 0:30537dec6e0b | 95 | |
akashvibhute | 0:30537dec6e0b | 96 | virtual int deserialize(unsigned char *inbuffer) |
akashvibhute | 0:30537dec6e0b | 97 | { |
akashvibhute | 0:30537dec6e0b | 98 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 99 | uint32_t length_info; |
akashvibhute | 0:30537dec6e0b | 100 | memcpy(&length_info, (inbuffer + offset), sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 101 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 102 | for(unsigned int k= offset; k< offset+length_info; ++k){ |
akashvibhute | 0:30537dec6e0b | 103 | inbuffer[k-1]=inbuffer[k]; |
akashvibhute | 0:30537dec6e0b | 104 | } |
akashvibhute | 0:30537dec6e0b | 105 | inbuffer[offset+length_info-1]=0; |
akashvibhute | 0:30537dec6e0b | 106 | this->info = (char *)(inbuffer + offset-1); |
akashvibhute | 0:30537dec6e0b | 107 | offset += length_info; |
akashvibhute | 0:30537dec6e0b | 108 | uint32_t length_collision1_name; |
akashvibhute | 0:30537dec6e0b | 109 | memcpy(&length_collision1_name, (inbuffer + offset), sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 110 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 111 | for(unsigned int k= offset; k< offset+length_collision1_name; ++k){ |
akashvibhute | 0:30537dec6e0b | 112 | inbuffer[k-1]=inbuffer[k]; |
akashvibhute | 0:30537dec6e0b | 113 | } |
akashvibhute | 0:30537dec6e0b | 114 | inbuffer[offset+length_collision1_name-1]=0; |
akashvibhute | 0:30537dec6e0b | 115 | this->collision1_name = (char *)(inbuffer + offset-1); |
akashvibhute | 0:30537dec6e0b | 116 | offset += length_collision1_name; |
akashvibhute | 0:30537dec6e0b | 117 | uint32_t length_collision2_name; |
akashvibhute | 0:30537dec6e0b | 118 | memcpy(&length_collision2_name, (inbuffer + offset), sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 119 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 120 | for(unsigned int k= offset; k< offset+length_collision2_name; ++k){ |
akashvibhute | 0:30537dec6e0b | 121 | inbuffer[k-1]=inbuffer[k]; |
akashvibhute | 0:30537dec6e0b | 122 | } |
akashvibhute | 0:30537dec6e0b | 123 | inbuffer[offset+length_collision2_name-1]=0; |
akashvibhute | 0:30537dec6e0b | 124 | this->collision2_name = (char *)(inbuffer + offset-1); |
akashvibhute | 0:30537dec6e0b | 125 | offset += length_collision2_name; |
akashvibhute | 0:30537dec6e0b | 126 | uint8_t wrenches_lengthT = *(inbuffer + offset++); |
akashvibhute | 0:30537dec6e0b | 127 | if(wrenches_lengthT > wrenches_length) |
akashvibhute | 0:30537dec6e0b | 128 | this->wrenches = (geometry_msgs::Wrench*)realloc(this->wrenches, wrenches_lengthT * sizeof(geometry_msgs::Wrench)); |
akashvibhute | 0:30537dec6e0b | 129 | offset += 3; |
akashvibhute | 0:30537dec6e0b | 130 | wrenches_length = wrenches_lengthT; |
akashvibhute | 0:30537dec6e0b | 131 | for( uint8_t i = 0; i < wrenches_length; i++){ |
akashvibhute | 0:30537dec6e0b | 132 | offset += this->st_wrenches.deserialize(inbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 133 | memcpy( &(this->wrenches[i]), &(this->st_wrenches), sizeof(geometry_msgs::Wrench)); |
akashvibhute | 0:30537dec6e0b | 134 | } |
akashvibhute | 0:30537dec6e0b | 135 | offset += this->total_wrench.deserialize(inbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 136 | uint8_t contact_positions_lengthT = *(inbuffer + offset++); |
akashvibhute | 0:30537dec6e0b | 137 | if(contact_positions_lengthT > contact_positions_length) |
akashvibhute | 0:30537dec6e0b | 138 | this->contact_positions = (geometry_msgs::Vector3*)realloc(this->contact_positions, contact_positions_lengthT * sizeof(geometry_msgs::Vector3)); |
akashvibhute | 0:30537dec6e0b | 139 | offset += 3; |
akashvibhute | 0:30537dec6e0b | 140 | contact_positions_length = contact_positions_lengthT; |
akashvibhute | 0:30537dec6e0b | 141 | for( uint8_t i = 0; i < contact_positions_length; i++){ |
akashvibhute | 0:30537dec6e0b | 142 | offset += this->st_contact_positions.deserialize(inbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 143 | memcpy( &(this->contact_positions[i]), &(this->st_contact_positions), sizeof(geometry_msgs::Vector3)); |
akashvibhute | 0:30537dec6e0b | 144 | } |
akashvibhute | 0:30537dec6e0b | 145 | uint8_t contact_normals_lengthT = *(inbuffer + offset++); |
akashvibhute | 0:30537dec6e0b | 146 | if(contact_normals_lengthT > contact_normals_length) |
akashvibhute | 0:30537dec6e0b | 147 | this->contact_normals = (geometry_msgs::Vector3*)realloc(this->contact_normals, contact_normals_lengthT * sizeof(geometry_msgs::Vector3)); |
akashvibhute | 0:30537dec6e0b | 148 | offset += 3; |
akashvibhute | 0:30537dec6e0b | 149 | contact_normals_length = contact_normals_lengthT; |
akashvibhute | 0:30537dec6e0b | 150 | for( uint8_t i = 0; i < contact_normals_length; i++){ |
akashvibhute | 0:30537dec6e0b | 151 | offset += this->st_contact_normals.deserialize(inbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 152 | memcpy( &(this->contact_normals[i]), &(this->st_contact_normals), sizeof(geometry_msgs::Vector3)); |
akashvibhute | 0:30537dec6e0b | 153 | } |
akashvibhute | 0:30537dec6e0b | 154 | uint8_t depths_lengthT = *(inbuffer + offset++); |
akashvibhute | 0:30537dec6e0b | 155 | if(depths_lengthT > depths_length) |
akashvibhute | 0:30537dec6e0b | 156 | this->depths = (float*)realloc(this->depths, depths_lengthT * sizeof(float)); |
akashvibhute | 0:30537dec6e0b | 157 | offset += 3; |
akashvibhute | 0:30537dec6e0b | 158 | depths_length = depths_lengthT; |
akashvibhute | 0:30537dec6e0b | 159 | for( uint8_t i = 0; i < depths_length; i++){ |
akashvibhute | 0:30537dec6e0b | 160 | offset += deserializeAvrFloat64(inbuffer + offset, &(this->st_depths)); |
akashvibhute | 0:30537dec6e0b | 161 | memcpy( &(this->depths[i]), &(this->st_depths), sizeof(float)); |
akashvibhute | 0:30537dec6e0b | 162 | } |
akashvibhute | 0:30537dec6e0b | 163 | return offset; |
akashvibhute | 0:30537dec6e0b | 164 | } |
akashvibhute | 0:30537dec6e0b | 165 | |
akashvibhute | 0:30537dec6e0b | 166 | const char * getType(){ return "gazebo_msgs/ContactState"; }; |
akashvibhute | 0:30537dec6e0b | 167 | const char * getMD5(){ return "48c0ffb054b8c444f870cecea1ee50d9"; }; |
akashvibhute | 0:30537dec6e0b | 168 | |
akashvibhute | 0:30537dec6e0b | 169 | }; |
akashvibhute | 0:30537dec6e0b | 170 | |
akashvibhute | 0:30537dec6e0b | 171 | } |
akashvibhute | 0:30537dec6e0b | 172 | #endif |