ros melodic library with custom message

Dependents:   Robot_team1_QEI_Douglas Robot_team1

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?

UserRevisionLine numberNew contents of line
scarter1 0:020db18a476d 1 #ifndef _ROS_stereo_msgs_DisparityImage_h
scarter1 0:020db18a476d 2 #define _ROS_stereo_msgs_DisparityImage_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 #include "std_msgs/Header.h"
scarter1 0:020db18a476d 9 #include "sensor_msgs/Image.h"
scarter1 0:020db18a476d 10 #include "sensor_msgs/RegionOfInterest.h"
scarter1 0:020db18a476d 11
scarter1 0:020db18a476d 12 namespace stereo_msgs
scarter1 0:020db18a476d 13 {
scarter1 0:020db18a476d 14
scarter1 0:020db18a476d 15 class DisparityImage : public ros::Msg
scarter1 0:020db18a476d 16 {
scarter1 0:020db18a476d 17 public:
scarter1 0:020db18a476d 18 typedef std_msgs::Header _header_type;
scarter1 0:020db18a476d 19 _header_type header;
scarter1 0:020db18a476d 20 typedef sensor_msgs::Image _image_type;
scarter1 0:020db18a476d 21 _image_type image;
scarter1 0:020db18a476d 22 typedef float _f_type;
scarter1 0:020db18a476d 23 _f_type f;
scarter1 0:020db18a476d 24 typedef float _T_type;
scarter1 0:020db18a476d 25 _T_type T;
scarter1 0:020db18a476d 26 typedef sensor_msgs::RegionOfInterest _valid_window_type;
scarter1 0:020db18a476d 27 _valid_window_type valid_window;
scarter1 0:020db18a476d 28 typedef float _min_disparity_type;
scarter1 0:020db18a476d 29 _min_disparity_type min_disparity;
scarter1 0:020db18a476d 30 typedef float _max_disparity_type;
scarter1 0:020db18a476d 31 _max_disparity_type max_disparity;
scarter1 0:020db18a476d 32 typedef float _delta_d_type;
scarter1 0:020db18a476d 33 _delta_d_type delta_d;
scarter1 0:020db18a476d 34
scarter1 0:020db18a476d 35 DisparityImage():
scarter1 0:020db18a476d 36 header(),
scarter1 0:020db18a476d 37 image(),
scarter1 0:020db18a476d 38 f(0),
scarter1 0:020db18a476d 39 T(0),
scarter1 0:020db18a476d 40 valid_window(),
scarter1 0:020db18a476d 41 min_disparity(0),
scarter1 0:020db18a476d 42 max_disparity(0),
scarter1 0:020db18a476d 43 delta_d(0)
scarter1 0:020db18a476d 44 {
scarter1 0:020db18a476d 45 }
scarter1 0:020db18a476d 46
scarter1 0:020db18a476d 47 virtual int serialize(unsigned char *outbuffer) const
scarter1 0:020db18a476d 48 {
scarter1 0:020db18a476d 49 int offset = 0;
scarter1 0:020db18a476d 50 offset += this->header.serialize(outbuffer + offset);
scarter1 0:020db18a476d 51 offset += this->image.serialize(outbuffer + offset);
scarter1 0:020db18a476d 52 union {
scarter1 0:020db18a476d 53 float real;
scarter1 0:020db18a476d 54 uint32_t base;
scarter1 0:020db18a476d 55 } u_f;
scarter1 0:020db18a476d 56 u_f.real = this->f;
scarter1 0:020db18a476d 57 *(outbuffer + offset + 0) = (u_f.base >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 58 *(outbuffer + offset + 1) = (u_f.base >> (8 * 1)) & 0xFF;
scarter1 0:020db18a476d 59 *(outbuffer + offset + 2) = (u_f.base >> (8 * 2)) & 0xFF;
scarter1 0:020db18a476d 60 *(outbuffer + offset + 3) = (u_f.base >> (8 * 3)) & 0xFF;
scarter1 0:020db18a476d 61 offset += sizeof(this->f);
scarter1 0:020db18a476d 62 union {
scarter1 0:020db18a476d 63 float real;
scarter1 0:020db18a476d 64 uint32_t base;
scarter1 0:020db18a476d 65 } u_T;
scarter1 0:020db18a476d 66 u_T.real = this->T;
scarter1 0:020db18a476d 67 *(outbuffer + offset + 0) = (u_T.base >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 68 *(outbuffer + offset + 1) = (u_T.base >> (8 * 1)) & 0xFF;
scarter1 0:020db18a476d 69 *(outbuffer + offset + 2) = (u_T.base >> (8 * 2)) & 0xFF;
scarter1 0:020db18a476d 70 *(outbuffer + offset + 3) = (u_T.base >> (8 * 3)) & 0xFF;
scarter1 0:020db18a476d 71 offset += sizeof(this->T);
scarter1 0:020db18a476d 72 offset += this->valid_window.serialize(outbuffer + offset);
scarter1 0:020db18a476d 73 union {
scarter1 0:020db18a476d 74 float real;
scarter1 0:020db18a476d 75 uint32_t base;
scarter1 0:020db18a476d 76 } u_min_disparity;
scarter1 0:020db18a476d 77 u_min_disparity.real = this->min_disparity;
scarter1 0:020db18a476d 78 *(outbuffer + offset + 0) = (u_min_disparity.base >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 79 *(outbuffer + offset + 1) = (u_min_disparity.base >> (8 * 1)) & 0xFF;
scarter1 0:020db18a476d 80 *(outbuffer + offset + 2) = (u_min_disparity.base >> (8 * 2)) & 0xFF;
scarter1 0:020db18a476d 81 *(outbuffer + offset + 3) = (u_min_disparity.base >> (8 * 3)) & 0xFF;
scarter1 0:020db18a476d 82 offset += sizeof(this->min_disparity);
scarter1 0:020db18a476d 83 union {
scarter1 0:020db18a476d 84 float real;
scarter1 0:020db18a476d 85 uint32_t base;
scarter1 0:020db18a476d 86 } u_max_disparity;
scarter1 0:020db18a476d 87 u_max_disparity.real = this->max_disparity;
scarter1 0:020db18a476d 88 *(outbuffer + offset + 0) = (u_max_disparity.base >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 89 *(outbuffer + offset + 1) = (u_max_disparity.base >> (8 * 1)) & 0xFF;
scarter1 0:020db18a476d 90 *(outbuffer + offset + 2) = (u_max_disparity.base >> (8 * 2)) & 0xFF;
scarter1 0:020db18a476d 91 *(outbuffer + offset + 3) = (u_max_disparity.base >> (8 * 3)) & 0xFF;
scarter1 0:020db18a476d 92 offset += sizeof(this->max_disparity);
scarter1 0:020db18a476d 93 union {
scarter1 0:020db18a476d 94 float real;
scarter1 0:020db18a476d 95 uint32_t base;
scarter1 0:020db18a476d 96 } u_delta_d;
scarter1 0:020db18a476d 97 u_delta_d.real = this->delta_d;
scarter1 0:020db18a476d 98 *(outbuffer + offset + 0) = (u_delta_d.base >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 99 *(outbuffer + offset + 1) = (u_delta_d.base >> (8 * 1)) & 0xFF;
scarter1 0:020db18a476d 100 *(outbuffer + offset + 2) = (u_delta_d.base >> (8 * 2)) & 0xFF;
scarter1 0:020db18a476d 101 *(outbuffer + offset + 3) = (u_delta_d.base >> (8 * 3)) & 0xFF;
scarter1 0:020db18a476d 102 offset += sizeof(this->delta_d);
scarter1 0:020db18a476d 103 return offset;
scarter1 0:020db18a476d 104 }
scarter1 0:020db18a476d 105
scarter1 0:020db18a476d 106 virtual int deserialize(unsigned char *inbuffer)
scarter1 0:020db18a476d 107 {
scarter1 0:020db18a476d 108 int offset = 0;
scarter1 0:020db18a476d 109 offset += this->header.deserialize(inbuffer + offset);
scarter1 0:020db18a476d 110 offset += this->image.deserialize(inbuffer + offset);
scarter1 0:020db18a476d 111 union {
scarter1 0:020db18a476d 112 float real;
scarter1 0:020db18a476d 113 uint32_t base;
scarter1 0:020db18a476d 114 } u_f;
scarter1 0:020db18a476d 115 u_f.base = 0;
scarter1 0:020db18a476d 116 u_f.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
scarter1 0:020db18a476d 117 u_f.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
scarter1 0:020db18a476d 118 u_f.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
scarter1 0:020db18a476d 119 u_f.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
scarter1 0:020db18a476d 120 this->f = u_f.real;
scarter1 0:020db18a476d 121 offset += sizeof(this->f);
scarter1 0:020db18a476d 122 union {
scarter1 0:020db18a476d 123 float real;
scarter1 0:020db18a476d 124 uint32_t base;
scarter1 0:020db18a476d 125 } u_T;
scarter1 0:020db18a476d 126 u_T.base = 0;
scarter1 0:020db18a476d 127 u_T.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
scarter1 0:020db18a476d 128 u_T.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
scarter1 0:020db18a476d 129 u_T.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
scarter1 0:020db18a476d 130 u_T.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
scarter1 0:020db18a476d 131 this->T = u_T.real;
scarter1 0:020db18a476d 132 offset += sizeof(this->T);
scarter1 0:020db18a476d 133 offset += this->valid_window.deserialize(inbuffer + offset);
scarter1 0:020db18a476d 134 union {
scarter1 0:020db18a476d 135 float real;
scarter1 0:020db18a476d 136 uint32_t base;
scarter1 0:020db18a476d 137 } u_min_disparity;
scarter1 0:020db18a476d 138 u_min_disparity.base = 0;
scarter1 0:020db18a476d 139 u_min_disparity.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
scarter1 0:020db18a476d 140 u_min_disparity.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
scarter1 0:020db18a476d 141 u_min_disparity.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
scarter1 0:020db18a476d 142 u_min_disparity.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
scarter1 0:020db18a476d 143 this->min_disparity = u_min_disparity.real;
scarter1 0:020db18a476d 144 offset += sizeof(this->min_disparity);
scarter1 0:020db18a476d 145 union {
scarter1 0:020db18a476d 146 float real;
scarter1 0:020db18a476d 147 uint32_t base;
scarter1 0:020db18a476d 148 } u_max_disparity;
scarter1 0:020db18a476d 149 u_max_disparity.base = 0;
scarter1 0:020db18a476d 150 u_max_disparity.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
scarter1 0:020db18a476d 151 u_max_disparity.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
scarter1 0:020db18a476d 152 u_max_disparity.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
scarter1 0:020db18a476d 153 u_max_disparity.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
scarter1 0:020db18a476d 154 this->max_disparity = u_max_disparity.real;
scarter1 0:020db18a476d 155 offset += sizeof(this->max_disparity);
scarter1 0:020db18a476d 156 union {
scarter1 0:020db18a476d 157 float real;
scarter1 0:020db18a476d 158 uint32_t base;
scarter1 0:020db18a476d 159 } u_delta_d;
scarter1 0:020db18a476d 160 u_delta_d.base = 0;
scarter1 0:020db18a476d 161 u_delta_d.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
scarter1 0:020db18a476d 162 u_delta_d.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
scarter1 0:020db18a476d 163 u_delta_d.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
scarter1 0:020db18a476d 164 u_delta_d.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
scarter1 0:020db18a476d 165 this->delta_d = u_delta_d.real;
scarter1 0:020db18a476d 166 offset += sizeof(this->delta_d);
scarter1 0:020db18a476d 167 return offset;
scarter1 0:020db18a476d 168 }
scarter1 0:020db18a476d 169
scarter1 0:020db18a476d 170 const char * getType(){ return "stereo_msgs/DisparityImage"; };
scarter1 0:020db18a476d 171 const char * getMD5(){ return "04a177815f75271039fa21f16acad8c9"; };
scarter1 0:020db18a476d 172
scarter1 0:020db18a476d 173 };
scarter1 0:020db18a476d 174
scarter1 0:020db18a476d 175 }
scarter1 0:020db18a476d 176 #endif