hairo

Dependencies:   mbed BufferedSerial

Committer:
garyservin
Date:
Sat Dec 31 00:48:34 2016 +0000
Revision:
0:9e9b7db60fd5
Initial commit, generated based on a clean kinetic-desktop-full

Who changed what in which revision?

UserRevisionLine numberNew contents of line
garyservin 0:9e9b7db60fd5 1 #ifndef _ROS_sensor_msgs_MultiDOFJointState_h
garyservin 0:9e9b7db60fd5 2 #define _ROS_sensor_msgs_MultiDOFJointState_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/Transform.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 sensor_msgs
garyservin 0:9e9b7db60fd5 14 {
garyservin 0:9e9b7db60fd5 15
garyservin 0:9e9b7db60fd5 16 class MultiDOFJointState : 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 joint_names_length;
garyservin 0:9e9b7db60fd5 22 typedef char* _joint_names_type;
garyservin 0:9e9b7db60fd5 23 _joint_names_type st_joint_names;
garyservin 0:9e9b7db60fd5 24 _joint_names_type * joint_names;
garyservin 0:9e9b7db60fd5 25 uint32_t transforms_length;
garyservin 0:9e9b7db60fd5 26 typedef geometry_msgs::Transform _transforms_type;
garyservin 0:9e9b7db60fd5 27 _transforms_type st_transforms;
garyservin 0:9e9b7db60fd5 28 _transforms_type * transforms;
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 MultiDOFJointState():
garyservin 0:9e9b7db60fd5 39 header(),
garyservin 0:9e9b7db60fd5 40 joint_names_length(0), joint_names(NULL),
garyservin 0:9e9b7db60fd5 41 transforms_length(0), transforms(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->joint_names_length >> (8 * 0)) & 0xFF;
garyservin 0:9e9b7db60fd5 52 *(outbuffer + offset + 1) = (this->joint_names_length >> (8 * 1)) & 0xFF;
garyservin 0:9e9b7db60fd5 53 *(outbuffer + offset + 2) = (this->joint_names_length >> (8 * 2)) & 0xFF;
garyservin 0:9e9b7db60fd5 54 *(outbuffer + offset + 3) = (this->joint_names_length >> (8 * 3)) & 0xFF;
garyservin 0:9e9b7db60fd5 55 offset += sizeof(this->joint_names_length);
garyservin 0:9e9b7db60fd5 56 for( uint32_t i = 0; i < joint_names_length; i++){
garyservin 0:9e9b7db60fd5 57 uint32_t length_joint_namesi = strlen(this->joint_names[i]);
garyservin 0:9e9b7db60fd5 58 varToArr(outbuffer + offset, length_joint_namesi);
garyservin 0:9e9b7db60fd5 59 offset += 4;
garyservin 0:9e9b7db60fd5 60 memcpy(outbuffer + offset, this->joint_names[i], length_joint_namesi);
garyservin 0:9e9b7db60fd5 61 offset += length_joint_namesi;
garyservin 0:9e9b7db60fd5 62 }
garyservin 0:9e9b7db60fd5 63 *(outbuffer + offset + 0) = (this->transforms_length >> (8 * 0)) & 0xFF;
garyservin 0:9e9b7db60fd5 64 *(outbuffer + offset + 1) = (this->transforms_length >> (8 * 1)) & 0xFF;
garyservin 0:9e9b7db60fd5 65 *(outbuffer + offset + 2) = (this->transforms_length >> (8 * 2)) & 0xFF;
garyservin 0:9e9b7db60fd5 66 *(outbuffer + offset + 3) = (this->transforms_length >> (8 * 3)) & 0xFF;
garyservin 0:9e9b7db60fd5 67 offset += sizeof(this->transforms_length);
garyservin 0:9e9b7db60fd5 68 for( uint32_t i = 0; i < transforms_length; i++){
garyservin 0:9e9b7db60fd5 69 offset += this->transforms[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 joint_names_lengthT = ((uint32_t) (*(inbuffer + offset)));
garyservin 0:9e9b7db60fd5 95 joint_names_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
garyservin 0:9e9b7db60fd5 96 joint_names_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
garyservin 0:9e9b7db60fd5 97 joint_names_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
garyservin 0:9e9b7db60fd5 98 offset += sizeof(this->joint_names_length);
garyservin 0:9e9b7db60fd5 99 if(joint_names_lengthT > joint_names_length)
garyservin 0:9e9b7db60fd5 100 this->joint_names = (char**)realloc(this->joint_names, joint_names_lengthT * sizeof(char*));
garyservin 0:9e9b7db60fd5 101 joint_names_length = joint_names_lengthT;
garyservin 0:9e9b7db60fd5 102 for( uint32_t i = 0; i < joint_names_length; i++){
garyservin 0:9e9b7db60fd5 103 uint32_t length_st_joint_names;
garyservin 0:9e9b7db60fd5 104 arrToVar(length_st_joint_names, (inbuffer + offset));
garyservin 0:9e9b7db60fd5 105 offset += 4;
garyservin 0:9e9b7db60fd5 106 for(unsigned int k= offset; k< offset+length_st_joint_names; ++k){
garyservin 0:9e9b7db60fd5 107 inbuffer[k-1]=inbuffer[k];
garyservin 0:9e9b7db60fd5 108 }
garyservin 0:9e9b7db60fd5 109 inbuffer[offset+length_st_joint_names-1]=0;
garyservin 0:9e9b7db60fd5 110 this->st_joint_names = (char *)(inbuffer + offset-1);
garyservin 0:9e9b7db60fd5 111 offset += length_st_joint_names;
garyservin 0:9e9b7db60fd5 112 memcpy( &(this->joint_names[i]), &(this->st_joint_names), sizeof(char*));
garyservin 0:9e9b7db60fd5 113 }
garyservin 0:9e9b7db60fd5 114 uint32_t transforms_lengthT = ((uint32_t) (*(inbuffer + offset)));
garyservin 0:9e9b7db60fd5 115 transforms_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
garyservin 0:9e9b7db60fd5 116 transforms_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
garyservin 0:9e9b7db60fd5 117 transforms_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
garyservin 0:9e9b7db60fd5 118 offset += sizeof(this->transforms_length);
garyservin 0:9e9b7db60fd5 119 if(transforms_lengthT > transforms_length)
garyservin 0:9e9b7db60fd5 120 this->transforms = (geometry_msgs::Transform*)realloc(this->transforms, transforms_lengthT * sizeof(geometry_msgs::Transform));
garyservin 0:9e9b7db60fd5 121 transforms_length = transforms_lengthT;
garyservin 0:9e9b7db60fd5 122 for( uint32_t i = 0; i < transforms_length; i++){
garyservin 0:9e9b7db60fd5 123 offset += this->st_transforms.deserialize(inbuffer + offset);
garyservin 0:9e9b7db60fd5 124 memcpy( &(this->transforms[i]), &(this->st_transforms), sizeof(geometry_msgs::Transform));
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 "sensor_msgs/MultiDOFJointState"; };
garyservin 0:9e9b7db60fd5 154 const char * getMD5(){ return "690f272f0640d2631c305eeb8301e59d"; };
garyservin 0:9e9b7db60fd5 155
garyservin 0:9e9b7db60fd5 156 };
garyservin 0:9e9b7db60fd5 157
garyservin 0:9e9b7db60fd5 158 }
garyservin 0:9e9b7db60fd5 159 #endif