ros melodic library with custom message
Dependents: Robot_team1_QEI_Douglas Robot_team1
ros_lib/smach_msgs/SmachContainerInitialStatusCmd.h@3:b964e3f71102, 2019-12-03 (annotated)
- Committer:
- florine_van
- Date:
- Tue Dec 03 09:39:29 2019 +0000
- Revision:
- 3:b964e3f71102
- Parent:
- 0:020db18a476d
Clean code and remove unused lines
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
scarter1 | 0:020db18a476d | 1 | #ifndef _ROS_smach_msgs_SmachContainerInitialStatusCmd_h |
scarter1 | 0:020db18a476d | 2 | #define _ROS_smach_msgs_SmachContainerInitialStatusCmd_h |
scarter1 | 0:020db18a476d | 3 | |
scarter1 | 0:020db18a476d | 4 | #include <stdint.h> |
scarter1 | 0:020db18a476d | 5 | #include <string.h> |
scarter1 | 0:020db18a476d | 6 | #include <stdlib.h> |
scarter1 | 0:020db18a476d | 7 | #include "ros/msg.h" |
scarter1 | 0:020db18a476d | 8 | |
scarter1 | 0:020db18a476d | 9 | namespace smach_msgs |
scarter1 | 0:020db18a476d | 10 | { |
scarter1 | 0:020db18a476d | 11 | |
scarter1 | 0:020db18a476d | 12 | class SmachContainerInitialStatusCmd : public ros::Msg |
scarter1 | 0:020db18a476d | 13 | { |
scarter1 | 0:020db18a476d | 14 | public: |
scarter1 | 0:020db18a476d | 15 | typedef const char* _path_type; |
scarter1 | 0:020db18a476d | 16 | _path_type path; |
scarter1 | 0:020db18a476d | 17 | uint32_t initial_states_length; |
scarter1 | 0:020db18a476d | 18 | typedef char* _initial_states_type; |
scarter1 | 0:020db18a476d | 19 | _initial_states_type st_initial_states; |
scarter1 | 0:020db18a476d | 20 | _initial_states_type * initial_states; |
scarter1 | 0:020db18a476d | 21 | typedef const char* _local_data_type; |
scarter1 | 0:020db18a476d | 22 | _local_data_type local_data; |
scarter1 | 0:020db18a476d | 23 | |
scarter1 | 0:020db18a476d | 24 | SmachContainerInitialStatusCmd(): |
scarter1 | 0:020db18a476d | 25 | path(""), |
scarter1 | 0:020db18a476d | 26 | initial_states_length(0), initial_states(NULL), |
scarter1 | 0:020db18a476d | 27 | local_data("") |
scarter1 | 0:020db18a476d | 28 | { |
scarter1 | 0:020db18a476d | 29 | } |
scarter1 | 0:020db18a476d | 30 | |
scarter1 | 0:020db18a476d | 31 | virtual int serialize(unsigned char *outbuffer) const |
scarter1 | 0:020db18a476d | 32 | { |
scarter1 | 0:020db18a476d | 33 | int offset = 0; |
scarter1 | 0:020db18a476d | 34 | uint32_t length_path = strlen(this->path); |
scarter1 | 0:020db18a476d | 35 | varToArr(outbuffer + offset, length_path); |
scarter1 | 0:020db18a476d | 36 | offset += 4; |
scarter1 | 0:020db18a476d | 37 | memcpy(outbuffer + offset, this->path, length_path); |
scarter1 | 0:020db18a476d | 38 | offset += length_path; |
scarter1 | 0:020db18a476d | 39 | *(outbuffer + offset + 0) = (this->initial_states_length >> (8 * 0)) & 0xFF; |
scarter1 | 0:020db18a476d | 40 | *(outbuffer + offset + 1) = (this->initial_states_length >> (8 * 1)) & 0xFF; |
scarter1 | 0:020db18a476d | 41 | *(outbuffer + offset + 2) = (this->initial_states_length >> (8 * 2)) & 0xFF; |
scarter1 | 0:020db18a476d | 42 | *(outbuffer + offset + 3) = (this->initial_states_length >> (8 * 3)) & 0xFF; |
scarter1 | 0:020db18a476d | 43 | offset += sizeof(this->initial_states_length); |
scarter1 | 0:020db18a476d | 44 | for( uint32_t i = 0; i < initial_states_length; i++){ |
scarter1 | 0:020db18a476d | 45 | uint32_t length_initial_statesi = strlen(this->initial_states[i]); |
scarter1 | 0:020db18a476d | 46 | varToArr(outbuffer + offset, length_initial_statesi); |
scarter1 | 0:020db18a476d | 47 | offset += 4; |
scarter1 | 0:020db18a476d | 48 | memcpy(outbuffer + offset, this->initial_states[i], length_initial_statesi); |
scarter1 | 0:020db18a476d | 49 | offset += length_initial_statesi; |
scarter1 | 0:020db18a476d | 50 | } |
scarter1 | 0:020db18a476d | 51 | uint32_t length_local_data = strlen(this->local_data); |
scarter1 | 0:020db18a476d | 52 | varToArr(outbuffer + offset, length_local_data); |
scarter1 | 0:020db18a476d | 53 | offset += 4; |
scarter1 | 0:020db18a476d | 54 | memcpy(outbuffer + offset, this->local_data, length_local_data); |
scarter1 | 0:020db18a476d | 55 | offset += length_local_data; |
scarter1 | 0:020db18a476d | 56 | return offset; |
scarter1 | 0:020db18a476d | 57 | } |
scarter1 | 0:020db18a476d | 58 | |
scarter1 | 0:020db18a476d | 59 | virtual int deserialize(unsigned char *inbuffer) |
scarter1 | 0:020db18a476d | 60 | { |
scarter1 | 0:020db18a476d | 61 | int offset = 0; |
scarter1 | 0:020db18a476d | 62 | uint32_t length_path; |
scarter1 | 0:020db18a476d | 63 | arrToVar(length_path, (inbuffer + offset)); |
scarter1 | 0:020db18a476d | 64 | offset += 4; |
scarter1 | 0:020db18a476d | 65 | for(unsigned int k= offset; k< offset+length_path; ++k){ |
scarter1 | 0:020db18a476d | 66 | inbuffer[k-1]=inbuffer[k]; |
scarter1 | 0:020db18a476d | 67 | } |
scarter1 | 0:020db18a476d | 68 | inbuffer[offset+length_path-1]=0; |
scarter1 | 0:020db18a476d | 69 | this->path = (char *)(inbuffer + offset-1); |
scarter1 | 0:020db18a476d | 70 | offset += length_path; |
scarter1 | 0:020db18a476d | 71 | uint32_t initial_states_lengthT = ((uint32_t) (*(inbuffer + offset))); |
scarter1 | 0:020db18a476d | 72 | initial_states_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
scarter1 | 0:020db18a476d | 73 | initial_states_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
scarter1 | 0:020db18a476d | 74 | initial_states_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
scarter1 | 0:020db18a476d | 75 | offset += sizeof(this->initial_states_length); |
scarter1 | 0:020db18a476d | 76 | if(initial_states_lengthT > initial_states_length) |
scarter1 | 0:020db18a476d | 77 | this->initial_states = (char**)realloc(this->initial_states, initial_states_lengthT * sizeof(char*)); |
scarter1 | 0:020db18a476d | 78 | initial_states_length = initial_states_lengthT; |
scarter1 | 0:020db18a476d | 79 | for( uint32_t i = 0; i < initial_states_length; i++){ |
scarter1 | 0:020db18a476d | 80 | uint32_t length_st_initial_states; |
scarter1 | 0:020db18a476d | 81 | arrToVar(length_st_initial_states, (inbuffer + offset)); |
scarter1 | 0:020db18a476d | 82 | offset += 4; |
scarter1 | 0:020db18a476d | 83 | for(unsigned int k= offset; k< offset+length_st_initial_states; ++k){ |
scarter1 | 0:020db18a476d | 84 | inbuffer[k-1]=inbuffer[k]; |
scarter1 | 0:020db18a476d | 85 | } |
scarter1 | 0:020db18a476d | 86 | inbuffer[offset+length_st_initial_states-1]=0; |
scarter1 | 0:020db18a476d | 87 | this->st_initial_states = (char *)(inbuffer + offset-1); |
scarter1 | 0:020db18a476d | 88 | offset += length_st_initial_states; |
scarter1 | 0:020db18a476d | 89 | memcpy( &(this->initial_states[i]), &(this->st_initial_states), sizeof(char*)); |
scarter1 | 0:020db18a476d | 90 | } |
scarter1 | 0:020db18a476d | 91 | uint32_t length_local_data; |
scarter1 | 0:020db18a476d | 92 | arrToVar(length_local_data, (inbuffer + offset)); |
scarter1 | 0:020db18a476d | 93 | offset += 4; |
scarter1 | 0:020db18a476d | 94 | for(unsigned int k= offset; k< offset+length_local_data; ++k){ |
scarter1 | 0:020db18a476d | 95 | inbuffer[k-1]=inbuffer[k]; |
scarter1 | 0:020db18a476d | 96 | } |
scarter1 | 0:020db18a476d | 97 | inbuffer[offset+length_local_data-1]=0; |
scarter1 | 0:020db18a476d | 98 | this->local_data = (char *)(inbuffer + offset-1); |
scarter1 | 0:020db18a476d | 99 | offset += length_local_data; |
scarter1 | 0:020db18a476d | 100 | return offset; |
scarter1 | 0:020db18a476d | 101 | } |
scarter1 | 0:020db18a476d | 102 | |
scarter1 | 0:020db18a476d | 103 | const char * getType(){ return "smach_msgs/SmachContainerInitialStatusCmd"; }; |
scarter1 | 0:020db18a476d | 104 | const char * getMD5(){ return "45f8cf31fc29b829db77f23001f788d6"; }; |
scarter1 | 0:020db18a476d | 105 | |
scarter1 | 0:020db18a476d | 106 | }; |
scarter1 | 0:020db18a476d | 107 | |
scarter1 | 0:020db18a476d | 108 | } |
scarter1 | 0:020db18a476d | 109 | #endif |