ros melodic library with custom message
Dependents: Robot_team1_QEI_Douglas Robot_team1
ros_lib/gazebo_msgs/LinkStates.h@3:b964e3f71102, 2019-12-03 (annotated)
- Committer:
- florine_van
- Date:
- Tue Dec 03 09:39:29 2019 +0000
- Revision:
- 3:b964e3f71102
- Parent:
- 0:020db18a476d
Clean code and remove unused lines
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
scarter1 | 0:020db18a476d | 1 | #ifndef _ROS_gazebo_msgs_LinkStates_h |
scarter1 | 0:020db18a476d | 2 | #define _ROS_gazebo_msgs_LinkStates_h |
scarter1 | 0:020db18a476d | 3 | |
scarter1 | 0:020db18a476d | 4 | #include <stdint.h> |
scarter1 | 0:020db18a476d | 5 | #include <string.h> |
scarter1 | 0:020db18a476d | 6 | #include <stdlib.h> |
scarter1 | 0:020db18a476d | 7 | #include "ros/msg.h" |
scarter1 | 0:020db18a476d | 8 | #include "geometry_msgs/Pose.h" |
scarter1 | 0:020db18a476d | 9 | #include "geometry_msgs/Twist.h" |
scarter1 | 0:020db18a476d | 10 | |
scarter1 | 0:020db18a476d | 11 | namespace gazebo_msgs |
scarter1 | 0:020db18a476d | 12 | { |
scarter1 | 0:020db18a476d | 13 | |
scarter1 | 0:020db18a476d | 14 | class LinkStates : public ros::Msg |
scarter1 | 0:020db18a476d | 15 | { |
scarter1 | 0:020db18a476d | 16 | public: |
scarter1 | 0:020db18a476d | 17 | uint32_t name_length; |
scarter1 | 0:020db18a476d | 18 | typedef char* _name_type; |
scarter1 | 0:020db18a476d | 19 | _name_type st_name; |
scarter1 | 0:020db18a476d | 20 | _name_type * name; |
scarter1 | 0:020db18a476d | 21 | uint32_t pose_length; |
scarter1 | 0:020db18a476d | 22 | typedef geometry_msgs::Pose _pose_type; |
scarter1 | 0:020db18a476d | 23 | _pose_type st_pose; |
scarter1 | 0:020db18a476d | 24 | _pose_type * pose; |
scarter1 | 0:020db18a476d | 25 | uint32_t twist_length; |
scarter1 | 0:020db18a476d | 26 | typedef geometry_msgs::Twist _twist_type; |
scarter1 | 0:020db18a476d | 27 | _twist_type st_twist; |
scarter1 | 0:020db18a476d | 28 | _twist_type * twist; |
scarter1 | 0:020db18a476d | 29 | |
scarter1 | 0:020db18a476d | 30 | LinkStates(): |
scarter1 | 0:020db18a476d | 31 | name_length(0), name(NULL), |
scarter1 | 0:020db18a476d | 32 | pose_length(0), pose(NULL), |
scarter1 | 0:020db18a476d | 33 | twist_length(0), twist(NULL) |
scarter1 | 0:020db18a476d | 34 | { |
scarter1 | 0:020db18a476d | 35 | } |
scarter1 | 0:020db18a476d | 36 | |
scarter1 | 0:020db18a476d | 37 | virtual int serialize(unsigned char *outbuffer) const |
scarter1 | 0:020db18a476d | 38 | { |
scarter1 | 0:020db18a476d | 39 | int offset = 0; |
scarter1 | 0:020db18a476d | 40 | *(outbuffer + offset + 0) = (this->name_length >> (8 * 0)) & 0xFF; |
scarter1 | 0:020db18a476d | 41 | *(outbuffer + offset + 1) = (this->name_length >> (8 * 1)) & 0xFF; |
scarter1 | 0:020db18a476d | 42 | *(outbuffer + offset + 2) = (this->name_length >> (8 * 2)) & 0xFF; |
scarter1 | 0:020db18a476d | 43 | *(outbuffer + offset + 3) = (this->name_length >> (8 * 3)) & 0xFF; |
scarter1 | 0:020db18a476d | 44 | offset += sizeof(this->name_length); |
scarter1 | 0:020db18a476d | 45 | for( uint32_t i = 0; i < name_length; i++){ |
scarter1 | 0:020db18a476d | 46 | uint32_t length_namei = strlen(this->name[i]); |
scarter1 | 0:020db18a476d | 47 | varToArr(outbuffer + offset, length_namei); |
scarter1 | 0:020db18a476d | 48 | offset += 4; |
scarter1 | 0:020db18a476d | 49 | memcpy(outbuffer + offset, this->name[i], length_namei); |
scarter1 | 0:020db18a476d | 50 | offset += length_namei; |
scarter1 | 0:020db18a476d | 51 | } |
scarter1 | 0:020db18a476d | 52 | *(outbuffer + offset + 0) = (this->pose_length >> (8 * 0)) & 0xFF; |
scarter1 | 0:020db18a476d | 53 | *(outbuffer + offset + 1) = (this->pose_length >> (8 * 1)) & 0xFF; |
scarter1 | 0:020db18a476d | 54 | *(outbuffer + offset + 2) = (this->pose_length >> (8 * 2)) & 0xFF; |
scarter1 | 0:020db18a476d | 55 | *(outbuffer + offset + 3) = (this->pose_length >> (8 * 3)) & 0xFF; |
scarter1 | 0:020db18a476d | 56 | offset += sizeof(this->pose_length); |
scarter1 | 0:020db18a476d | 57 | for( uint32_t i = 0; i < pose_length; i++){ |
scarter1 | 0:020db18a476d | 58 | offset += this->pose[i].serialize(outbuffer + offset); |
scarter1 | 0:020db18a476d | 59 | } |
scarter1 | 0:020db18a476d | 60 | *(outbuffer + offset + 0) = (this->twist_length >> (8 * 0)) & 0xFF; |
scarter1 | 0:020db18a476d | 61 | *(outbuffer + offset + 1) = (this->twist_length >> (8 * 1)) & 0xFF; |
scarter1 | 0:020db18a476d | 62 | *(outbuffer + offset + 2) = (this->twist_length >> (8 * 2)) & 0xFF; |
scarter1 | 0:020db18a476d | 63 | *(outbuffer + offset + 3) = (this->twist_length >> (8 * 3)) & 0xFF; |
scarter1 | 0:020db18a476d | 64 | offset += sizeof(this->twist_length); |
scarter1 | 0:020db18a476d | 65 | for( uint32_t i = 0; i < twist_length; i++){ |
scarter1 | 0:020db18a476d | 66 | offset += this->twist[i].serialize(outbuffer + offset); |
scarter1 | 0:020db18a476d | 67 | } |
scarter1 | 0:020db18a476d | 68 | return offset; |
scarter1 | 0:020db18a476d | 69 | } |
scarter1 | 0:020db18a476d | 70 | |
scarter1 | 0:020db18a476d | 71 | virtual int deserialize(unsigned char *inbuffer) |
scarter1 | 0:020db18a476d | 72 | { |
scarter1 | 0:020db18a476d | 73 | int offset = 0; |
scarter1 | 0:020db18a476d | 74 | uint32_t name_lengthT = ((uint32_t) (*(inbuffer + offset))); |
scarter1 | 0:020db18a476d | 75 | name_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
scarter1 | 0:020db18a476d | 76 | name_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
scarter1 | 0:020db18a476d | 77 | name_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
scarter1 | 0:020db18a476d | 78 | offset += sizeof(this->name_length); |
scarter1 | 0:020db18a476d | 79 | if(name_lengthT > name_length) |
scarter1 | 0:020db18a476d | 80 | this->name = (char**)realloc(this->name, name_lengthT * sizeof(char*)); |
scarter1 | 0:020db18a476d | 81 | name_length = name_lengthT; |
scarter1 | 0:020db18a476d | 82 | for( uint32_t i = 0; i < name_length; i++){ |
scarter1 | 0:020db18a476d | 83 | uint32_t length_st_name; |
scarter1 | 0:020db18a476d | 84 | arrToVar(length_st_name, (inbuffer + offset)); |
scarter1 | 0:020db18a476d | 85 | offset += 4; |
scarter1 | 0:020db18a476d | 86 | for(unsigned int k= offset; k< offset+length_st_name; ++k){ |
scarter1 | 0:020db18a476d | 87 | inbuffer[k-1]=inbuffer[k]; |
scarter1 | 0:020db18a476d | 88 | } |
scarter1 | 0:020db18a476d | 89 | inbuffer[offset+length_st_name-1]=0; |
scarter1 | 0:020db18a476d | 90 | this->st_name = (char *)(inbuffer + offset-1); |
scarter1 | 0:020db18a476d | 91 | offset += length_st_name; |
scarter1 | 0:020db18a476d | 92 | memcpy( &(this->name[i]), &(this->st_name), sizeof(char*)); |
scarter1 | 0:020db18a476d | 93 | } |
scarter1 | 0:020db18a476d | 94 | uint32_t pose_lengthT = ((uint32_t) (*(inbuffer + offset))); |
scarter1 | 0:020db18a476d | 95 | pose_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
scarter1 | 0:020db18a476d | 96 | pose_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
scarter1 | 0:020db18a476d | 97 | pose_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
scarter1 | 0:020db18a476d | 98 | offset += sizeof(this->pose_length); |
scarter1 | 0:020db18a476d | 99 | if(pose_lengthT > pose_length) |
scarter1 | 0:020db18a476d | 100 | this->pose = (geometry_msgs::Pose*)realloc(this->pose, pose_lengthT * sizeof(geometry_msgs::Pose)); |
scarter1 | 0:020db18a476d | 101 | pose_length = pose_lengthT; |
scarter1 | 0:020db18a476d | 102 | for( uint32_t i = 0; i < pose_length; i++){ |
scarter1 | 0:020db18a476d | 103 | offset += this->st_pose.deserialize(inbuffer + offset); |
scarter1 | 0:020db18a476d | 104 | memcpy( &(this->pose[i]), &(this->st_pose), sizeof(geometry_msgs::Pose)); |
scarter1 | 0:020db18a476d | 105 | } |
scarter1 | 0:020db18a476d | 106 | uint32_t twist_lengthT = ((uint32_t) (*(inbuffer + offset))); |
scarter1 | 0:020db18a476d | 107 | twist_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
scarter1 | 0:020db18a476d | 108 | twist_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
scarter1 | 0:020db18a476d | 109 | twist_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
scarter1 | 0:020db18a476d | 110 | offset += sizeof(this->twist_length); |
scarter1 | 0:020db18a476d | 111 | if(twist_lengthT > twist_length) |
scarter1 | 0:020db18a476d | 112 | this->twist = (geometry_msgs::Twist*)realloc(this->twist, twist_lengthT * sizeof(geometry_msgs::Twist)); |
scarter1 | 0:020db18a476d | 113 | twist_length = twist_lengthT; |
scarter1 | 0:020db18a476d | 114 | for( uint32_t i = 0; i < twist_length; i++){ |
scarter1 | 0:020db18a476d | 115 | offset += this->st_twist.deserialize(inbuffer + offset); |
scarter1 | 0:020db18a476d | 116 | memcpy( &(this->twist[i]), &(this->st_twist), sizeof(geometry_msgs::Twist)); |
scarter1 | 0:020db18a476d | 117 | } |
scarter1 | 0:020db18a476d | 118 | return offset; |
scarter1 | 0:020db18a476d | 119 | } |
scarter1 | 0:020db18a476d | 120 | |
scarter1 | 0:020db18a476d | 121 | const char * getType(){ return "gazebo_msgs/LinkStates"; }; |
scarter1 | 0:020db18a476d | 122 | const char * getMD5(){ return "48c080191eb15c41858319b4d8a609c2"; }; |
scarter1 | 0:020db18a476d | 123 | |
scarter1 | 0:020db18a476d | 124 | }; |
scarter1 | 0:020db18a476d | 125 | |
scarter1 | 0:020db18a476d | 126 | } |
scarter1 | 0:020db18a476d | 127 | #endif |