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