ros melodic library with custom message
Dependents: Robot_team1_QEI_Douglas Robot_team1
ros_lib/diagnostic_msgs/DiagnosticArray.h
- Committer:
- florine_van
- Date:
- 2019-12-03
- Revision:
- 3:b964e3f71102
- Parent:
- 0:020db18a476d
File content as of revision 3:b964e3f71102:
#ifndef _ROS_diagnostic_msgs_DiagnosticArray_h #define _ROS_diagnostic_msgs_DiagnosticArray_h #include <stdint.h> #include <string.h> #include <stdlib.h> #include "ros/msg.h" #include "std_msgs/Header.h" #include "diagnostic_msgs/DiagnosticStatus.h" namespace diagnostic_msgs { class DiagnosticArray : public ros::Msg { public: typedef std_msgs::Header _header_type; _header_type header; uint32_t status_length; typedef diagnostic_msgs::DiagnosticStatus _status_type; _status_type st_status; _status_type * status; DiagnosticArray(): header(), status_length(0), status(NULL) { } virtual int serialize(unsigned char *outbuffer) const { int offset = 0; offset += this->header.serialize(outbuffer + offset); *(outbuffer + offset + 0) = (this->status_length >> (8 * 0)) & 0xFF; *(outbuffer + offset + 1) = (this->status_length >> (8 * 1)) & 0xFF; *(outbuffer + offset + 2) = (this->status_length >> (8 * 2)) & 0xFF; *(outbuffer + offset + 3) = (this->status_length >> (8 * 3)) & 0xFF; offset += sizeof(this->status_length); for( uint32_t i = 0; i < status_length; i++){ offset += this->status[i].serialize(outbuffer + offset); } return offset; } virtual int deserialize(unsigned char *inbuffer) { int offset = 0; offset += this->header.deserialize(inbuffer + offset); uint32_t status_lengthT = ((uint32_t) (*(inbuffer + offset))); status_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); status_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); status_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); offset += sizeof(this->status_length); if(status_lengthT > status_length) this->status = (diagnostic_msgs::DiagnosticStatus*)realloc(this->status, status_lengthT * sizeof(diagnostic_msgs::DiagnosticStatus)); status_length = status_lengthT; for( uint32_t i = 0; i < status_length; i++){ offset += this->st_status.deserialize(inbuffer + offset); memcpy( &(this->status[i]), &(this->st_status), sizeof(diagnostic_msgs::DiagnosticStatus)); } return offset; } const char * getType(){ return "diagnostic_msgs/DiagnosticArray"; }; const char * getMD5(){ return "60810da900de1dd6ddd437c3503511da"; }; }; } #endif