hairo
Dependencies: mbed BufferedSerial
gazebo_msgs/WorldState.h@4:bcdd99711326, 2018-12-04 (annotated)
- Committer:
- tknara
- Date:
- Tue Dec 04 00:14:32 2018 +0000
- Revision:
- 4:bcdd99711326
- Parent:
- 0:9e9b7db60fd5
test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
garyservin | 0:9e9b7db60fd5 | 1 | #ifndef _ROS_gazebo_msgs_WorldState_h |
garyservin | 0:9e9b7db60fd5 | 2 | #define _ROS_gazebo_msgs_WorldState_h |
garyservin | 0:9e9b7db60fd5 | 3 | |
garyservin | 0:9e9b7db60fd5 | 4 | #include <stdint.h> |
garyservin | 0:9e9b7db60fd5 | 5 | #include <string.h> |
garyservin | 0:9e9b7db60fd5 | 6 | #include <stdlib.h> |
garyservin | 0:9e9b7db60fd5 | 7 | #include "ros/msg.h" |
garyservin | 0:9e9b7db60fd5 | 8 | #include "std_msgs/Header.h" |
garyservin | 0:9e9b7db60fd5 | 9 | #include "geometry_msgs/Pose.h" |
garyservin | 0:9e9b7db60fd5 | 10 | #include "geometry_msgs/Twist.h" |
garyservin | 0:9e9b7db60fd5 | 11 | #include "geometry_msgs/Wrench.h" |
garyservin | 0:9e9b7db60fd5 | 12 | |
garyservin | 0:9e9b7db60fd5 | 13 | namespace gazebo_msgs |
garyservin | 0:9e9b7db60fd5 | 14 | { |
garyservin | 0:9e9b7db60fd5 | 15 | |
garyservin | 0:9e9b7db60fd5 | 16 | class WorldState : public ros::Msg |
garyservin | 0:9e9b7db60fd5 | 17 | { |
garyservin | 0:9e9b7db60fd5 | 18 | public: |
garyservin | 0:9e9b7db60fd5 | 19 | typedef std_msgs::Header _header_type; |
garyservin | 0:9e9b7db60fd5 | 20 | _header_type header; |
garyservin | 0:9e9b7db60fd5 | 21 | uint32_t name_length; |
garyservin | 0:9e9b7db60fd5 | 22 | typedef char* _name_type; |
garyservin | 0:9e9b7db60fd5 | 23 | _name_type st_name; |
garyservin | 0:9e9b7db60fd5 | 24 | _name_type * name; |
garyservin | 0:9e9b7db60fd5 | 25 | uint32_t pose_length; |
garyservin | 0:9e9b7db60fd5 | 26 | typedef geometry_msgs::Pose _pose_type; |
garyservin | 0:9e9b7db60fd5 | 27 | _pose_type st_pose; |
garyservin | 0:9e9b7db60fd5 | 28 | _pose_type * pose; |
garyservin | 0:9e9b7db60fd5 | 29 | uint32_t twist_length; |
garyservin | 0:9e9b7db60fd5 | 30 | typedef geometry_msgs::Twist _twist_type; |
garyservin | 0:9e9b7db60fd5 | 31 | _twist_type st_twist; |
garyservin | 0:9e9b7db60fd5 | 32 | _twist_type * twist; |
garyservin | 0:9e9b7db60fd5 | 33 | uint32_t wrench_length; |
garyservin | 0:9e9b7db60fd5 | 34 | typedef geometry_msgs::Wrench _wrench_type; |
garyservin | 0:9e9b7db60fd5 | 35 | _wrench_type st_wrench; |
garyservin | 0:9e9b7db60fd5 | 36 | _wrench_type * wrench; |
garyservin | 0:9e9b7db60fd5 | 37 | |
garyservin | 0:9e9b7db60fd5 | 38 | WorldState(): |
garyservin | 0:9e9b7db60fd5 | 39 | header(), |
garyservin | 0:9e9b7db60fd5 | 40 | name_length(0), name(NULL), |
garyservin | 0:9e9b7db60fd5 | 41 | pose_length(0), pose(NULL), |
garyservin | 0:9e9b7db60fd5 | 42 | twist_length(0), twist(NULL), |
garyservin | 0:9e9b7db60fd5 | 43 | wrench_length(0), wrench(NULL) |
garyservin | 0:9e9b7db60fd5 | 44 | { |
garyservin | 0:9e9b7db60fd5 | 45 | } |
garyservin | 0:9e9b7db60fd5 | 46 | |
garyservin | 0:9e9b7db60fd5 | 47 | virtual int serialize(unsigned char *outbuffer) const |
garyservin | 0:9e9b7db60fd5 | 48 | { |
garyservin | 0:9e9b7db60fd5 | 49 | int offset = 0; |
garyservin | 0:9e9b7db60fd5 | 50 | offset += this->header.serialize(outbuffer + offset); |
garyservin | 0:9e9b7db60fd5 | 51 | *(outbuffer + offset + 0) = (this->name_length >> (8 * 0)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 52 | *(outbuffer + offset + 1) = (this->name_length >> (8 * 1)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 53 | *(outbuffer + offset + 2) = (this->name_length >> (8 * 2)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 54 | *(outbuffer + offset + 3) = (this->name_length >> (8 * 3)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 55 | offset += sizeof(this->name_length); |
garyservin | 0:9e9b7db60fd5 | 56 | for( uint32_t i = 0; i < name_length; i++){ |
garyservin | 0:9e9b7db60fd5 | 57 | uint32_t length_namei = strlen(this->name[i]); |
garyservin | 0:9e9b7db60fd5 | 58 | varToArr(outbuffer + offset, length_namei); |
garyservin | 0:9e9b7db60fd5 | 59 | offset += 4; |
garyservin | 0:9e9b7db60fd5 | 60 | memcpy(outbuffer + offset, this->name[i], length_namei); |
garyservin | 0:9e9b7db60fd5 | 61 | offset += length_namei; |
garyservin | 0:9e9b7db60fd5 | 62 | } |
garyservin | 0:9e9b7db60fd5 | 63 | *(outbuffer + offset + 0) = (this->pose_length >> (8 * 0)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 64 | *(outbuffer + offset + 1) = (this->pose_length >> (8 * 1)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 65 | *(outbuffer + offset + 2) = (this->pose_length >> (8 * 2)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 66 | *(outbuffer + offset + 3) = (this->pose_length >> (8 * 3)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 67 | offset += sizeof(this->pose_length); |
garyservin | 0:9e9b7db60fd5 | 68 | for( uint32_t i = 0; i < pose_length; i++){ |
garyservin | 0:9e9b7db60fd5 | 69 | offset += this->pose[i].serialize(outbuffer + offset); |
garyservin | 0:9e9b7db60fd5 | 70 | } |
garyservin | 0:9e9b7db60fd5 | 71 | *(outbuffer + offset + 0) = (this->twist_length >> (8 * 0)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 72 | *(outbuffer + offset + 1) = (this->twist_length >> (8 * 1)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 73 | *(outbuffer + offset + 2) = (this->twist_length >> (8 * 2)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 74 | *(outbuffer + offset + 3) = (this->twist_length >> (8 * 3)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 75 | offset += sizeof(this->twist_length); |
garyservin | 0:9e9b7db60fd5 | 76 | for( uint32_t i = 0; i < twist_length; i++){ |
garyservin | 0:9e9b7db60fd5 | 77 | offset += this->twist[i].serialize(outbuffer + offset); |
garyservin | 0:9e9b7db60fd5 | 78 | } |
garyservin | 0:9e9b7db60fd5 | 79 | *(outbuffer + offset + 0) = (this->wrench_length >> (8 * 0)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 80 | *(outbuffer + offset + 1) = (this->wrench_length >> (8 * 1)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 81 | *(outbuffer + offset + 2) = (this->wrench_length >> (8 * 2)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 82 | *(outbuffer + offset + 3) = (this->wrench_length >> (8 * 3)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 83 | offset += sizeof(this->wrench_length); |
garyservin | 0:9e9b7db60fd5 | 84 | for( uint32_t i = 0; i < wrench_length; i++){ |
garyservin | 0:9e9b7db60fd5 | 85 | offset += this->wrench[i].serialize(outbuffer + offset); |
garyservin | 0:9e9b7db60fd5 | 86 | } |
garyservin | 0:9e9b7db60fd5 | 87 | return offset; |
garyservin | 0:9e9b7db60fd5 | 88 | } |
garyservin | 0:9e9b7db60fd5 | 89 | |
garyservin | 0:9e9b7db60fd5 | 90 | virtual int deserialize(unsigned char *inbuffer) |
garyservin | 0:9e9b7db60fd5 | 91 | { |
garyservin | 0:9e9b7db60fd5 | 92 | int offset = 0; |
garyservin | 0:9e9b7db60fd5 | 93 | offset += this->header.deserialize(inbuffer + offset); |
garyservin | 0:9e9b7db60fd5 | 94 | uint32_t name_lengthT = ((uint32_t) (*(inbuffer + offset))); |
garyservin | 0:9e9b7db60fd5 | 95 | name_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:9e9b7db60fd5 | 96 | name_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:9e9b7db60fd5 | 97 | name_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:9e9b7db60fd5 | 98 | offset += sizeof(this->name_length); |
garyservin | 0:9e9b7db60fd5 | 99 | if(name_lengthT > name_length) |
garyservin | 0:9e9b7db60fd5 | 100 | this->name = (char**)realloc(this->name, name_lengthT * sizeof(char*)); |
garyservin | 0:9e9b7db60fd5 | 101 | name_length = name_lengthT; |
garyservin | 0:9e9b7db60fd5 | 102 | for( uint32_t i = 0; i < name_length; i++){ |
garyservin | 0:9e9b7db60fd5 | 103 | uint32_t length_st_name; |
garyservin | 0:9e9b7db60fd5 | 104 | arrToVar(length_st_name, (inbuffer + offset)); |
garyservin | 0:9e9b7db60fd5 | 105 | offset += 4; |
garyservin | 0:9e9b7db60fd5 | 106 | for(unsigned int k= offset; k< offset+length_st_name; ++k){ |
garyservin | 0:9e9b7db60fd5 | 107 | inbuffer[k-1]=inbuffer[k]; |
garyservin | 0:9e9b7db60fd5 | 108 | } |
garyservin | 0:9e9b7db60fd5 | 109 | inbuffer[offset+length_st_name-1]=0; |
garyservin | 0:9e9b7db60fd5 | 110 | this->st_name = (char *)(inbuffer + offset-1); |
garyservin | 0:9e9b7db60fd5 | 111 | offset += length_st_name; |
garyservin | 0:9e9b7db60fd5 | 112 | memcpy( &(this->name[i]), &(this->st_name), sizeof(char*)); |
garyservin | 0:9e9b7db60fd5 | 113 | } |
garyservin | 0:9e9b7db60fd5 | 114 | uint32_t pose_lengthT = ((uint32_t) (*(inbuffer + offset))); |
garyservin | 0:9e9b7db60fd5 | 115 | pose_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:9e9b7db60fd5 | 116 | pose_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:9e9b7db60fd5 | 117 | pose_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:9e9b7db60fd5 | 118 | offset += sizeof(this->pose_length); |
garyservin | 0:9e9b7db60fd5 | 119 | if(pose_lengthT > pose_length) |
garyservin | 0:9e9b7db60fd5 | 120 | this->pose = (geometry_msgs::Pose*)realloc(this->pose, pose_lengthT * sizeof(geometry_msgs::Pose)); |
garyservin | 0:9e9b7db60fd5 | 121 | pose_length = pose_lengthT; |
garyservin | 0:9e9b7db60fd5 | 122 | for( uint32_t i = 0; i < pose_length; i++){ |
garyservin | 0:9e9b7db60fd5 | 123 | offset += this->st_pose.deserialize(inbuffer + offset); |
garyservin | 0:9e9b7db60fd5 | 124 | memcpy( &(this->pose[i]), &(this->st_pose), sizeof(geometry_msgs::Pose)); |
garyservin | 0:9e9b7db60fd5 | 125 | } |
garyservin | 0:9e9b7db60fd5 | 126 | uint32_t twist_lengthT = ((uint32_t) (*(inbuffer + offset))); |
garyservin | 0:9e9b7db60fd5 | 127 | twist_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:9e9b7db60fd5 | 128 | twist_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:9e9b7db60fd5 | 129 | twist_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:9e9b7db60fd5 | 130 | offset += sizeof(this->twist_length); |
garyservin | 0:9e9b7db60fd5 | 131 | if(twist_lengthT > twist_length) |
garyservin | 0:9e9b7db60fd5 | 132 | this->twist = (geometry_msgs::Twist*)realloc(this->twist, twist_lengthT * sizeof(geometry_msgs::Twist)); |
garyservin | 0:9e9b7db60fd5 | 133 | twist_length = twist_lengthT; |
garyservin | 0:9e9b7db60fd5 | 134 | for( uint32_t i = 0; i < twist_length; i++){ |
garyservin | 0:9e9b7db60fd5 | 135 | offset += this->st_twist.deserialize(inbuffer + offset); |
garyservin | 0:9e9b7db60fd5 | 136 | memcpy( &(this->twist[i]), &(this->st_twist), sizeof(geometry_msgs::Twist)); |
garyservin | 0:9e9b7db60fd5 | 137 | } |
garyservin | 0:9e9b7db60fd5 | 138 | uint32_t wrench_lengthT = ((uint32_t) (*(inbuffer + offset))); |
garyservin | 0:9e9b7db60fd5 | 139 | wrench_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:9e9b7db60fd5 | 140 | wrench_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:9e9b7db60fd5 | 141 | wrench_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:9e9b7db60fd5 | 142 | offset += sizeof(this->wrench_length); |
garyservin | 0:9e9b7db60fd5 | 143 | if(wrench_lengthT > wrench_length) |
garyservin | 0:9e9b7db60fd5 | 144 | this->wrench = (geometry_msgs::Wrench*)realloc(this->wrench, wrench_lengthT * sizeof(geometry_msgs::Wrench)); |
garyservin | 0:9e9b7db60fd5 | 145 | wrench_length = wrench_lengthT; |
garyservin | 0:9e9b7db60fd5 | 146 | for( uint32_t i = 0; i < wrench_length; i++){ |
garyservin | 0:9e9b7db60fd5 | 147 | offset += this->st_wrench.deserialize(inbuffer + offset); |
garyservin | 0:9e9b7db60fd5 | 148 | memcpy( &(this->wrench[i]), &(this->st_wrench), sizeof(geometry_msgs::Wrench)); |
garyservin | 0:9e9b7db60fd5 | 149 | } |
garyservin | 0:9e9b7db60fd5 | 150 | return offset; |
garyservin | 0:9e9b7db60fd5 | 151 | } |
garyservin | 0:9e9b7db60fd5 | 152 | |
garyservin | 0:9e9b7db60fd5 | 153 | const char * getType(){ return "gazebo_msgs/WorldState"; }; |
garyservin | 0:9e9b7db60fd5 | 154 | const char * getMD5(){ return "de1a9de3ab7ba97ac0e9ec01a4eb481e"; }; |
garyservin | 0:9e9b7db60fd5 | 155 | |
garyservin | 0:9e9b7db60fd5 | 156 | }; |
garyservin | 0:9e9b7db60fd5 | 157 | |
garyservin | 0:9e9b7db60fd5 | 158 | } |
garyservin | 0:9e9b7db60fd5 | 159 | #endif |