Руслан Бредун / Mbed 2 deprecated STM32-MC_node

Dependencies:   mbed Watchdog stm32-sensor-base2

Committer:
ommpy
Date:
Tue Jul 07 15:19:06 2020 +0530
Revision:
2:b7fdc74e5c5d
new board files

Who changed what in which revision?

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