ROS Serial library for Mbed platforms for ROS Melodic Morenia. Check http://wiki.ros.org/rosserial_mbed/ for more information.

Dependencies:   BufferedSerial

Committer:
Gary Servin
Date:
Fri Nov 08 14:38:09 2019 -0300
Revision:
0:04ac6be8229a
Initial commit, generated based on a clean melodic-desktop-full

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Gary Servin 0:04ac6be8229a 1 #ifndef _ROS_sensor_msgs_PointCloud_h
Gary Servin 0:04ac6be8229a 2 #define _ROS_sensor_msgs_PointCloud_h
Gary Servin 0:04ac6be8229a 3
Gary Servin 0:04ac6be8229a 4 #include <stdint.h>
Gary Servin 0:04ac6be8229a 5 #include <string.h>
Gary Servin 0:04ac6be8229a 6 #include <stdlib.h>
Gary Servin 0:04ac6be8229a 7 #include "ros/msg.h"
Gary Servin 0:04ac6be8229a 8 #include "std_msgs/Header.h"
Gary Servin 0:04ac6be8229a 9 #include "geometry_msgs/Point32.h"
Gary Servin 0:04ac6be8229a 10 #include "sensor_msgs/ChannelFloat32.h"
Gary Servin 0:04ac6be8229a 11
Gary Servin 0:04ac6be8229a 12 namespace sensor_msgs
Gary Servin 0:04ac6be8229a 13 {
Gary Servin 0:04ac6be8229a 14
Gary Servin 0:04ac6be8229a 15 class PointCloud : public ros::Msg
Gary Servin 0:04ac6be8229a 16 {
Gary Servin 0:04ac6be8229a 17 public:
Gary Servin 0:04ac6be8229a 18 typedef std_msgs::Header _header_type;
Gary Servin 0:04ac6be8229a 19 _header_type header;
Gary Servin 0:04ac6be8229a 20 uint32_t points_length;
Gary Servin 0:04ac6be8229a 21 typedef geometry_msgs::Point32 _points_type;
Gary Servin 0:04ac6be8229a 22 _points_type st_points;
Gary Servin 0:04ac6be8229a 23 _points_type * points;
Gary Servin 0:04ac6be8229a 24 uint32_t channels_length;
Gary Servin 0:04ac6be8229a 25 typedef sensor_msgs::ChannelFloat32 _channels_type;
Gary Servin 0:04ac6be8229a 26 _channels_type st_channels;
Gary Servin 0:04ac6be8229a 27 _channels_type * channels;
Gary Servin 0:04ac6be8229a 28
Gary Servin 0:04ac6be8229a 29 PointCloud():
Gary Servin 0:04ac6be8229a 30 header(),
Gary Servin 0:04ac6be8229a 31 points_length(0), points(NULL),
Gary Servin 0:04ac6be8229a 32 channels_length(0), channels(NULL)
Gary Servin 0:04ac6be8229a 33 {
Gary Servin 0:04ac6be8229a 34 }
Gary Servin 0:04ac6be8229a 35
Gary Servin 0:04ac6be8229a 36 virtual int serialize(unsigned char *outbuffer) const
Gary Servin 0:04ac6be8229a 37 {
Gary Servin 0:04ac6be8229a 38 int offset = 0;
Gary Servin 0:04ac6be8229a 39 offset += this->header.serialize(outbuffer + offset);
Gary Servin 0:04ac6be8229a 40 *(outbuffer + offset + 0) = (this->points_length >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 41 *(outbuffer + offset + 1) = (this->points_length >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 42 *(outbuffer + offset + 2) = (this->points_length >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 43 *(outbuffer + offset + 3) = (this->points_length >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 44 offset += sizeof(this->points_length);
Gary Servin 0:04ac6be8229a 45 for( uint32_t i = 0; i < points_length; i++){
Gary Servin 0:04ac6be8229a 46 offset += this->points[i].serialize(outbuffer + offset);
Gary Servin 0:04ac6be8229a 47 }
Gary Servin 0:04ac6be8229a 48 *(outbuffer + offset + 0) = (this->channels_length >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 49 *(outbuffer + offset + 1) = (this->channels_length >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 50 *(outbuffer + offset + 2) = (this->channels_length >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 51 *(outbuffer + offset + 3) = (this->channels_length >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 52 offset += sizeof(this->channels_length);
Gary Servin 0:04ac6be8229a 53 for( uint32_t i = 0; i < channels_length; i++){
Gary Servin 0:04ac6be8229a 54 offset += this->channels[i].serialize(outbuffer + offset);
Gary Servin 0:04ac6be8229a 55 }
Gary Servin 0:04ac6be8229a 56 return offset;
Gary Servin 0:04ac6be8229a 57 }
Gary Servin 0:04ac6be8229a 58
Gary Servin 0:04ac6be8229a 59 virtual int deserialize(unsigned char *inbuffer)
Gary Servin 0:04ac6be8229a 60 {
Gary Servin 0:04ac6be8229a 61 int offset = 0;
Gary Servin 0:04ac6be8229a 62 offset += this->header.deserialize(inbuffer + offset);
Gary Servin 0:04ac6be8229a 63 uint32_t points_lengthT = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 64 points_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 65 points_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 66 points_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 67 offset += sizeof(this->points_length);
Gary Servin 0:04ac6be8229a 68 if(points_lengthT > points_length)
Gary Servin 0:04ac6be8229a 69 this->points = (geometry_msgs::Point32*)realloc(this->points, points_lengthT * sizeof(geometry_msgs::Point32));
Gary Servin 0:04ac6be8229a 70 points_length = points_lengthT;
Gary Servin 0:04ac6be8229a 71 for( uint32_t i = 0; i < points_length; i++){
Gary Servin 0:04ac6be8229a 72 offset += this->st_points.deserialize(inbuffer + offset);
Gary Servin 0:04ac6be8229a 73 memcpy( &(this->points[i]), &(this->st_points), sizeof(geometry_msgs::Point32));
Gary Servin 0:04ac6be8229a 74 }
Gary Servin 0:04ac6be8229a 75 uint32_t channels_lengthT = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 76 channels_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 77 channels_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 78 channels_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 79 offset += sizeof(this->channels_length);
Gary Servin 0:04ac6be8229a 80 if(channels_lengthT > channels_length)
Gary Servin 0:04ac6be8229a 81 this->channels = (sensor_msgs::ChannelFloat32*)realloc(this->channels, channels_lengthT * sizeof(sensor_msgs::ChannelFloat32));
Gary Servin 0:04ac6be8229a 82 channels_length = channels_lengthT;
Gary Servin 0:04ac6be8229a 83 for( uint32_t i = 0; i < channels_length; i++){
Gary Servin 0:04ac6be8229a 84 offset += this->st_channels.deserialize(inbuffer + offset);
Gary Servin 0:04ac6be8229a 85 memcpy( &(this->channels[i]), &(this->st_channels), sizeof(sensor_msgs::ChannelFloat32));
Gary Servin 0:04ac6be8229a 86 }
Gary Servin 0:04ac6be8229a 87 return offset;
Gary Servin 0:04ac6be8229a 88 }
Gary Servin 0:04ac6be8229a 89
Gary Servin 0:04ac6be8229a 90 const char * getType(){ return "sensor_msgs/PointCloud"; };
Gary Servin 0:04ac6be8229a 91 const char * getMD5(){ return "d8e9c3f5afbdd8a130fd1d2763945fca"; };
Gary Servin 0:04ac6be8229a 92
Gary Servin 0:04ac6be8229a 93 };
Gary Servin 0:04ac6be8229a 94
Gary Servin 0:04ac6be8229a 95 }
Gary Servin 0:04ac6be8229a 96 #endif