No description

Dependencies:   BufferedSerial

Committer:
Anaph
Date:
Mon Mar 30 22:15:01 2020 +0000
Revision:
3:d7bea56ad88b
Parent:
0:9e9b7db60fd5
No description

Who changed what in which revision?

UserRevisionLine numberNew contents of line
garyservin 0:9e9b7db60fd5 1 #ifndef _ROS_shape_msgs_SolidPrimitive_h
garyservin 0:9e9b7db60fd5 2 #define _ROS_shape_msgs_SolidPrimitive_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
garyservin 0:9e9b7db60fd5 9 namespace shape_msgs
garyservin 0:9e9b7db60fd5 10 {
garyservin 0:9e9b7db60fd5 11
garyservin 0:9e9b7db60fd5 12 class SolidPrimitive : public ros::Msg
garyservin 0:9e9b7db60fd5 13 {
garyservin 0:9e9b7db60fd5 14 public:
garyservin 0:9e9b7db60fd5 15 typedef uint8_t _type_type;
garyservin 0:9e9b7db60fd5 16 _type_type type;
garyservin 0:9e9b7db60fd5 17 uint32_t dimensions_length;
garyservin 0:9e9b7db60fd5 18 typedef double _dimensions_type;
garyservin 0:9e9b7db60fd5 19 _dimensions_type st_dimensions;
garyservin 0:9e9b7db60fd5 20 _dimensions_type * dimensions;
garyservin 0:9e9b7db60fd5 21 enum { BOX = 1 };
garyservin 0:9e9b7db60fd5 22 enum { SPHERE = 2 };
garyservin 0:9e9b7db60fd5 23 enum { CYLINDER = 3 };
garyservin 0:9e9b7db60fd5 24 enum { CONE = 4 };
garyservin 0:9e9b7db60fd5 25 enum { BOX_X = 0 };
garyservin 0:9e9b7db60fd5 26 enum { BOX_Y = 1 };
garyservin 0:9e9b7db60fd5 27 enum { BOX_Z = 2 };
garyservin 0:9e9b7db60fd5 28 enum { SPHERE_RADIUS = 0 };
garyservin 0:9e9b7db60fd5 29 enum { CYLINDER_HEIGHT = 0 };
garyservin 0:9e9b7db60fd5 30 enum { CYLINDER_RADIUS = 1 };
garyservin 0:9e9b7db60fd5 31 enum { CONE_HEIGHT = 0 };
garyservin 0:9e9b7db60fd5 32 enum { CONE_RADIUS = 1 };
garyservin 0:9e9b7db60fd5 33
garyservin 0:9e9b7db60fd5 34 SolidPrimitive():
garyservin 0:9e9b7db60fd5 35 type(0),
garyservin 0:9e9b7db60fd5 36 dimensions_length(0), dimensions(NULL)
garyservin 0:9e9b7db60fd5 37 {
garyservin 0:9e9b7db60fd5 38 }
garyservin 0:9e9b7db60fd5 39
garyservin 0:9e9b7db60fd5 40 virtual int serialize(unsigned char *outbuffer) const
garyservin 0:9e9b7db60fd5 41 {
garyservin 0:9e9b7db60fd5 42 int offset = 0;
garyservin 0:9e9b7db60fd5 43 *(outbuffer + offset + 0) = (this->type >> (8 * 0)) & 0xFF;
garyservin 0:9e9b7db60fd5 44 offset += sizeof(this->type);
garyservin 0:9e9b7db60fd5 45 *(outbuffer + offset + 0) = (this->dimensions_length >> (8 * 0)) & 0xFF;
garyservin 0:9e9b7db60fd5 46 *(outbuffer + offset + 1) = (this->dimensions_length >> (8 * 1)) & 0xFF;
garyservin 0:9e9b7db60fd5 47 *(outbuffer + offset + 2) = (this->dimensions_length >> (8 * 2)) & 0xFF;
garyservin 0:9e9b7db60fd5 48 *(outbuffer + offset + 3) = (this->dimensions_length >> (8 * 3)) & 0xFF;
garyservin 0:9e9b7db60fd5 49 offset += sizeof(this->dimensions_length);
garyservin 0:9e9b7db60fd5 50 for( uint32_t i = 0; i < dimensions_length; i++){
garyservin 0:9e9b7db60fd5 51 union {
garyservin 0:9e9b7db60fd5 52 double real;
garyservin 0:9e9b7db60fd5 53 uint64_t base;
garyservin 0:9e9b7db60fd5 54 } u_dimensionsi;
garyservin 0:9e9b7db60fd5 55 u_dimensionsi.real = this->dimensions[i];
garyservin 0:9e9b7db60fd5 56 *(outbuffer + offset + 0) = (u_dimensionsi.base >> (8 * 0)) & 0xFF;
garyservin 0:9e9b7db60fd5 57 *(outbuffer + offset + 1) = (u_dimensionsi.base >> (8 * 1)) & 0xFF;
garyservin 0:9e9b7db60fd5 58 *(outbuffer + offset + 2) = (u_dimensionsi.base >> (8 * 2)) & 0xFF;
garyservin 0:9e9b7db60fd5 59 *(outbuffer + offset + 3) = (u_dimensionsi.base >> (8 * 3)) & 0xFF;
garyservin 0:9e9b7db60fd5 60 *(outbuffer + offset + 4) = (u_dimensionsi.base >> (8 * 4)) & 0xFF;
garyservin 0:9e9b7db60fd5 61 *(outbuffer + offset + 5) = (u_dimensionsi.base >> (8 * 5)) & 0xFF;
garyservin 0:9e9b7db60fd5 62 *(outbuffer + offset + 6) = (u_dimensionsi.base >> (8 * 6)) & 0xFF;
garyservin 0:9e9b7db60fd5 63 *(outbuffer + offset + 7) = (u_dimensionsi.base >> (8 * 7)) & 0xFF;
garyservin 0:9e9b7db60fd5 64 offset += sizeof(this->dimensions[i]);
garyservin 0:9e9b7db60fd5 65 }
garyservin 0:9e9b7db60fd5 66 return offset;
garyservin 0:9e9b7db60fd5 67 }
garyservin 0:9e9b7db60fd5 68
garyservin 0:9e9b7db60fd5 69 virtual int deserialize(unsigned char *inbuffer)
garyservin 0:9e9b7db60fd5 70 {
garyservin 0:9e9b7db60fd5 71 int offset = 0;
garyservin 0:9e9b7db60fd5 72 this->type = ((uint8_t) (*(inbuffer + offset)));
garyservin 0:9e9b7db60fd5 73 offset += sizeof(this->type);
garyservin 0:9e9b7db60fd5 74 uint32_t dimensions_lengthT = ((uint32_t) (*(inbuffer + offset)));
garyservin 0:9e9b7db60fd5 75 dimensions_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
garyservin 0:9e9b7db60fd5 76 dimensions_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
garyservin 0:9e9b7db60fd5 77 dimensions_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
garyservin 0:9e9b7db60fd5 78 offset += sizeof(this->dimensions_length);
garyservin 0:9e9b7db60fd5 79 if(dimensions_lengthT > dimensions_length)
garyservin 0:9e9b7db60fd5 80 this->dimensions = (double*)realloc(this->dimensions, dimensions_lengthT * sizeof(double));
garyservin 0:9e9b7db60fd5 81 dimensions_length = dimensions_lengthT;
garyservin 0:9e9b7db60fd5 82 for( uint32_t i = 0; i < dimensions_length; i++){
garyservin 0:9e9b7db60fd5 83 union {
garyservin 0:9e9b7db60fd5 84 double real;
garyservin 0:9e9b7db60fd5 85 uint64_t base;
garyservin 0:9e9b7db60fd5 86 } u_st_dimensions;
garyservin 0:9e9b7db60fd5 87 u_st_dimensions.base = 0;
garyservin 0:9e9b7db60fd5 88 u_st_dimensions.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
garyservin 0:9e9b7db60fd5 89 u_st_dimensions.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
garyservin 0:9e9b7db60fd5 90 u_st_dimensions.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
garyservin 0:9e9b7db60fd5 91 u_st_dimensions.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
garyservin 0:9e9b7db60fd5 92 u_st_dimensions.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
garyservin 0:9e9b7db60fd5 93 u_st_dimensions.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
garyservin 0:9e9b7db60fd5 94 u_st_dimensions.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
garyservin 0:9e9b7db60fd5 95 u_st_dimensions.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
garyservin 0:9e9b7db60fd5 96 this->st_dimensions = u_st_dimensions.real;
garyservin 0:9e9b7db60fd5 97 offset += sizeof(this->st_dimensions);
garyservin 0:9e9b7db60fd5 98 memcpy( &(this->dimensions[i]), &(this->st_dimensions), sizeof(double));
garyservin 0:9e9b7db60fd5 99 }
garyservin 0:9e9b7db60fd5 100 return offset;
garyservin 0:9e9b7db60fd5 101 }
garyservin 0:9e9b7db60fd5 102
garyservin 0:9e9b7db60fd5 103 const char * getType(){ return "shape_msgs/SolidPrimitive"; };
garyservin 0:9e9b7db60fd5 104 const char * getMD5(){ return "d8f8cbc74c5ff283fca29569ccefb45d"; };
garyservin 0:9e9b7db60fd5 105
garyservin 0:9e9b7db60fd5 106 };
garyservin 0:9e9b7db60fd5 107
garyservin 0:9e9b7db60fd5 108 }
garyservin 0:9e9b7db60fd5 109 #endif