catchrobo2022 / Mbed 2 deprecated catchrobo2022_mbed

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ListRobotStatesInWarehouse.h Source File

ListRobotStatesInWarehouse.h

00001 #ifndef _ROS_SERVICE_ListRobotStatesInWarehouse_h
00002 #define _ROS_SERVICE_ListRobotStatesInWarehouse_h
00003 #include <stdint.h>
00004 #include <string.h>
00005 #include <stdlib.h>
00006 #include "ros/msg.h"
00007 
00008 namespace moveit_msgs
00009 {
00010 
00011 static const char LISTROBOTSTATESINWAREHOUSE[] = "moveit_msgs/ListRobotStatesInWarehouse";
00012 
00013   class ListRobotStatesInWarehouseRequest : public ros::Msg
00014   {
00015     public:
00016       typedef const char* _regex_type;
00017       _regex_type regex;
00018       typedef const char* _robot_type;
00019       _robot_type robot;
00020 
00021     ListRobotStatesInWarehouseRequest():
00022       regex(""),
00023       robot("")
00024     {
00025     }
00026 
00027     virtual int serialize(unsigned char *outbuffer) const
00028     {
00029       int offset = 0;
00030       uint32_t length_regex = strlen(this->regex);
00031       varToArr(outbuffer + offset, length_regex);
00032       offset += 4;
00033       memcpy(outbuffer + offset, this->regex, length_regex);
00034       offset += length_regex;
00035       uint32_t length_robot = strlen(this->robot);
00036       varToArr(outbuffer + offset, length_robot);
00037       offset += 4;
00038       memcpy(outbuffer + offset, this->robot, length_robot);
00039       offset += length_robot;
00040       return offset;
00041     }
00042 
00043     virtual int deserialize(unsigned char *inbuffer)
00044     {
00045       int offset = 0;
00046       uint32_t length_regex;
00047       arrToVar(length_regex, (inbuffer + offset));
00048       offset += 4;
00049       for(unsigned int k= offset; k< offset+length_regex; ++k){
00050           inbuffer[k-1]=inbuffer[k];
00051       }
00052       inbuffer[offset+length_regex-1]=0;
00053       this->regex = (char *)(inbuffer + offset-1);
00054       offset += length_regex;
00055       uint32_t length_robot;
00056       arrToVar(length_robot, (inbuffer + offset));
00057       offset += 4;
00058       for(unsigned int k= offset; k< offset+length_robot; ++k){
00059           inbuffer[k-1]=inbuffer[k];
00060       }
00061       inbuffer[offset+length_robot-1]=0;
00062       this->robot = (char *)(inbuffer + offset-1);
00063       offset += length_robot;
00064      return offset;
00065     }
00066 
00067     virtual const char * getType(){ return LISTROBOTSTATESINWAREHOUSE; };
00068     virtual const char * getMD5(){ return "6f0970a3ca837e2fc3ed63e314b44b42"; };
00069 
00070   };
00071 
00072   class ListRobotStatesInWarehouseResponse : public ros::Msg
00073   {
00074     public:
00075       uint32_t states_length;
00076       typedef char* _states_type;
00077       _states_type st_states;
00078       _states_type * states;
00079 
00080     ListRobotStatesInWarehouseResponse():
00081       states_length(0), states(NULL)
00082     {
00083     }
00084 
00085     virtual int serialize(unsigned char *outbuffer) const
00086     {
00087       int offset = 0;
00088       *(outbuffer + offset + 0) = (this->states_length >> (8 * 0)) & 0xFF;
00089       *(outbuffer + offset + 1) = (this->states_length >> (8 * 1)) & 0xFF;
00090       *(outbuffer + offset + 2) = (this->states_length >> (8 * 2)) & 0xFF;
00091       *(outbuffer + offset + 3) = (this->states_length >> (8 * 3)) & 0xFF;
00092       offset += sizeof(this->states_length);
00093       for( uint32_t i = 0; i < states_length; i++){
00094       uint32_t length_statesi = strlen(this->states[i]);
00095       varToArr(outbuffer + offset, length_statesi);
00096       offset += 4;
00097       memcpy(outbuffer + offset, this->states[i], length_statesi);
00098       offset += length_statesi;
00099       }
00100       return offset;
00101     }
00102 
00103     virtual int deserialize(unsigned char *inbuffer)
00104     {
00105       int offset = 0;
00106       uint32_t states_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00107       states_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00108       states_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00109       states_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00110       offset += sizeof(this->states_length);
00111       if(states_lengthT > states_length)
00112         this->states = (char**)realloc(this->states, states_lengthT * sizeof(char*));
00113       states_length = states_lengthT;
00114       for( uint32_t i = 0; i < states_length; i++){
00115       uint32_t length_st_states;
00116       arrToVar(length_st_states, (inbuffer + offset));
00117       offset += 4;
00118       for(unsigned int k= offset; k< offset+length_st_states; ++k){
00119           inbuffer[k-1]=inbuffer[k];
00120       }
00121       inbuffer[offset+length_st_states-1]=0;
00122       this->st_states = (char *)(inbuffer + offset-1);
00123       offset += length_st_states;
00124         memcpy( &(this->states[i]), &(this->st_states), sizeof(char*));
00125       }
00126      return offset;
00127     }
00128 
00129     virtual const char * getType(){ return LISTROBOTSTATESINWAREHOUSE; };
00130     virtual const char * getMD5(){ return "a8656b247c0429bb79afe0ddb88eb2f5"; };
00131 
00132   };
00133 
00134   class ListRobotStatesInWarehouse {
00135     public:
00136     typedef ListRobotStatesInWarehouseRequest Request;
00137     typedef ListRobotStatesInWarehouseResponse Response;
00138   };
00139 
00140 }
00141 #endif