Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Robot_team1_QEI_Douglas Robot_team1
lidar_msg.h
00001 #ifndef _ROS_mbed_custom_msgs_lidar_msg_h 00002 #define _ROS_mbed_custom_msgs_lidar_msg_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 mbed_custom_msgs 00011 { 00012 00013 class lidar_msg : public ros::Msg 00014 { 00015 public: 00016 typedef std_msgs::Header _header_type; 00017 _header_type header; 00018 typedef uint32_t _sensor_forward_type; 00019 _sensor_forward_type sensor_forward; 00020 typedef uint32_t _sensor_back_type; 00021 _sensor_back_type sensor_back; 00022 typedef uint32_t _sensor_left_type; 00023 _sensor_left_type sensor_left; 00024 typedef uint32_t _sensor_right_type; 00025 _sensor_right_type sensor_right; 00026 typedef const char* _data_type; 00027 _data_type data; 00028 00029 lidar_msg(): 00030 header(), 00031 sensor_forward(0), 00032 sensor_back(0), 00033 sensor_left(0), 00034 sensor_right(0), 00035 data("") 00036 { 00037 } 00038 00039 virtual int serialize(unsigned char *outbuffer) const 00040 { 00041 int offset = 0; 00042 offset += this->header.serialize(outbuffer + offset); 00043 *(outbuffer + offset + 0) = (this->sensor_forward >> (8 * 0)) & 0xFF; 00044 *(outbuffer + offset + 1) = (this->sensor_forward >> (8 * 1)) & 0xFF; 00045 *(outbuffer + offset + 2) = (this->sensor_forward >> (8 * 2)) & 0xFF; 00046 *(outbuffer + offset + 3) = (this->sensor_forward >> (8 * 3)) & 0xFF; 00047 offset += sizeof(this->sensor_forward); 00048 *(outbuffer + offset + 0) = (this->sensor_back >> (8 * 0)) & 0xFF; 00049 *(outbuffer + offset + 1) = (this->sensor_back >> (8 * 1)) & 0xFF; 00050 *(outbuffer + offset + 2) = (this->sensor_back >> (8 * 2)) & 0xFF; 00051 *(outbuffer + offset + 3) = (this->sensor_back >> (8 * 3)) & 0xFF; 00052 offset += sizeof(this->sensor_back); 00053 *(outbuffer + offset + 0) = (this->sensor_left >> (8 * 0)) & 0xFF; 00054 *(outbuffer + offset + 1) = (this->sensor_left >> (8 * 1)) & 0xFF; 00055 *(outbuffer + offset + 2) = (this->sensor_left >> (8 * 2)) & 0xFF; 00056 *(outbuffer + offset + 3) = (this->sensor_left >> (8 * 3)) & 0xFF; 00057 offset += sizeof(this->sensor_left); 00058 *(outbuffer + offset + 0) = (this->sensor_right >> (8 * 0)) & 0xFF; 00059 *(outbuffer + offset + 1) = (this->sensor_right >> (8 * 1)) & 0xFF; 00060 *(outbuffer + offset + 2) = (this->sensor_right >> (8 * 2)) & 0xFF; 00061 *(outbuffer + offset + 3) = (this->sensor_right >> (8 * 3)) & 0xFF; 00062 offset += sizeof(this->sensor_right); 00063 uint32_t length_data = strlen(this->data); 00064 varToArr(outbuffer + offset, length_data); 00065 offset += 4; 00066 memcpy(outbuffer + offset, this->data, length_data); 00067 offset += length_data; 00068 return offset; 00069 } 00070 00071 virtual int deserialize(unsigned char *inbuffer) 00072 { 00073 int offset = 0; 00074 offset += this->header.deserialize(inbuffer + offset); 00075 this->sensor_forward = ((uint32_t) (*(inbuffer + offset))); 00076 this->sensor_forward |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00077 this->sensor_forward |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00078 this->sensor_forward |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00079 offset += sizeof(this->sensor_forward); 00080 this->sensor_back = ((uint32_t) (*(inbuffer + offset))); 00081 this->sensor_back |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00082 this->sensor_back |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00083 this->sensor_back |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00084 offset += sizeof(this->sensor_back); 00085 this->sensor_left = ((uint32_t) (*(inbuffer + offset))); 00086 this->sensor_left |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00087 this->sensor_left |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00088 this->sensor_left |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00089 offset += sizeof(this->sensor_left); 00090 this->sensor_right = ((uint32_t) (*(inbuffer + offset))); 00091 this->sensor_right |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00092 this->sensor_right |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00093 this->sensor_right |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00094 offset += sizeof(this->sensor_right); 00095 uint32_t length_data; 00096 arrToVar(length_data, (inbuffer + offset)); 00097 offset += 4; 00098 for(unsigned int k= offset; k< offset+length_data; ++k){ 00099 inbuffer[k-1]=inbuffer[k]; 00100 } 00101 inbuffer[offset+length_data-1]=0; 00102 this->data = (char *)(inbuffer + offset-1); 00103 offset += length_data; 00104 return offset; 00105 } 00106 00107 const char * getType(){ return "mbed_custom_msgs/lidar_msg"; }; 00108 const char * getMD5(){ return "1576a60ced5a1f58d271af7970886f43"; }; 00109 00110 }; 00111 00112 } 00113 #endif
Generated on Tue Jul 12 2022 15:50:03 by
