Руслан Бредун / 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_SERVICE_SetModelConfiguration_h
ommpy 2:b7fdc74e5c5d 2 #define _ROS_SERVICE_SetModelConfiguration_h
ommpy 2:b7fdc74e5c5d 3 #include <stdint.h>
ommpy 2:b7fdc74e5c5d 4 #include <string.h>
ommpy 2:b7fdc74e5c5d 5 #include <stdlib.h>
ommpy 2:b7fdc74e5c5d 6 #include "ros/msg.h"
ommpy 2:b7fdc74e5c5d 7
ommpy 2:b7fdc74e5c5d 8 namespace gazebo_msgs
ommpy 2:b7fdc74e5c5d 9 {
ommpy 2:b7fdc74e5c5d 10
ommpy 2:b7fdc74e5c5d 11 static const char SETMODELCONFIGURATION[] = "gazebo_msgs/SetModelConfiguration";
ommpy 2:b7fdc74e5c5d 12
ommpy 2:b7fdc74e5c5d 13 class SetModelConfigurationRequest : public ros::Msg
ommpy 2:b7fdc74e5c5d 14 {
ommpy 2:b7fdc74e5c5d 15 public:
ommpy 2:b7fdc74e5c5d 16 typedef const char* _model_name_type;
ommpy 2:b7fdc74e5c5d 17 _model_name_type model_name;
ommpy 2:b7fdc74e5c5d 18 typedef const char* _urdf_param_name_type;
ommpy 2:b7fdc74e5c5d 19 _urdf_param_name_type urdf_param_name;
ommpy 2:b7fdc74e5c5d 20 uint32_t joint_names_length;
ommpy 2:b7fdc74e5c5d 21 typedef char* _joint_names_type;
ommpy 2:b7fdc74e5c5d 22 _joint_names_type st_joint_names;
ommpy 2:b7fdc74e5c5d 23 _joint_names_type * joint_names;
ommpy 2:b7fdc74e5c5d 24 uint32_t joint_positions_length;
ommpy 2:b7fdc74e5c5d 25 typedef double _joint_positions_type;
ommpy 2:b7fdc74e5c5d 26 _joint_positions_type st_joint_positions;
ommpy 2:b7fdc74e5c5d 27 _joint_positions_type * joint_positions;
ommpy 2:b7fdc74e5c5d 28
ommpy 2:b7fdc74e5c5d 29 SetModelConfigurationRequest():
ommpy 2:b7fdc74e5c5d 30 model_name(""),
ommpy 2:b7fdc74e5c5d 31 urdf_param_name(""),
ommpy 2:b7fdc74e5c5d 32 joint_names_length(0), joint_names(NULL),
ommpy 2:b7fdc74e5c5d 33 joint_positions_length(0), joint_positions(NULL)
ommpy 2:b7fdc74e5c5d 34 {
ommpy 2:b7fdc74e5c5d 35 }
ommpy 2:b7fdc74e5c5d 36
ommpy 2:b7fdc74e5c5d 37 virtual int serialize(unsigned char *outbuffer) const
ommpy 2:b7fdc74e5c5d 38 {
ommpy 2:b7fdc74e5c5d 39 int offset = 0;
ommpy 2:b7fdc74e5c5d 40 uint32_t length_model_name = strlen(this->model_name);
ommpy 2:b7fdc74e5c5d 41 varToArr(outbuffer + offset, length_model_name);
ommpy 2:b7fdc74e5c5d 42 offset += 4;
ommpy 2:b7fdc74e5c5d 43 memcpy(outbuffer + offset, this->model_name, length_model_name);
ommpy 2:b7fdc74e5c5d 44 offset += length_model_name;
ommpy 2:b7fdc74e5c5d 45 uint32_t length_urdf_param_name = strlen(this->urdf_param_name);
ommpy 2:b7fdc74e5c5d 46 varToArr(outbuffer + offset, length_urdf_param_name);
ommpy 2:b7fdc74e5c5d 47 offset += 4;
ommpy 2:b7fdc74e5c5d 48 memcpy(outbuffer + offset, this->urdf_param_name, length_urdf_param_name);
ommpy 2:b7fdc74e5c5d 49 offset += length_urdf_param_name;
ommpy 2:b7fdc74e5c5d 50 *(outbuffer + offset + 0) = (this->joint_names_length >> (8 * 0)) & 0xFF;
ommpy 2:b7fdc74e5c5d 51 *(outbuffer + offset + 1) = (this->joint_names_length >> (8 * 1)) & 0xFF;
ommpy 2:b7fdc74e5c5d 52 *(outbuffer + offset + 2) = (this->joint_names_length >> (8 * 2)) & 0xFF;
ommpy 2:b7fdc74e5c5d 53 *(outbuffer + offset + 3) = (this->joint_names_length >> (8 * 3)) & 0xFF;
ommpy 2:b7fdc74e5c5d 54 offset += sizeof(this->joint_names_length);
ommpy 2:b7fdc74e5c5d 55 for( uint32_t i = 0; i < joint_names_length; i++){
ommpy 2:b7fdc74e5c5d 56 uint32_t length_joint_namesi = strlen(this->joint_names[i]);
ommpy 2:b7fdc74e5c5d 57 varToArr(outbuffer + offset, length_joint_namesi);
ommpy 2:b7fdc74e5c5d 58 offset += 4;
ommpy 2:b7fdc74e5c5d 59 memcpy(outbuffer + offset, this->joint_names[i], length_joint_namesi);
ommpy 2:b7fdc74e5c5d 60 offset += length_joint_namesi;
ommpy 2:b7fdc74e5c5d 61 }
ommpy 2:b7fdc74e5c5d 62 *(outbuffer + offset + 0) = (this->joint_positions_length >> (8 * 0)) & 0xFF;
ommpy 2:b7fdc74e5c5d 63 *(outbuffer + offset + 1) = (this->joint_positions_length >> (8 * 1)) & 0xFF;
ommpy 2:b7fdc74e5c5d 64 *(outbuffer + offset + 2) = (this->joint_positions_length >> (8 * 2)) & 0xFF;
ommpy 2:b7fdc74e5c5d 65 *(outbuffer + offset + 3) = (this->joint_positions_length >> (8 * 3)) & 0xFF;
ommpy 2:b7fdc74e5c5d 66 offset += sizeof(this->joint_positions_length);
ommpy 2:b7fdc74e5c5d 67 for( uint32_t i = 0; i < joint_positions_length; i++){
ommpy 2:b7fdc74e5c5d 68 union {
ommpy 2:b7fdc74e5c5d 69 double real;
ommpy 2:b7fdc74e5c5d 70 uint64_t base;
ommpy 2:b7fdc74e5c5d 71 } u_joint_positionsi;
ommpy 2:b7fdc74e5c5d 72 u_joint_positionsi.real = this->joint_positions[i];
ommpy 2:b7fdc74e5c5d 73 *(outbuffer + offset + 0) = (u_joint_positionsi.base >> (8 * 0)) & 0xFF;
ommpy 2:b7fdc74e5c5d 74 *(outbuffer + offset + 1) = (u_joint_positionsi.base >> (8 * 1)) & 0xFF;
ommpy 2:b7fdc74e5c5d 75 *(outbuffer + offset + 2) = (u_joint_positionsi.base >> (8 * 2)) & 0xFF;
ommpy 2:b7fdc74e5c5d 76 *(outbuffer + offset + 3) = (u_joint_positionsi.base >> (8 * 3)) & 0xFF;
ommpy 2:b7fdc74e5c5d 77 *(outbuffer + offset + 4) = (u_joint_positionsi.base >> (8 * 4)) & 0xFF;
ommpy 2:b7fdc74e5c5d 78 *(outbuffer + offset + 5) = (u_joint_positionsi.base >> (8 * 5)) & 0xFF;
ommpy 2:b7fdc74e5c5d 79 *(outbuffer + offset + 6) = (u_joint_positionsi.base >> (8 * 6)) & 0xFF;
ommpy 2:b7fdc74e5c5d 80 *(outbuffer + offset + 7) = (u_joint_positionsi.base >> (8 * 7)) & 0xFF;
ommpy 2:b7fdc74e5c5d 81 offset += sizeof(this->joint_positions[i]);
ommpy 2:b7fdc74e5c5d 82 }
ommpy 2:b7fdc74e5c5d 83 return offset;
ommpy 2:b7fdc74e5c5d 84 }
ommpy 2:b7fdc74e5c5d 85
ommpy 2:b7fdc74e5c5d 86 virtual int deserialize(unsigned char *inbuffer)
ommpy 2:b7fdc74e5c5d 87 {
ommpy 2:b7fdc74e5c5d 88 int offset = 0;
ommpy 2:b7fdc74e5c5d 89 uint32_t length_model_name;
ommpy 2:b7fdc74e5c5d 90 arrToVar(length_model_name, (inbuffer + offset));
ommpy 2:b7fdc74e5c5d 91 offset += 4;
ommpy 2:b7fdc74e5c5d 92 for(unsigned int k= offset; k< offset+length_model_name; ++k){
ommpy 2:b7fdc74e5c5d 93 inbuffer[k-1]=inbuffer[k];
ommpy 2:b7fdc74e5c5d 94 }
ommpy 2:b7fdc74e5c5d 95 inbuffer[offset+length_model_name-1]=0;
ommpy 2:b7fdc74e5c5d 96 this->model_name = (char *)(inbuffer + offset-1);
ommpy 2:b7fdc74e5c5d 97 offset += length_model_name;
ommpy 2:b7fdc74e5c5d 98 uint32_t length_urdf_param_name;
ommpy 2:b7fdc74e5c5d 99 arrToVar(length_urdf_param_name, (inbuffer + offset));
ommpy 2:b7fdc74e5c5d 100 offset += 4;
ommpy 2:b7fdc74e5c5d 101 for(unsigned int k= offset; k< offset+length_urdf_param_name; ++k){
ommpy 2:b7fdc74e5c5d 102 inbuffer[k-1]=inbuffer[k];
ommpy 2:b7fdc74e5c5d 103 }
ommpy 2:b7fdc74e5c5d 104 inbuffer[offset+length_urdf_param_name-1]=0;
ommpy 2:b7fdc74e5c5d 105 this->urdf_param_name = (char *)(inbuffer + offset-1);
ommpy 2:b7fdc74e5c5d 106 offset += length_urdf_param_name;
ommpy 2:b7fdc74e5c5d 107 uint32_t joint_names_lengthT = ((uint32_t) (*(inbuffer + offset)));
ommpy 2:b7fdc74e5c5d 108 joint_names_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
ommpy 2:b7fdc74e5c5d 109 joint_names_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
ommpy 2:b7fdc74e5c5d 110 joint_names_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
ommpy 2:b7fdc74e5c5d 111 offset += sizeof(this->joint_names_length);
ommpy 2:b7fdc74e5c5d 112 if(joint_names_lengthT > joint_names_length)
ommpy 2:b7fdc74e5c5d 113 this->joint_names = (char**)realloc(this->joint_names, joint_names_lengthT * sizeof(char*));
ommpy 2:b7fdc74e5c5d 114 joint_names_length = joint_names_lengthT;
ommpy 2:b7fdc74e5c5d 115 for( uint32_t i = 0; i < joint_names_length; i++){
ommpy 2:b7fdc74e5c5d 116 uint32_t length_st_joint_names;
ommpy 2:b7fdc74e5c5d 117 arrToVar(length_st_joint_names, (inbuffer + offset));
ommpy 2:b7fdc74e5c5d 118 offset += 4;
ommpy 2:b7fdc74e5c5d 119 for(unsigned int k= offset; k< offset+length_st_joint_names; ++k){
ommpy 2:b7fdc74e5c5d 120 inbuffer[k-1]=inbuffer[k];
ommpy 2:b7fdc74e5c5d 121 }
ommpy 2:b7fdc74e5c5d 122 inbuffer[offset+length_st_joint_names-1]=0;
ommpy 2:b7fdc74e5c5d 123 this->st_joint_names = (char *)(inbuffer + offset-1);
ommpy 2:b7fdc74e5c5d 124 offset += length_st_joint_names;
ommpy 2:b7fdc74e5c5d 125 memcpy( &(this->joint_names[i]), &(this->st_joint_names), sizeof(char*));
ommpy 2:b7fdc74e5c5d 126 }
ommpy 2:b7fdc74e5c5d 127 uint32_t joint_positions_lengthT = ((uint32_t) (*(inbuffer + offset)));
ommpy 2:b7fdc74e5c5d 128 joint_positions_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
ommpy 2:b7fdc74e5c5d 129 joint_positions_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
ommpy 2:b7fdc74e5c5d 130 joint_positions_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
ommpy 2:b7fdc74e5c5d 131 offset += sizeof(this->joint_positions_length);
ommpy 2:b7fdc74e5c5d 132 if(joint_positions_lengthT > joint_positions_length)
ommpy 2:b7fdc74e5c5d 133 this->joint_positions = (double*)realloc(this->joint_positions, joint_positions_lengthT * sizeof(double));
ommpy 2:b7fdc74e5c5d 134 joint_positions_length = joint_positions_lengthT;
ommpy 2:b7fdc74e5c5d 135 for( uint32_t i = 0; i < joint_positions_length; i++){
ommpy 2:b7fdc74e5c5d 136 union {
ommpy 2:b7fdc74e5c5d 137 double real;
ommpy 2:b7fdc74e5c5d 138 uint64_t base;
ommpy 2:b7fdc74e5c5d 139 } u_st_joint_positions;
ommpy 2:b7fdc74e5c5d 140 u_st_joint_positions.base = 0;
ommpy 2:b7fdc74e5c5d 141 u_st_joint_positions.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
ommpy 2:b7fdc74e5c5d 142 u_st_joint_positions.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
ommpy 2:b7fdc74e5c5d 143 u_st_joint_positions.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
ommpy 2:b7fdc74e5c5d 144 u_st_joint_positions.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
ommpy 2:b7fdc74e5c5d 145 u_st_joint_positions.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
ommpy 2:b7fdc74e5c5d 146 u_st_joint_positions.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
ommpy 2:b7fdc74e5c5d 147 u_st_joint_positions.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
ommpy 2:b7fdc74e5c5d 148 u_st_joint_positions.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
ommpy 2:b7fdc74e5c5d 149 this->st_joint_positions = u_st_joint_positions.real;
ommpy 2:b7fdc74e5c5d 150 offset += sizeof(this->st_joint_positions);
ommpy 2:b7fdc74e5c5d 151 memcpy( &(this->joint_positions[i]), &(this->st_joint_positions), sizeof(double));
ommpy 2:b7fdc74e5c5d 152 }
ommpy 2:b7fdc74e5c5d 153 return offset;
ommpy 2:b7fdc74e5c5d 154 }
ommpy 2:b7fdc74e5c5d 155
ommpy 2:b7fdc74e5c5d 156 const char * getType(){ return SETMODELCONFIGURATION; };
ommpy 2:b7fdc74e5c5d 157 const char * getMD5(){ return "160eae60f51fabff255480c70afa289f"; };
ommpy 2:b7fdc74e5c5d 158
ommpy 2:b7fdc74e5c5d 159 };
ommpy 2:b7fdc74e5c5d 160
ommpy 2:b7fdc74e5c5d 161 class SetModelConfigurationResponse : public ros::Msg
ommpy 2:b7fdc74e5c5d 162 {
ommpy 2:b7fdc74e5c5d 163 public:
ommpy 2:b7fdc74e5c5d 164 typedef bool _success_type;
ommpy 2:b7fdc74e5c5d 165 _success_type success;
ommpy 2:b7fdc74e5c5d 166 typedef const char* _status_message_type;
ommpy 2:b7fdc74e5c5d 167 _status_message_type status_message;
ommpy 2:b7fdc74e5c5d 168
ommpy 2:b7fdc74e5c5d 169 SetModelConfigurationResponse():
ommpy 2:b7fdc74e5c5d 170 success(0),
ommpy 2:b7fdc74e5c5d 171 status_message("")
ommpy 2:b7fdc74e5c5d 172 {
ommpy 2:b7fdc74e5c5d 173 }
ommpy 2:b7fdc74e5c5d 174
ommpy 2:b7fdc74e5c5d 175 virtual int serialize(unsigned char *outbuffer) const
ommpy 2:b7fdc74e5c5d 176 {
ommpy 2:b7fdc74e5c5d 177 int offset = 0;
ommpy 2:b7fdc74e5c5d 178 union {
ommpy 2:b7fdc74e5c5d 179 bool real;
ommpy 2:b7fdc74e5c5d 180 uint8_t base;
ommpy 2:b7fdc74e5c5d 181 } u_success;
ommpy 2:b7fdc74e5c5d 182 u_success.real = this->success;
ommpy 2:b7fdc74e5c5d 183 *(outbuffer + offset + 0) = (u_success.base >> (8 * 0)) & 0xFF;
ommpy 2:b7fdc74e5c5d 184 offset += sizeof(this->success);
ommpy 2:b7fdc74e5c5d 185 uint32_t length_status_message = strlen(this->status_message);
ommpy 2:b7fdc74e5c5d 186 varToArr(outbuffer + offset, length_status_message);
ommpy 2:b7fdc74e5c5d 187 offset += 4;
ommpy 2:b7fdc74e5c5d 188 memcpy(outbuffer + offset, this->status_message, length_status_message);
ommpy 2:b7fdc74e5c5d 189 offset += length_status_message;
ommpy 2:b7fdc74e5c5d 190 return offset;
ommpy 2:b7fdc74e5c5d 191 }
ommpy 2:b7fdc74e5c5d 192
ommpy 2:b7fdc74e5c5d 193 virtual int deserialize(unsigned char *inbuffer)
ommpy 2:b7fdc74e5c5d 194 {
ommpy 2:b7fdc74e5c5d 195 int offset = 0;
ommpy 2:b7fdc74e5c5d 196 union {
ommpy 2:b7fdc74e5c5d 197 bool real;
ommpy 2:b7fdc74e5c5d 198 uint8_t base;
ommpy 2:b7fdc74e5c5d 199 } u_success;
ommpy 2:b7fdc74e5c5d 200 u_success.base = 0;
ommpy 2:b7fdc74e5c5d 201 u_success.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
ommpy 2:b7fdc74e5c5d 202 this->success = u_success.real;
ommpy 2:b7fdc74e5c5d 203 offset += sizeof(this->success);
ommpy 2:b7fdc74e5c5d 204 uint32_t length_status_message;
ommpy 2:b7fdc74e5c5d 205 arrToVar(length_status_message, (inbuffer + offset));
ommpy 2:b7fdc74e5c5d 206 offset += 4;
ommpy 2:b7fdc74e5c5d 207 for(unsigned int k= offset; k< offset+length_status_message; ++k){
ommpy 2:b7fdc74e5c5d 208 inbuffer[k-1]=inbuffer[k];
ommpy 2:b7fdc74e5c5d 209 }
ommpy 2:b7fdc74e5c5d 210 inbuffer[offset+length_status_message-1]=0;
ommpy 2:b7fdc74e5c5d 211 this->status_message = (char *)(inbuffer + offset-1);
ommpy 2:b7fdc74e5c5d 212 offset += length_status_message;
ommpy 2:b7fdc74e5c5d 213 return offset;
ommpy 2:b7fdc74e5c5d 214 }
ommpy 2:b7fdc74e5c5d 215
ommpy 2:b7fdc74e5c5d 216 const char * getType(){ return SETMODELCONFIGURATION; };
ommpy 2:b7fdc74e5c5d 217 const char * getMD5(){ return "2ec6f3eff0161f4257b808b12bc830c2"; };
ommpy 2:b7fdc74e5c5d 218
ommpy 2:b7fdc74e5c5d 219 };
ommpy 2:b7fdc74e5c5d 220
ommpy 2:b7fdc74e5c5d 221 class SetModelConfiguration {
ommpy 2:b7fdc74e5c5d 222 public:
ommpy 2:b7fdc74e5c5d 223 typedef SetModelConfigurationRequest Request;
ommpy 2:b7fdc74e5c5d 224 typedef SetModelConfigurationResponse Response;
ommpy 2:b7fdc74e5c5d 225 };
ommpy 2:b7fdc74e5c5d 226
ommpy 2:b7fdc74e5c5d 227 }
ommpy 2:b7fdc74e5c5d 228 #endif