catchrobo2022 / Mbed 2 deprecated catchrobo2022_mbed

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers HarkPower.h Source File

HarkPower.h

00001 #ifndef _ROS_jsk_hark_msgs_HarkPower_h
00002 #define _ROS_jsk_hark_msgs_HarkPower_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 #include "std_msgs/Header.h"
00009 
00010 namespace jsk_hark_msgs
00011 {
00012 
00013   class HarkPower : public ros::Msg
00014   {
00015     public:
00016       typedef std_msgs::Header _header_type;
00017       _header_type header;
00018       typedef int32_t _count_type;
00019       _count_type count;
00020       typedef int32_t _directions_type;
00021       _directions_type directions;
00022       typedef int32_t _data_bytes_type;
00023       _data_bytes_type data_bytes;
00024       uint32_t powers_length;
00025       typedef float _powers_type;
00026       _powers_type st_powers;
00027       _powers_type * powers;
00028 
00029     HarkPower():
00030       header(),
00031       count(0),
00032       directions(0),
00033       data_bytes(0),
00034       powers_length(0), powers(NULL)
00035     {
00036     }
00037 
00038     virtual int serialize(unsigned char *outbuffer) const
00039     {
00040       int offset = 0;
00041       offset += this->header.serialize(outbuffer + offset);
00042       union {
00043         int32_t real;
00044         uint32_t base;
00045       } u_count;
00046       u_count.real = this->count;
00047       *(outbuffer + offset + 0) = (u_count.base >> (8 * 0)) & 0xFF;
00048       *(outbuffer + offset + 1) = (u_count.base >> (8 * 1)) & 0xFF;
00049       *(outbuffer + offset + 2) = (u_count.base >> (8 * 2)) & 0xFF;
00050       *(outbuffer + offset + 3) = (u_count.base >> (8 * 3)) & 0xFF;
00051       offset += sizeof(this->count);
00052       union {
00053         int32_t real;
00054         uint32_t base;
00055       } u_directions;
00056       u_directions.real = this->directions;
00057       *(outbuffer + offset + 0) = (u_directions.base >> (8 * 0)) & 0xFF;
00058       *(outbuffer + offset + 1) = (u_directions.base >> (8 * 1)) & 0xFF;
00059       *(outbuffer + offset + 2) = (u_directions.base >> (8 * 2)) & 0xFF;
00060       *(outbuffer + offset + 3) = (u_directions.base >> (8 * 3)) & 0xFF;
00061       offset += sizeof(this->directions);
00062       union {
00063         int32_t real;
00064         uint32_t base;
00065       } u_data_bytes;
00066       u_data_bytes.real = this->data_bytes;
00067       *(outbuffer + offset + 0) = (u_data_bytes.base >> (8 * 0)) & 0xFF;
00068       *(outbuffer + offset + 1) = (u_data_bytes.base >> (8 * 1)) & 0xFF;
00069       *(outbuffer + offset + 2) = (u_data_bytes.base >> (8 * 2)) & 0xFF;
00070       *(outbuffer + offset + 3) = (u_data_bytes.base >> (8 * 3)) & 0xFF;
00071       offset += sizeof(this->data_bytes);
00072       *(outbuffer + offset + 0) = (this->powers_length >> (8 * 0)) & 0xFF;
00073       *(outbuffer + offset + 1) = (this->powers_length >> (8 * 1)) & 0xFF;
00074       *(outbuffer + offset + 2) = (this->powers_length >> (8 * 2)) & 0xFF;
00075       *(outbuffer + offset + 3) = (this->powers_length >> (8 * 3)) & 0xFF;
00076       offset += sizeof(this->powers_length);
00077       for( uint32_t i = 0; i < powers_length; i++){
00078       union {
00079         float real;
00080         uint32_t base;
00081       } u_powersi;
00082       u_powersi.real = this->powers[i];
00083       *(outbuffer + offset + 0) = (u_powersi.base >> (8 * 0)) & 0xFF;
00084       *(outbuffer + offset + 1) = (u_powersi.base >> (8 * 1)) & 0xFF;
00085       *(outbuffer + offset + 2) = (u_powersi.base >> (8 * 2)) & 0xFF;
00086       *(outbuffer + offset + 3) = (u_powersi.base >> (8 * 3)) & 0xFF;
00087       offset += sizeof(this->powers[i]);
00088       }
00089       return offset;
00090     }
00091 
00092     virtual int deserialize(unsigned char *inbuffer)
00093     {
00094       int offset = 0;
00095       offset += this->header.deserialize(inbuffer + offset);
00096       union {
00097         int32_t real;
00098         uint32_t base;
00099       } u_count;
00100       u_count.base = 0;
00101       u_count.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00102       u_count.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00103       u_count.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00104       u_count.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00105       this->count = u_count.real;
00106       offset += sizeof(this->count);
00107       union {
00108         int32_t real;
00109         uint32_t base;
00110       } u_directions;
00111       u_directions.base = 0;
00112       u_directions.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00113       u_directions.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00114       u_directions.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00115       u_directions.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00116       this->directions = u_directions.real;
00117       offset += sizeof(this->directions);
00118       union {
00119         int32_t real;
00120         uint32_t base;
00121       } u_data_bytes;
00122       u_data_bytes.base = 0;
00123       u_data_bytes.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00124       u_data_bytes.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00125       u_data_bytes.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00126       u_data_bytes.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00127       this->data_bytes = u_data_bytes.real;
00128       offset += sizeof(this->data_bytes);
00129       uint32_t powers_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00130       powers_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00131       powers_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00132       powers_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00133       offset += sizeof(this->powers_length);
00134       if(powers_lengthT > powers_length)
00135         this->powers = (float*)realloc(this->powers, powers_lengthT * sizeof(float));
00136       powers_length = powers_lengthT;
00137       for( uint32_t i = 0; i < powers_length; i++){
00138       union {
00139         float real;
00140         uint32_t base;
00141       } u_st_powers;
00142       u_st_powers.base = 0;
00143       u_st_powers.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00144       u_st_powers.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00145       u_st_powers.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00146       u_st_powers.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00147       this->st_powers = u_st_powers.real;
00148       offset += sizeof(this->st_powers);
00149         memcpy( &(this->powers[i]), &(this->st_powers), sizeof(float));
00150       }
00151      return offset;
00152     }
00153 
00154     virtual const char * getType(){ return "jsk_hark_msgs/HarkPower"; };
00155     virtual const char * getMD5(){ return "251c13d7a8be27144a2b24c6f53df705"; };
00156 
00157   };
00158 
00159 }
00160 #endif