YARP
Yet Another Robot Platform
PointCloud.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 // This is an automatically generated file.
10 
11 // Generated from the following "sensor_msgs/PointCloud" msg definition:
12 // # This message holds a collection of 3d points, plus optional additional
13 // # information about each point.
14 //
15 // # Time of sensor data acquisition, coordinate frame ID.
16 // Header header
17 //
18 // # Array of 3d points. Each Point32 should be interpreted as a 3d point
19 // # in the frame given in the header.
20 // geometry_msgs/Point32[] points
21 //
22 // # Each channel should have the same number of elements as points array,
23 // # and the data in each channel should correspond 1:1 with each point.
24 // # Channel names in common practice are listed in ChannelFloat32.msg.
25 // ChannelFloat32[] channels
26 // Instances of this class can be read and written with YARP ports,
27 // using a ROS-compatible format.
28 
29 #ifndef YARP_ROSMSG_sensor_msgs_PointCloud_h
30 #define YARP_ROSMSG_sensor_msgs_PointCloud_h
31 
32 #include <yarp/os/Wire.h>
33 #include <yarp/os/Type.h>
34 #include <yarp/os/idl/WireTypes.h>
35 #include <string>
36 #include <vector>
40 
41 namespace yarp {
42 namespace rosmsg {
43 namespace sensor_msgs {
44 
46 {
47 public:
49  std::vector<yarp::rosmsg::geometry_msgs::Point32> points;
50  std::vector<yarp::rosmsg::sensor_msgs::ChannelFloat32> channels;
51 
53  header(),
54  points(),
55  channels()
56  {
57  }
58 
59  void clear()
60  {
61  // *** header ***
62  header.clear();
63 
64  // *** points ***
65  points.clear();
66 
67  // *** channels ***
68  channels.clear();
69  }
70 
71  bool readBare(yarp::os::ConnectionReader& connection) override
72  {
73  // *** header ***
74  if (!header.read(connection)) {
75  return false;
76  }
77 
78  // *** points ***
79  int len = connection.expectInt32();
80  points.resize(len);
81  for (int i=0; i<len; i++) {
82  if (!points[i].read(connection)) {
83  return false;
84  }
85  }
86 
87  // *** channels ***
88  len = connection.expectInt32();
89  channels.resize(len);
90  for (int i=0; i<len; i++) {
91  if (!channels[i].read(connection)) {
92  return false;
93  }
94  }
95 
96  return !connection.isError();
97  }
98 
99  bool readBottle(yarp::os::ConnectionReader& connection) override
100  {
101  connection.convertTextMode();
102  yarp::os::idl::WireReader reader(connection);
103  if (!reader.readListHeader(3)) {
104  return false;
105  }
106 
107  // *** header ***
108  if (!header.read(connection)) {
109  return false;
110  }
111 
112  // *** points ***
113  if (connection.expectInt32() != BOTTLE_TAG_LIST) {
114  return false;
115  }
116  int len = connection.expectInt32();
117  points.resize(len);
118  for (int i=0; i<len; i++) {
119  if (!points[i].read(connection)) {
120  return false;
121  }
122  }
123 
124  // *** channels ***
125  if (connection.expectInt32() != BOTTLE_TAG_LIST) {
126  return false;
127  }
128  len = connection.expectInt32();
129  channels.resize(len);
130  for (int i=0; i<len; i++) {
131  if (!channels[i].read(connection)) {
132  return false;
133  }
134  }
135 
136  return !connection.isError();
137  }
138 
140  bool read(yarp::os::ConnectionReader& connection) override
141  {
142  return (connection.isBareMode() ? readBare(connection)
143  : readBottle(connection));
144  }
145 
146  bool writeBare(yarp::os::ConnectionWriter& connection) const override
147  {
148  // *** header ***
149  if (!header.write(connection)) {
150  return false;
151  }
152 
153  // *** points ***
154  connection.appendInt32(points.size());
155  for (size_t i=0; i<points.size(); i++) {
156  if (!points[i].write(connection)) {
157  return false;
158  }
159  }
160 
161  // *** channels ***
162  connection.appendInt32(channels.size());
163  for (size_t i=0; i<channels.size(); i++) {
164  if (!channels[i].write(connection)) {
165  return false;
166  }
167  }
168 
169  return !connection.isError();
170  }
171 
172  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
173  {
174  connection.appendInt32(BOTTLE_TAG_LIST);
175  connection.appendInt32(3);
176 
177  // *** header ***
178  if (!header.write(connection)) {
179  return false;
180  }
181 
182  // *** points ***
183  connection.appendInt32(BOTTLE_TAG_LIST);
184  connection.appendInt32(points.size());
185  for (size_t i=0; i<points.size(); i++) {
186  if (!points[i].write(connection)) {
187  return false;
188  }
189  }
190 
191  // *** channels ***
192  connection.appendInt32(BOTTLE_TAG_LIST);
193  connection.appendInt32(channels.size());
194  for (size_t i=0; i<channels.size(); i++) {
195  if (!channels[i].write(connection)) {
196  return false;
197  }
198  }
199 
200  connection.convertTextMode();
201  return !connection.isError();
202  }
203 
205  bool write(yarp::os::ConnectionWriter& connection) const override
206  {
207  return (connection.isBareMode() ? writeBare(connection)
208  : writeBottle(connection));
209  }
210 
211  // This class will serialize ROS style or YARP style depending on protocol.
212  // If you need to force a serialization style, use one of these classes:
215 
216  // The name for this message, ROS will need this
217  static constexpr const char* typeName = "sensor_msgs/PointCloud";
218 
219  // The checksum for this message, ROS will need this
220  static constexpr const char* typeChecksum = "d8e9c3f5afbdd8a130fd1d2763945fca";
221 
222  // The source text for this message, ROS will need this
223  static constexpr const char* typeText = "\
224 # This message holds a collection of 3d points, plus optional additional\n\
225 # information about each point.\n\
226 \n\
227 # Time of sensor data acquisition, coordinate frame ID.\n\
228 Header header\n\
229 \n\
230 # Array of 3d points. Each Point32 should be interpreted as a 3d point\n\
231 # in the frame given in the header.\n\
232 geometry_msgs/Point32[] points\n\
233 \n\
234 # Each channel should have the same number of elements as points array,\n\
235 # and the data in each channel should correspond 1:1 with each point.\n\
236 # Channel names in common practice are listed in ChannelFloat32.msg.\n\
237 ChannelFloat32[] channels\n\
238 \n\
239 ================================================================================\n\
240 MSG: std_msgs/Header\n\
241 # Standard metadata for higher-level stamped data types.\n\
242 # This is generally used to communicate timestamped data \n\
243 # in a particular coordinate frame.\n\
244 # \n\
245 # sequence ID: consecutively increasing ID \n\
246 uint32 seq\n\
247 #Two-integer timestamp that is expressed as:\n\
248 # * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\
249 # * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\
250 # time-handling sugar is provided by the client library\n\
251 time stamp\n\
252 #Frame this data is associated with\n\
253 # 0: no frame\n\
254 # 1: global frame\n\
255 string frame_id\n\
256 \n\
257 ================================================================================\n\
258 MSG: geometry_msgs/Point32\n\
259 # This contains the position of a point in free space(with 32 bits of precision).\n\
260 # It is recommeded to use Point wherever possible instead of Point32. \n\
261 # \n\
262 # This recommendation is to promote interoperability. \n\
263 #\n\
264 # This message is designed to take up less space when sending\n\
265 # lots of points at once, as in the case of a PointCloud. \n\
266 \n\
267 float32 x\n\
268 float32 y\n\
269 float32 z\n\
270 ================================================================================\n\
271 MSG: sensor_msgs/ChannelFloat32\n\
272 # This message is used by the PointCloud message to hold optional data\n\
273 # associated with each point in the cloud. The length of the values\n\
274 # array should be the same as the length of the points array in the\n\
275 # PointCloud, and each value should be associated with the corresponding\n\
276 # point.\n\
277 \n\
278 # Channel names in existing practice include:\n\
279 # \"u\", \"v\" - row and column (respectively) in the left stereo image.\n\
280 # This is opposite to usual conventions but remains for\n\
281 # historical reasons. The newer PointCloud2 message has no\n\
282 # such problem.\n\
283 # \"rgb\" - For point clouds produced by color stereo cameras. uint8\n\
284 # (R,G,B) values packed into the least significant 24 bits,\n\
285 # in order.\n\
286 # \"intensity\" - laser or pixel intensity.\n\
287 # \"distance\"\n\
288 \n\
289 # The channel name should give semantics of the channel (e.g.\n\
290 # \"intensity\" instead of \"value\").\n\
291 string name\n\
292 \n\
293 # The values array should be 1-1 with the elements of the associated\n\
294 # PointCloud.\n\
295 float32[] values\n\
296 ";
297 
298  yarp::os::Type getType() const override
299  {
300  yarp::os::Type typ = yarp::os::Type::byName(typeName, typeName);
301  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
302  typ.addProperty("message_definition", yarp::os::Value(typeText));
303  return typ;
304  }
305 };
306 
307 } // namespace sensor_msgs
308 } // namespace rosmsg
309 } // namespace yarp
310 
311 #endif // YARP_ROSMSG_sensor_msgs_PointCloud_h
static constexpr const char * typeChecksum
Definition: PointCloud.h:220
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: PointCloud.h:205
static Type byName(const char *name)
Definition: Type.cpp:176
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: PointCloud.h:71
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:138
yarp::os::idl::BareStyle< yarp::rosmsg::sensor_msgs::PointCloud > rosStyle
Definition: PointCloud.h:213
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: PointCloud.h:172
virtual bool isError() const =0
The main, catch-all namespace for YARP.
Definition: numeric.h:47
std::vector< yarp::rosmsg::sensor_msgs::ChannelFloat32 > channels
Definition: PointCloud.h:50
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary...
yarp::rosmsg::std_msgs::Header header
Definition: PointCloud.h:48
yarp::os::idl::BottleStyle< yarp::rosmsg::sensor_msgs::PointCloud > bottleStyle
Definition: PointCloud.h:214
virtual bool isBareMode() const =0
Check if the connection is bare mode.
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: PointCloud.h:146
static constexpr const char * typeText
Definition: PointCloud.h:223
An interface for writing to a network connection.
virtual bool write(const yarp::os::idl::WireWriter &writer) const
virtual void appendInt32(std::int32_t data)=0
Send a representation of a 32-bit integer to the network connection.
virtual bool read(yarp::os::idl::WireReader &reader)
virtual bool isError() const =0
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Header.h:162
yarp::os::Type getType() const override
Definition: PointCloud.h:298
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:33
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: PointCloud.h:99
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
An interface for reading from a network connection.
A single value (typically within a Bottle).
Definition: Value.h:46
virtual bool isBareMode() const =0
Check if the connection is bare mode.
virtual bool convertTextMode()=0
Converts a standard description in binary into a textual description, if the connection is in text-mo...
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: PointCloud.h:140
static constexpr const char * typeName
Definition: PointCloud.h:217
IDL-friendly connection reader.
Definition: WireReader.h:32
std::vector< yarp::rosmsg::geometry_msgs::Point32 > points
Definition: PointCloud.h:49
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Header.h:115