ros melodic library with custom message

Dependents:   Robot_team1_QEI_Douglas Robot_team1

Committer:
scarter1
Date:
Wed Oct 30 14:59:49 2019 +0000
Revision:
0:020db18a476d
melodic library;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
scarter1 0:020db18a476d 1 #ifndef _ROS_control_msgs_JointJog_h
scarter1 0:020db18a476d 2 #define _ROS_control_msgs_JointJog_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 "std_msgs/Header.h"
scarter1 0:020db18a476d 9
scarter1 0:020db18a476d 10 namespace control_msgs
scarter1 0:020db18a476d 11 {
scarter1 0:020db18a476d 12
scarter1 0:020db18a476d 13 class JointJog : public ros::Msg
scarter1 0:020db18a476d 14 {
scarter1 0:020db18a476d 15 public:
scarter1 0:020db18a476d 16 typedef std_msgs::Header _header_type;
scarter1 0:020db18a476d 17 _header_type header;
scarter1 0:020db18a476d 18 uint32_t joint_names_length;
scarter1 0:020db18a476d 19 typedef char* _joint_names_type;
scarter1 0:020db18a476d 20 _joint_names_type st_joint_names;
scarter1 0:020db18a476d 21 _joint_names_type * joint_names;
scarter1 0:020db18a476d 22 uint32_t displacements_length;
scarter1 0:020db18a476d 23 typedef double _displacements_type;
scarter1 0:020db18a476d 24 _displacements_type st_displacements;
scarter1 0:020db18a476d 25 _displacements_type * displacements;
scarter1 0:020db18a476d 26 uint32_t velocities_length;
scarter1 0:020db18a476d 27 typedef double _velocities_type;
scarter1 0:020db18a476d 28 _velocities_type st_velocities;
scarter1 0:020db18a476d 29 _velocities_type * velocities;
scarter1 0:020db18a476d 30 typedef double _duration_type;
scarter1 0:020db18a476d 31 _duration_type duration;
scarter1 0:020db18a476d 32
scarter1 0:020db18a476d 33 JointJog():
scarter1 0:020db18a476d 34 header(),
scarter1 0:020db18a476d 35 joint_names_length(0), joint_names(NULL),
scarter1 0:020db18a476d 36 displacements_length(0), displacements(NULL),
scarter1 0:020db18a476d 37 velocities_length(0), velocities(NULL),
scarter1 0:020db18a476d 38 duration(0)
scarter1 0:020db18a476d 39 {
scarter1 0:020db18a476d 40 }
scarter1 0:020db18a476d 41
scarter1 0:020db18a476d 42 virtual int serialize(unsigned char *outbuffer) const
scarter1 0:020db18a476d 43 {
scarter1 0:020db18a476d 44 int offset = 0;
scarter1 0:020db18a476d 45 offset += this->header.serialize(outbuffer + offset);
scarter1 0:020db18a476d 46 *(outbuffer + offset + 0) = (this->joint_names_length >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 47 *(outbuffer + offset + 1) = (this->joint_names_length >> (8 * 1)) & 0xFF;
scarter1 0:020db18a476d 48 *(outbuffer + offset + 2) = (this->joint_names_length >> (8 * 2)) & 0xFF;
scarter1 0:020db18a476d 49 *(outbuffer + offset + 3) = (this->joint_names_length >> (8 * 3)) & 0xFF;
scarter1 0:020db18a476d 50 offset += sizeof(this->joint_names_length);
scarter1 0:020db18a476d 51 for( uint32_t i = 0; i < joint_names_length; i++){
scarter1 0:020db18a476d 52 uint32_t length_joint_namesi = strlen(this->joint_names[i]);
scarter1 0:020db18a476d 53 varToArr(outbuffer + offset, length_joint_namesi);
scarter1 0:020db18a476d 54 offset += 4;
scarter1 0:020db18a476d 55 memcpy(outbuffer + offset, this->joint_names[i], length_joint_namesi);
scarter1 0:020db18a476d 56 offset += length_joint_namesi;
scarter1 0:020db18a476d 57 }
scarter1 0:020db18a476d 58 *(outbuffer + offset + 0) = (this->displacements_length >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 59 *(outbuffer + offset + 1) = (this->displacements_length >> (8 * 1)) & 0xFF;
scarter1 0:020db18a476d 60 *(outbuffer + offset + 2) = (this->displacements_length >> (8 * 2)) & 0xFF;
scarter1 0:020db18a476d 61 *(outbuffer + offset + 3) = (this->displacements_length >> (8 * 3)) & 0xFF;
scarter1 0:020db18a476d 62 offset += sizeof(this->displacements_length);
scarter1 0:020db18a476d 63 for( uint32_t i = 0; i < displacements_length; i++){
scarter1 0:020db18a476d 64 union {
scarter1 0:020db18a476d 65 double real;
scarter1 0:020db18a476d 66 uint64_t base;
scarter1 0:020db18a476d 67 } u_displacementsi;
scarter1 0:020db18a476d 68 u_displacementsi.real = this->displacements[i];
scarter1 0:020db18a476d 69 *(outbuffer + offset + 0) = (u_displacementsi.base >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 70 *(outbuffer + offset + 1) = (u_displacementsi.base >> (8 * 1)) & 0xFF;
scarter1 0:020db18a476d 71 *(outbuffer + offset + 2) = (u_displacementsi.base >> (8 * 2)) & 0xFF;
scarter1 0:020db18a476d 72 *(outbuffer + offset + 3) = (u_displacementsi.base >> (8 * 3)) & 0xFF;
scarter1 0:020db18a476d 73 *(outbuffer + offset + 4) = (u_displacementsi.base >> (8 * 4)) & 0xFF;
scarter1 0:020db18a476d 74 *(outbuffer + offset + 5) = (u_displacementsi.base >> (8 * 5)) & 0xFF;
scarter1 0:020db18a476d 75 *(outbuffer + offset + 6) = (u_displacementsi.base >> (8 * 6)) & 0xFF;
scarter1 0:020db18a476d 76 *(outbuffer + offset + 7) = (u_displacementsi.base >> (8 * 7)) & 0xFF;
scarter1 0:020db18a476d 77 offset += sizeof(this->displacements[i]);
scarter1 0:020db18a476d 78 }
scarter1 0:020db18a476d 79 *(outbuffer + offset + 0) = (this->velocities_length >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 80 *(outbuffer + offset + 1) = (this->velocities_length >> (8 * 1)) & 0xFF;
scarter1 0:020db18a476d 81 *(outbuffer + offset + 2) = (this->velocities_length >> (8 * 2)) & 0xFF;
scarter1 0:020db18a476d 82 *(outbuffer + offset + 3) = (this->velocities_length >> (8 * 3)) & 0xFF;
scarter1 0:020db18a476d 83 offset += sizeof(this->velocities_length);
scarter1 0:020db18a476d 84 for( uint32_t i = 0; i < velocities_length; i++){
scarter1 0:020db18a476d 85 union {
scarter1 0:020db18a476d 86 double real;
scarter1 0:020db18a476d 87 uint64_t base;
scarter1 0:020db18a476d 88 } u_velocitiesi;
scarter1 0:020db18a476d 89 u_velocitiesi.real = this->velocities[i];
scarter1 0:020db18a476d 90 *(outbuffer + offset + 0) = (u_velocitiesi.base >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 91 *(outbuffer + offset + 1) = (u_velocitiesi.base >> (8 * 1)) & 0xFF;
scarter1 0:020db18a476d 92 *(outbuffer + offset + 2) = (u_velocitiesi.base >> (8 * 2)) & 0xFF;
scarter1 0:020db18a476d 93 *(outbuffer + offset + 3) = (u_velocitiesi.base >> (8 * 3)) & 0xFF;
scarter1 0:020db18a476d 94 *(outbuffer + offset + 4) = (u_velocitiesi.base >> (8 * 4)) & 0xFF;
scarter1 0:020db18a476d 95 *(outbuffer + offset + 5) = (u_velocitiesi.base >> (8 * 5)) & 0xFF;
scarter1 0:020db18a476d 96 *(outbuffer + offset + 6) = (u_velocitiesi.base >> (8 * 6)) & 0xFF;
scarter1 0:020db18a476d 97 *(outbuffer + offset + 7) = (u_velocitiesi.base >> (8 * 7)) & 0xFF;
scarter1 0:020db18a476d 98 offset += sizeof(this->velocities[i]);
scarter1 0:020db18a476d 99 }
scarter1 0:020db18a476d 100 union {
scarter1 0:020db18a476d 101 double real;
scarter1 0:020db18a476d 102 uint64_t base;
scarter1 0:020db18a476d 103 } u_duration;
scarter1 0:020db18a476d 104 u_duration.real = this->duration;
scarter1 0:020db18a476d 105 *(outbuffer + offset + 0) = (u_duration.base >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 106 *(outbuffer + offset + 1) = (u_duration.base >> (8 * 1)) & 0xFF;
scarter1 0:020db18a476d 107 *(outbuffer + offset + 2) = (u_duration.base >> (8 * 2)) & 0xFF;
scarter1 0:020db18a476d 108 *(outbuffer + offset + 3) = (u_duration.base >> (8 * 3)) & 0xFF;
scarter1 0:020db18a476d 109 *(outbuffer + offset + 4) = (u_duration.base >> (8 * 4)) & 0xFF;
scarter1 0:020db18a476d 110 *(outbuffer + offset + 5) = (u_duration.base >> (8 * 5)) & 0xFF;
scarter1 0:020db18a476d 111 *(outbuffer + offset + 6) = (u_duration.base >> (8 * 6)) & 0xFF;
scarter1 0:020db18a476d 112 *(outbuffer + offset + 7) = (u_duration.base >> (8 * 7)) & 0xFF;
scarter1 0:020db18a476d 113 offset += sizeof(this->duration);
scarter1 0:020db18a476d 114 return offset;
scarter1 0:020db18a476d 115 }
scarter1 0:020db18a476d 116
scarter1 0:020db18a476d 117 virtual int deserialize(unsigned char *inbuffer)
scarter1 0:020db18a476d 118 {
scarter1 0:020db18a476d 119 int offset = 0;
scarter1 0:020db18a476d 120 offset += this->header.deserialize(inbuffer + offset);
scarter1 0:020db18a476d 121 uint32_t joint_names_lengthT = ((uint32_t) (*(inbuffer + offset)));
scarter1 0:020db18a476d 122 joint_names_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
scarter1 0:020db18a476d 123 joint_names_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
scarter1 0:020db18a476d 124 joint_names_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
scarter1 0:020db18a476d 125 offset += sizeof(this->joint_names_length);
scarter1 0:020db18a476d 126 if(joint_names_lengthT > joint_names_length)
scarter1 0:020db18a476d 127 this->joint_names = (char**)realloc(this->joint_names, joint_names_lengthT * sizeof(char*));
scarter1 0:020db18a476d 128 joint_names_length = joint_names_lengthT;
scarter1 0:020db18a476d 129 for( uint32_t i = 0; i < joint_names_length; i++){
scarter1 0:020db18a476d 130 uint32_t length_st_joint_names;
scarter1 0:020db18a476d 131 arrToVar(length_st_joint_names, (inbuffer + offset));
scarter1 0:020db18a476d 132 offset += 4;
scarter1 0:020db18a476d 133 for(unsigned int k= offset; k< offset+length_st_joint_names; ++k){
scarter1 0:020db18a476d 134 inbuffer[k-1]=inbuffer[k];
scarter1 0:020db18a476d 135 }
scarter1 0:020db18a476d 136 inbuffer[offset+length_st_joint_names-1]=0;
scarter1 0:020db18a476d 137 this->st_joint_names = (char *)(inbuffer + offset-1);
scarter1 0:020db18a476d 138 offset += length_st_joint_names;
scarter1 0:020db18a476d 139 memcpy( &(this->joint_names[i]), &(this->st_joint_names), sizeof(char*));
scarter1 0:020db18a476d 140 }
scarter1 0:020db18a476d 141 uint32_t displacements_lengthT = ((uint32_t) (*(inbuffer + offset)));
scarter1 0:020db18a476d 142 displacements_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
scarter1 0:020db18a476d 143 displacements_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
scarter1 0:020db18a476d 144 displacements_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
scarter1 0:020db18a476d 145 offset += sizeof(this->displacements_length);
scarter1 0:020db18a476d 146 if(displacements_lengthT > displacements_length)
scarter1 0:020db18a476d 147 this->displacements = (double*)realloc(this->displacements, displacements_lengthT * sizeof(double));
scarter1 0:020db18a476d 148 displacements_length = displacements_lengthT;
scarter1 0:020db18a476d 149 for( uint32_t i = 0; i < displacements_length; i++){
scarter1 0:020db18a476d 150 union {
scarter1 0:020db18a476d 151 double real;
scarter1 0:020db18a476d 152 uint64_t base;
scarter1 0:020db18a476d 153 } u_st_displacements;
scarter1 0:020db18a476d 154 u_st_displacements.base = 0;
scarter1 0:020db18a476d 155 u_st_displacements.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
scarter1 0:020db18a476d 156 u_st_displacements.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
scarter1 0:020db18a476d 157 u_st_displacements.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
scarter1 0:020db18a476d 158 u_st_displacements.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
scarter1 0:020db18a476d 159 u_st_displacements.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
scarter1 0:020db18a476d 160 u_st_displacements.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
scarter1 0:020db18a476d 161 u_st_displacements.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
scarter1 0:020db18a476d 162 u_st_displacements.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
scarter1 0:020db18a476d 163 this->st_displacements = u_st_displacements.real;
scarter1 0:020db18a476d 164 offset += sizeof(this->st_displacements);
scarter1 0:020db18a476d 165 memcpy( &(this->displacements[i]), &(this->st_displacements), sizeof(double));
scarter1 0:020db18a476d 166 }
scarter1 0:020db18a476d 167 uint32_t velocities_lengthT = ((uint32_t) (*(inbuffer + offset)));
scarter1 0:020db18a476d 168 velocities_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
scarter1 0:020db18a476d 169 velocities_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
scarter1 0:020db18a476d 170 velocities_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
scarter1 0:020db18a476d 171 offset += sizeof(this->velocities_length);
scarter1 0:020db18a476d 172 if(velocities_lengthT > velocities_length)
scarter1 0:020db18a476d 173 this->velocities = (double*)realloc(this->velocities, velocities_lengthT * sizeof(double));
scarter1 0:020db18a476d 174 velocities_length = velocities_lengthT;
scarter1 0:020db18a476d 175 for( uint32_t i = 0; i < velocities_length; i++){
scarter1 0:020db18a476d 176 union {
scarter1 0:020db18a476d 177 double real;
scarter1 0:020db18a476d 178 uint64_t base;
scarter1 0:020db18a476d 179 } u_st_velocities;
scarter1 0:020db18a476d 180 u_st_velocities.base = 0;
scarter1 0:020db18a476d 181 u_st_velocities.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
scarter1 0:020db18a476d 182 u_st_velocities.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
scarter1 0:020db18a476d 183 u_st_velocities.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
scarter1 0:020db18a476d 184 u_st_velocities.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
scarter1 0:020db18a476d 185 u_st_velocities.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
scarter1 0:020db18a476d 186 u_st_velocities.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
scarter1 0:020db18a476d 187 u_st_velocities.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
scarter1 0:020db18a476d 188 u_st_velocities.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
scarter1 0:020db18a476d 189 this->st_velocities = u_st_velocities.real;
scarter1 0:020db18a476d 190 offset += sizeof(this->st_velocities);
scarter1 0:020db18a476d 191 memcpy( &(this->velocities[i]), &(this->st_velocities), sizeof(double));
scarter1 0:020db18a476d 192 }
scarter1 0:020db18a476d 193 union {
scarter1 0:020db18a476d 194 double real;
scarter1 0:020db18a476d 195 uint64_t base;
scarter1 0:020db18a476d 196 } u_duration;
scarter1 0:020db18a476d 197 u_duration.base = 0;
scarter1 0:020db18a476d 198 u_duration.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
scarter1 0:020db18a476d 199 u_duration.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
scarter1 0:020db18a476d 200 u_duration.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
scarter1 0:020db18a476d 201 u_duration.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
scarter1 0:020db18a476d 202 u_duration.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
scarter1 0:020db18a476d 203 u_duration.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
scarter1 0:020db18a476d 204 u_duration.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
scarter1 0:020db18a476d 205 u_duration.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
scarter1 0:020db18a476d 206 this->duration = u_duration.real;
scarter1 0:020db18a476d 207 offset += sizeof(this->duration);
scarter1 0:020db18a476d 208 return offset;
scarter1 0:020db18a476d 209 }
scarter1 0:020db18a476d 210
scarter1 0:020db18a476d 211 const char * getType(){ return "control_msgs/JointJog"; };
scarter1 0:020db18a476d 212 const char * getMD5(){ return "1685da700c8c2e1254afc92a5fb89c96"; };
scarter1 0:020db18a476d 213
scarter1 0:020db18a476d 214 };
scarter1 0:020db18a476d 215
scarter1 0:020db18a476d 216 }
scarter1 0:020db18a476d 217 #endif