It has only one change from original one. I added robotfeedback message on it.
Dependents: RobotFeedback mobileRobotITU
Fork of ros_lib_indigo by
gazebo_msgs/WorldState.h@4:80d9bee5079a, 2017-03-04 (annotated)
- Committer:
- randalthor
- Date:
- Sat Mar 04 14:07:56 2017 +0000
- Revision:
- 4:80d9bee5079a
- Parent:
- 0:fd24f7ca9688
fatih
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
garyservin | 0:fd24f7ca9688 | 1 | #ifndef _ROS_gazebo_msgs_WorldState_h |
garyservin | 0:fd24f7ca9688 | 2 | #define _ROS_gazebo_msgs_WorldState_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 | #include "std_msgs/Header.h" |
garyservin | 0:fd24f7ca9688 | 9 | #include "geometry_msgs/Pose.h" |
garyservin | 0:fd24f7ca9688 | 10 | #include "geometry_msgs/Twist.h" |
garyservin | 0:fd24f7ca9688 | 11 | #include "geometry_msgs/Wrench.h" |
garyservin | 0:fd24f7ca9688 | 12 | |
garyservin | 0:fd24f7ca9688 | 13 | namespace gazebo_msgs |
garyservin | 0:fd24f7ca9688 | 14 | { |
garyservin | 0:fd24f7ca9688 | 15 | |
garyservin | 0:fd24f7ca9688 | 16 | class WorldState : public ros::Msg |
garyservin | 0:fd24f7ca9688 | 17 | { |
garyservin | 0:fd24f7ca9688 | 18 | public: |
garyservin | 0:fd24f7ca9688 | 19 | std_msgs::Header header; |
garyservin | 0:fd24f7ca9688 | 20 | uint8_t name_length; |
garyservin | 0:fd24f7ca9688 | 21 | char* st_name; |
garyservin | 0:fd24f7ca9688 | 22 | char* * name; |
garyservin | 0:fd24f7ca9688 | 23 | uint8_t pose_length; |
garyservin | 0:fd24f7ca9688 | 24 | geometry_msgs::Pose st_pose; |
garyservin | 0:fd24f7ca9688 | 25 | geometry_msgs::Pose * pose; |
garyservin | 0:fd24f7ca9688 | 26 | uint8_t twist_length; |
garyservin | 0:fd24f7ca9688 | 27 | geometry_msgs::Twist st_twist; |
garyservin | 0:fd24f7ca9688 | 28 | geometry_msgs::Twist * twist; |
garyservin | 0:fd24f7ca9688 | 29 | uint8_t wrench_length; |
garyservin | 0:fd24f7ca9688 | 30 | geometry_msgs::Wrench st_wrench; |
garyservin | 0:fd24f7ca9688 | 31 | geometry_msgs::Wrench * wrench; |
garyservin | 0:fd24f7ca9688 | 32 | |
garyservin | 0:fd24f7ca9688 | 33 | WorldState(): |
garyservin | 0:fd24f7ca9688 | 34 | header(), |
garyservin | 0:fd24f7ca9688 | 35 | name_length(0), name(NULL), |
garyservin | 0:fd24f7ca9688 | 36 | pose_length(0), pose(NULL), |
garyservin | 0:fd24f7ca9688 | 37 | twist_length(0), twist(NULL), |
garyservin | 0:fd24f7ca9688 | 38 | wrench_length(0), wrench(NULL) |
garyservin | 0:fd24f7ca9688 | 39 | { |
garyservin | 0:fd24f7ca9688 | 40 | } |
garyservin | 0:fd24f7ca9688 | 41 | |
garyservin | 0:fd24f7ca9688 | 42 | virtual int serialize(unsigned char *outbuffer) const |
garyservin | 0:fd24f7ca9688 | 43 | { |
garyservin | 0:fd24f7ca9688 | 44 | int offset = 0; |
garyservin | 0:fd24f7ca9688 | 45 | offset += this->header.serialize(outbuffer + offset); |
garyservin | 0:fd24f7ca9688 | 46 | *(outbuffer + offset++) = name_length; |
garyservin | 0:fd24f7ca9688 | 47 | *(outbuffer + offset++) = 0; |
garyservin | 0:fd24f7ca9688 | 48 | *(outbuffer + offset++) = 0; |
garyservin | 0:fd24f7ca9688 | 49 | *(outbuffer + offset++) = 0; |
garyservin | 0:fd24f7ca9688 | 50 | for( uint8_t i = 0; i < name_length; i++){ |
garyservin | 0:fd24f7ca9688 | 51 | uint32_t length_namei = strlen(this->name[i]); |
garyservin | 0:fd24f7ca9688 | 52 | memcpy(outbuffer + offset, &length_namei, sizeof(uint32_t)); |
garyservin | 0:fd24f7ca9688 | 53 | offset += 4; |
garyservin | 0:fd24f7ca9688 | 54 | memcpy(outbuffer + offset, this->name[i], length_namei); |
garyservin | 0:fd24f7ca9688 | 55 | offset += length_namei; |
garyservin | 0:fd24f7ca9688 | 56 | } |
garyservin | 0:fd24f7ca9688 | 57 | *(outbuffer + offset++) = pose_length; |
garyservin | 0:fd24f7ca9688 | 58 | *(outbuffer + offset++) = 0; |
garyservin | 0:fd24f7ca9688 | 59 | *(outbuffer + offset++) = 0; |
garyservin | 0:fd24f7ca9688 | 60 | *(outbuffer + offset++) = 0; |
garyservin | 0:fd24f7ca9688 | 61 | for( uint8_t i = 0; i < pose_length; i++){ |
garyservin | 0:fd24f7ca9688 | 62 | offset += this->pose[i].serialize(outbuffer + offset); |
garyservin | 0:fd24f7ca9688 | 63 | } |
garyservin | 0:fd24f7ca9688 | 64 | *(outbuffer + offset++) = twist_length; |
garyservin | 0:fd24f7ca9688 | 65 | *(outbuffer + offset++) = 0; |
garyservin | 0:fd24f7ca9688 | 66 | *(outbuffer + offset++) = 0; |
garyservin | 0:fd24f7ca9688 | 67 | *(outbuffer + offset++) = 0; |
garyservin | 0:fd24f7ca9688 | 68 | for( uint8_t i = 0; i < twist_length; i++){ |
garyservin | 0:fd24f7ca9688 | 69 | offset += this->twist[i].serialize(outbuffer + offset); |
garyservin | 0:fd24f7ca9688 | 70 | } |
garyservin | 0:fd24f7ca9688 | 71 | *(outbuffer + offset++) = wrench_length; |
garyservin | 0:fd24f7ca9688 | 72 | *(outbuffer + offset++) = 0; |
garyservin | 0:fd24f7ca9688 | 73 | *(outbuffer + offset++) = 0; |
garyservin | 0:fd24f7ca9688 | 74 | *(outbuffer + offset++) = 0; |
garyservin | 0:fd24f7ca9688 | 75 | for( uint8_t i = 0; i < wrench_length; i++){ |
garyservin | 0:fd24f7ca9688 | 76 | offset += this->wrench[i].serialize(outbuffer + offset); |
garyservin | 0:fd24f7ca9688 | 77 | } |
garyservin | 0:fd24f7ca9688 | 78 | return offset; |
garyservin | 0:fd24f7ca9688 | 79 | } |
garyservin | 0:fd24f7ca9688 | 80 | |
garyservin | 0:fd24f7ca9688 | 81 | virtual int deserialize(unsigned char *inbuffer) |
garyservin | 0:fd24f7ca9688 | 82 | { |
garyservin | 0:fd24f7ca9688 | 83 | int offset = 0; |
garyservin | 0:fd24f7ca9688 | 84 | offset += this->header.deserialize(inbuffer + offset); |
garyservin | 0:fd24f7ca9688 | 85 | uint8_t name_lengthT = *(inbuffer + offset++); |
garyservin | 0:fd24f7ca9688 | 86 | if(name_lengthT > name_length) |
garyservin | 0:fd24f7ca9688 | 87 | this->name = (char**)realloc(this->name, name_lengthT * sizeof(char*)); |
garyservin | 0:fd24f7ca9688 | 88 | offset += 3; |
garyservin | 0:fd24f7ca9688 | 89 | name_length = name_lengthT; |
garyservin | 0:fd24f7ca9688 | 90 | for( uint8_t i = 0; i < name_length; i++){ |
garyservin | 0:fd24f7ca9688 | 91 | uint32_t length_st_name; |
garyservin | 0:fd24f7ca9688 | 92 | memcpy(&length_st_name, (inbuffer + offset), sizeof(uint32_t)); |
garyservin | 0:fd24f7ca9688 | 93 | offset += 4; |
garyservin | 0:fd24f7ca9688 | 94 | for(unsigned int k= offset; k< offset+length_st_name; ++k){ |
garyservin | 0:fd24f7ca9688 | 95 | inbuffer[k-1]=inbuffer[k]; |
garyservin | 0:fd24f7ca9688 | 96 | } |
garyservin | 0:fd24f7ca9688 | 97 | inbuffer[offset+length_st_name-1]=0; |
garyservin | 0:fd24f7ca9688 | 98 | this->st_name = (char *)(inbuffer + offset-1); |
garyservin | 0:fd24f7ca9688 | 99 | offset += length_st_name; |
garyservin | 0:fd24f7ca9688 | 100 | memcpy( &(this->name[i]), &(this->st_name), sizeof(char*)); |
garyservin | 0:fd24f7ca9688 | 101 | } |
garyservin | 0:fd24f7ca9688 | 102 | uint8_t pose_lengthT = *(inbuffer + offset++); |
garyservin | 0:fd24f7ca9688 | 103 | if(pose_lengthT > pose_length) |
garyservin | 0:fd24f7ca9688 | 104 | this->pose = (geometry_msgs::Pose*)realloc(this->pose, pose_lengthT * sizeof(geometry_msgs::Pose)); |
garyservin | 0:fd24f7ca9688 | 105 | offset += 3; |
garyservin | 0:fd24f7ca9688 | 106 | pose_length = pose_lengthT; |
garyservin | 0:fd24f7ca9688 | 107 | for( uint8_t i = 0; i < pose_length; i++){ |
garyservin | 0:fd24f7ca9688 | 108 | offset += this->st_pose.deserialize(inbuffer + offset); |
garyservin | 0:fd24f7ca9688 | 109 | memcpy( &(this->pose[i]), &(this->st_pose), sizeof(geometry_msgs::Pose)); |
garyservin | 0:fd24f7ca9688 | 110 | } |
garyservin | 0:fd24f7ca9688 | 111 | uint8_t twist_lengthT = *(inbuffer + offset++); |
garyservin | 0:fd24f7ca9688 | 112 | if(twist_lengthT > twist_length) |
garyservin | 0:fd24f7ca9688 | 113 | this->twist = (geometry_msgs::Twist*)realloc(this->twist, twist_lengthT * sizeof(geometry_msgs::Twist)); |
garyservin | 0:fd24f7ca9688 | 114 | offset += 3; |
garyservin | 0:fd24f7ca9688 | 115 | twist_length = twist_lengthT; |
garyservin | 0:fd24f7ca9688 | 116 | for( uint8_t i = 0; i < twist_length; i++){ |
garyservin | 0:fd24f7ca9688 | 117 | offset += this->st_twist.deserialize(inbuffer + offset); |
garyservin | 0:fd24f7ca9688 | 118 | memcpy( &(this->twist[i]), &(this->st_twist), sizeof(geometry_msgs::Twist)); |
garyservin | 0:fd24f7ca9688 | 119 | } |
garyservin | 0:fd24f7ca9688 | 120 | uint8_t wrench_lengthT = *(inbuffer + offset++); |
garyservin | 0:fd24f7ca9688 | 121 | if(wrench_lengthT > wrench_length) |
garyservin | 0:fd24f7ca9688 | 122 | this->wrench = (geometry_msgs::Wrench*)realloc(this->wrench, wrench_lengthT * sizeof(geometry_msgs::Wrench)); |
garyservin | 0:fd24f7ca9688 | 123 | offset += 3; |
garyservin | 0:fd24f7ca9688 | 124 | wrench_length = wrench_lengthT; |
garyservin | 0:fd24f7ca9688 | 125 | for( uint8_t i = 0; i < wrench_length; i++){ |
garyservin | 0:fd24f7ca9688 | 126 | offset += this->st_wrench.deserialize(inbuffer + offset); |
garyservin | 0:fd24f7ca9688 | 127 | memcpy( &(this->wrench[i]), &(this->st_wrench), sizeof(geometry_msgs::Wrench)); |
garyservin | 0:fd24f7ca9688 | 128 | } |
garyservin | 0:fd24f7ca9688 | 129 | return offset; |
garyservin | 0:fd24f7ca9688 | 130 | } |
garyservin | 0:fd24f7ca9688 | 131 | |
garyservin | 0:fd24f7ca9688 | 132 | const char * getType(){ return "gazebo_msgs/WorldState"; }; |
garyservin | 0:fd24f7ca9688 | 133 | const char * getMD5(){ return "de1a9de3ab7ba97ac0e9ec01a4eb481e"; }; |
garyservin | 0:fd24f7ca9688 | 134 | |
garyservin | 0:fd24f7ca9688 | 135 | }; |
garyservin | 0:fd24f7ca9688 | 136 | |
garyservin | 0:fd24f7ca9688 | 137 | } |
garyservin | 0:fd24f7ca9688 | 138 | #endif |